run.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. cargo build --target $1
  39. cargo build --target $1 --release
  40. cargo build --target $1 --features c
  41. cargo build --target $1 --release --features c
  42. fi
  43. PREFIX=$(echo $1 | sed -e 's/unknown-//')-
  44. case $1 in
  45. armv7-*)
  46. PREFIX=arm-linux-gnueabihf-
  47. ;;
  48. thumb*)
  49. PREFIX=arm-none-eabi-
  50. ;;
  51. *86*-*)
  52. PREFIX=
  53. ;;
  54. esac
  55. NM=nm
  56. if [ -d /target ]; then
  57. path=/target/${1}/debug/deps/libcompiler_builtins-*.rlib
  58. else
  59. path=target/${1}/debug/deps/libcompiler_builtins-*.rlib
  60. fi
  61. # Look out for duplicated symbols when we include the compiler-rt (C) implementation
  62. for rlib in $(echo $path); do
  63. set +x
  64. echo "================================================================"
  65. echo checking $rlib for duplicate symbols
  66. echo "================================================================"
  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