run.sh 3.8 KB

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