run.sh 3.3 KB

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