run.sh 3.0 KB

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