run.sh 3.5 KB

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