run.sh 3.3 KB

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