run.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. set -ex
  2. # FIXME(japarix/xargo#186) this shouldn't be necessary
  3. export RUST_TARGET_PATH=`pwd`
  4. case $1 in
  5. thumb*)
  6. cargo=xargo
  7. ;;
  8. *)
  9. cargo=cargo
  10. ;;
  11. esac
  12. INTRINSICS_FEATURES="c"
  13. # Some architectures like ARM apparently seem to require the `mem` feature
  14. # enabled to successfully compile the `intrinsics` example, and... we're not
  15. # sure why!
  16. if [ -z "$INTRINSICS_FAILS_WITH_MEM_FEATURE" ]; then
  17. INTRINSICS_FEATURES="$INTRINSICS_FEATURES mem"
  18. fi
  19. # Test our implementation
  20. case $1 in
  21. thumb*)
  22. run="xargo test --manifest-path testcrate/Cargo.toml --target $1"
  23. for t in $(ls testcrate/tests); do
  24. t=${t%.rs}
  25. RUSTFLAGS="-C debug-assertions=no -C lto" \
  26. CARGO_INCREMENTAL=0 \
  27. $run --test $t --no-default-features --features 'mem c' --no-run
  28. qemu-arm-static target/${1}/debug/$t-*
  29. done
  30. for t in $(ls testcrate/tests); do
  31. t=${t%.rs}
  32. RUSTFLAGS="-C lto" \
  33. CARGO_INCREMENTAL=0 \
  34. $run --test $t --no-default-features --features 'mem c' --no-run --release
  35. qemu-arm-static target/${1}/release/$t-*
  36. done
  37. ;;
  38. *)
  39. run="cargo test --manifest-path testcrate/Cargo.toml --target $1"
  40. $run
  41. $run --release
  42. $run --features c
  43. $run --features c --release
  44. ;;
  45. esac
  46. PREFIX=$(echo $1 | sed -e 's/unknown-//')-
  47. case $1 in
  48. armv7-*)
  49. PREFIX=arm-linux-gnueabihf-
  50. ;;
  51. thumb*)
  52. PREFIX=arm-none-eabi-
  53. ;;
  54. *86*-*)
  55. PREFIX=
  56. ;;
  57. esac
  58. NM=nm
  59. if [ -d /target ]; then
  60. path=/target/${1}/debug/deps/libcompiler_builtins-*.rlib
  61. else
  62. path=target/${1}/debug/deps/libcompiler_builtins-*.rlib
  63. fi
  64. # Look out for duplicated symbols when we include the compiler-rt (C) implementation
  65. for rlib in $(echo $path); do
  66. set +x
  67. stdout=$($PREFIX$NM -g --defined-only $rlib 2>&1)
  68. # NOTE On i586, It's normal that the get_pc_thunk symbol appears several
  69. # times so ignore it
  70. #
  71. # FIXME(#167) - we shouldn't ignore `__builtin_cl` style symbols here.
  72. set +e
  73. echo "$stdout" | \
  74. sort | \
  75. uniq -d | \
  76. grep -v __x86.get_pc_thunk | \
  77. grep -v __builtin_cl | \
  78. grep -v __builtin_ctz | \
  79. grep 'T __'
  80. if test $? = 0; then
  81. exit 1
  82. fi
  83. set -ex
  84. done
  85. rm -f $path
  86. # Verify that we haven't drop any intrinsic/symbol
  87. RUSTFLAGS="-C debug-assertions=no" \
  88. $cargo build --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics -v
  89. # Verify that there are no undefined symbols to `panic` within our
  90. # implementations
  91. #
  92. # TODO(#79) fix the undefined references problem for debug-assertions+lto
  93. if [ -z "$DEBUG_LTO_BUILD_DOESNT_WORK" ]; then
  94. RUSTFLAGS="-C debug-assertions=no" \
  95. CARGO_INCREMENTAL=0 \
  96. $cargo rustc --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics -- -C lto
  97. fi
  98. $cargo rustc --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics --release -- -C lto
  99. # Ensure no references to a panicking function
  100. for rlib in $(echo $path); do
  101. set +ex
  102. $PREFIX$NM -u $rlib 2>&1 | grep panicking
  103. if test $? = 0; then
  104. exit 1
  105. fi
  106. set -ex
  107. done
  108. true