run.sh 3.4 KB

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