run.sh 3.7 KB

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