script.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. set -ex
  2. . $(dirname $0)/env.sh
  3. gist_it() {
  4. gist -d "'$TARGET/rustc-builtins.rlib' from commit '$TRAVIS_COMMIT' on branch '$TRAVIS_BRANCH'"
  5. echo "Disassembly available at the above URL."
  6. }
  7. build() {
  8. if [[ $WEAK ]]; then
  9. $CARGO build --features weak --target $TARGET
  10. $CARGO build --features weak --target $TARGET --release
  11. else
  12. $CARGO build --target $TARGET
  13. $CARGO build --target $TARGET --release
  14. fi
  15. }
  16. inspect() {
  17. $PREFIX$NM -g --defined-only target/**/debug/*.rlib
  18. set +e
  19. $PREFIX$OBJDUMP -Cd target/**/release/*.rlib | gist_it
  20. set -e
  21. # Check presence/absence of weak symbols
  22. if [[ $WEAK ]]; then
  23. local symbols=( memcmp memcpy memmove memset )
  24. for symbol in "${symbols[@]}"; do
  25. $PREFIX$NM target/$TARGET/debug/deps/librlibc-*.rlib | grep -q "W $symbol"
  26. done
  27. else
  28. set +e
  29. ls target/$TARGET/debug/deps/librlibc-*.rlib
  30. if [[ $? == 0 ]]; then
  31. exit 1
  32. fi
  33. set -e
  34. fi
  35. }
  36. run_tests() {
  37. if [[ $QEMU_LD_PREFIX ]]; then
  38. export RUST_TEST_THREADS=1
  39. fi
  40. if [[ $RUN_TESTS == y ]]; then
  41. cargo test --target $TARGET
  42. cargo test --target $TARGET --release
  43. fi
  44. }
  45. main() {
  46. if [[ $LINUX && ${IN_DOCKER_CONTAINER:-n} == n ]]; then
  47. # NOTE The Dockerfile of this image is in the docker branch of this repository
  48. docker run \
  49. --privileged \
  50. -e IN_DOCKER_CONTAINER=y \
  51. -e TARGET=$TARGET \
  52. -e TRAVIS_BRANCH=$TRAVIS_BRANCH \
  53. -e TRAVIS_COMMIT=$TRAVIS_COMMIT \
  54. -e TRAVIS_OS_NAME=$TRAVIS_OS_NAME \
  55. -e WEAK=$WEAK \
  56. -v $(pwd):/mnt \
  57. japaric/rustc-builtins \
  58. sh -c 'cd /mnt;
  59. bash ci/install.sh;
  60. bash ci/script.sh'
  61. else
  62. build
  63. inspect
  64. run_tests
  65. fi
  66. }
  67. main