run.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. case "$TRAVIS_OS_NAME" in
  59. osx)
  60. # NOTE OSx's nm doesn't accept the `--defined-only` or provide an equivalent.
  61. # Use GNU nm instead
  62. NM=gnm
  63. brew update
  64. brew install binutils
  65. ;;
  66. *)
  67. NM=nm
  68. ;;
  69. esac
  70. if [ -d /target ]; then
  71. path=/target/${1}/debug/deps/libcompiler_builtins-*.rlib
  72. else
  73. path=target/${1}/debug/deps/libcompiler_builtins-*.rlib
  74. fi
  75. # Look out for duplicated symbols when we include the compiler-rt (C) implementation
  76. for rlib in $(echo $path); do
  77. set +x
  78. stdout=$($PREFIX$NM -g --defined-only $rlib 2>&1)
  79. # NOTE On i586, It's normal that the get_pc_thunk symbol appears several
  80. # times so ignore it
  81. #
  82. # FIXME(#167) - we shouldn't ignore `__builtin_cl` style symbols here.
  83. set +e
  84. echo "$stdout" | \
  85. sort | \
  86. uniq -d | \
  87. grep -v __x86.get_pc_thunk | \
  88. grep -v __builtin_cl | \
  89. grep -v __builtin_ctz | \
  90. grep 'T __'
  91. if test $? = 0; then
  92. exit 1
  93. fi
  94. set -ex
  95. done
  96. rm -f $path
  97. # Verify that we haven't drop any intrinsic/symbol
  98. RUSTFLAGS="-C debug-assertions=no" \
  99. $cargo build --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics -v
  100. # Verify that there are no undefined symbols to `panic` within our
  101. # implementations
  102. #
  103. # TODO(#79) fix the undefined references problem for debug-assertions+lto
  104. if [ -z "$DEBUG_LTO_BUILD_DOESNT_WORK" ]; then
  105. RUSTFLAGS="-C debug-assertions=no" \
  106. CARGO_INCREMENTAL=0 \
  107. $cargo rustc --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics -- -C lto
  108. fi
  109. $cargo rustc --features "$INTRINSICS_FEATURES" --target $1 --example intrinsics --release -- -C lto
  110. # Ensure no references to a panicking function
  111. for rlib in $(echo $path); do
  112. set +ex
  113. $PREFIX$NM -u $rlib 2>&1 | grep panicking
  114. if test $? = 0; then
  115. exit 1
  116. fi
  117. set -ex
  118. done
  119. true