diff --git a/.gitmodules b/.gitmodules index 70164d48a307b..b9451e630f29d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,7 @@ [submodule "src/llvm"] path = src/llvm - url = https://github.com/rust-lang/llvm.git - branch = master + url = https://github.com/avr-rust/llvm.git + branch = avr-rust-2018-12-18 [submodule "src/rust-installer"] path = src/tools/rust-installer url = https://github.com/rust-lang/rust-installer.git diff --git a/.travis.yml b/.travis.yml index 9e46e6b8ef6b1..7249af7ac0328 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,328 +1,32 @@ -language: shell +language: generic sudo: required -dist: trusty services: - docker -addons: - apt: - packages: - - gdb +# LLVM takes awhile to check out and otherwise we'll manage the submodules in +# our configure script, so disable auto submodule management. git: - depth: 2 submodules: false + depth: 1 -matrix: - fast_finish: true - include: - # Images used in testing PR and try-build should be run first. - - env: IMAGE=x86_64-gnu-llvm-6.0 RUST_BACKTRACE=1 - if: type = pull_request OR branch = auto - - - env: IMAGE=dist-x86_64-linux DEPLOY=1 - if: branch = try OR branch = auto - - # "alternate" deployments, these are "nightlies" but have LLVM assertions - # turned on, they're deployed to a different location primarily for - # additional testing. - - env: IMAGE=dist-x86_64-linux DEPLOY_ALT=1 CI_JOB_NAME=dist-x86_64-linux-alt - if: branch = try OR branch = auto - - - env: > - RUST_CHECK_TARGET=dist - RUST_CONFIGURE_ARGS="--enable-extended --enable-profiler --enable-lldb --set rust.jemalloc" - SRC=. - DEPLOY_ALT=1 - RUSTC_RETRY_LINKER_ON_SEGFAULT=1 - MACOSX_DEPLOYMENT_TARGET=10.7 - NO_LLVM_ASSERTIONS=1 - NO_DEBUG_ASSERTIONS=1 - CI_JOB_NAME=dist-x86_64-apple-alt - os: osx - osx_image: xcode9.3-moar - if: branch = auto - - # macOS builders. These are placed near the beginning because they are very - # slow to run. - - # OSX builders running tests, these run the full test suite. - # NO_DEBUG_ASSERTIONS=1 to make them go faster, but also do have some - # runners that run `//ignore-debug` tests. - # - # Note that the compiler is compiled to target 10.8 here because the Xcode - # version that we're using, 8.2, cannot compile LLVM for OSX 10.7. - - env: > - RUST_CHECK_TARGET=check - RUST_CONFIGURE_ARGS="--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc" - SRC=. - RUSTC_RETRY_LINKER_ON_SEGFAULT=1 - MACOSX_DEPLOYMENT_TARGET=10.8 - MACOSX_STD_DEPLOYMENT_TARGET=10.7 - NO_LLVM_ASSERTIONS=1 - NO_DEBUG_ASSERTIONS=1 - CI_JOB_NAME=x86_64-apple - os: osx - osx_image: xcode9.3-moar - if: branch = auto - - - env: > - RUST_CHECK_TARGET=check - RUST_CONFIGURE_ARGS="--build=i686-apple-darwin --set rust.jemalloc" - SRC=. - RUSTC_RETRY_LINKER_ON_SEGFAULT=1 - MACOSX_DEPLOYMENT_TARGET=10.8 - MACOSX_STD_DEPLOYMENT_TARGET=10.7 - NO_LLVM_ASSERTIONS=1 - NO_DEBUG_ASSERTIONS=1 - CI_JOB_NAME=i686-apple - os: osx - osx_image: xcode9.3-moar - if: branch = auto - - # OSX builders producing releases. These do not run the full test suite and - # just produce a bunch of artifacts. - # - # Note that these are running in the `xcode7` image instead of the - # `xcode8.2` image as above. That's because we want to build releases for - # OSX 10.7 and `xcode7` is the latest Xcode able to compile LLVM for 10.7. - - env: > - RUST_CHECK_TARGET=dist - RUST_CONFIGURE_ARGS="--build=i686-apple-darwin --enable-full-tools --enable-profiler --enable-lldb --set rust.jemalloc" - SRC=. - DEPLOY=1 - RUSTC_RETRY_LINKER_ON_SEGFAULT=1 - MACOSX_DEPLOYMENT_TARGET=10.7 - NO_LLVM_ASSERTIONS=1 - NO_DEBUG_ASSERTIONS=1 - DIST_REQUIRE_ALL_TOOLS=1 - CI_JOB_NAME=dist-i686-apple - os: osx - osx_image: xcode9.3-moar - if: branch = auto - - - env: > - RUST_CHECK_TARGET=dist - RUST_CONFIGURE_ARGS="--target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --enable-lldb --set rust.jemalloc" - SRC=. - DEPLOY=1 - RUSTC_RETRY_LINKER_ON_SEGFAULT=1 - MACOSX_DEPLOYMENT_TARGET=10.7 - NO_LLVM_ASSERTIONS=1 - NO_DEBUG_ASSERTIONS=1 - DIST_REQUIRE_ALL_TOOLS=1 - CI_JOB_NAME=dist-x86_64-apple - os: osx - osx_image: xcode9.3-moar - if: branch = auto - - # Linux builders, remaining docker images - - env: IMAGE=arm-android - if: branch = auto - - env: IMAGE=armhf-gnu - if: branch = auto - - env: IMAGE=dist-various-1 DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-various-2 DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-aarch64-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-android DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-arm-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-armhf-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-armv7-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-i586-gnu-i586-i686-musl DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-i686-freebsd DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-i686-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-mips-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-mips64-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-mips64el-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-mipsel-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-powerpc-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-powerpc64-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-powerpc64le-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-s390x-linux DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-x86_64-freebsd DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-x86_64-musl DEPLOY=1 - if: branch = auto - - env: IMAGE=dist-x86_64-netbsd DEPLOY=1 - if: branch = auto - - env: IMAGE=asmjs - if: branch = auto - - env: IMAGE=i686-gnu - if: branch = auto - - env: IMAGE=i686-gnu-nopt - if: branch = auto - - env: IMAGE=wasm32-unknown - if: branch = auto - - env: IMAGE=x86_64-gnu - if: branch = auto - - env: IMAGE=x86_64-gnu-full-bootstrap - if: branch = auto - - env: IMAGE=x86_64-gnu-aux - if: branch = auto - - env: IMAGE=x86_64-gnu-tools - if: branch = auto OR (type = pull_request AND commit_message =~ /(?i:^update.*\b(rls|rustfmt|clippy|miri|cargo)\b)/) - - env: IMAGE=x86_64-gnu-debug - if: branch = auto - - env: IMAGE=x86_64-gnu-nopt - if: branch = auto - - env: IMAGE=x86_64-gnu-distcheck - if: branch = auto - - env: IMAGE=mingw-check - if: type = pull_request OR branch = auto - - - stage: publish toolstate - if: branch = master AND type = push - before_install: [] - install: [] - sudo: false - script: - MESSAGE_FILE=$(mktemp -t msg.XXXXXX); - . src/ci/docker/x86_64-gnu-tools/repo.sh; - commit_toolstate_change "$MESSAGE_FILE" "$TRAVIS_BUILD_DIR/src/tools/publish_toolstate.py" "$(git rev-parse HEAD)" "$(git log --format=%s -n1 HEAD)" "$MESSAGE_FILE" "$TOOLSTATE_REPO_ACCESS_TOKEN"; +env: + - CXX=/usr/bin/g++-4.7 RUST_BACKTRACE=1 before_install: - # We'll use the AWS cli to download/upload cached docker layers as well as - # push our deployments, so download that here. - - pip install --user awscli; export PATH=$PATH:$HOME/.local/bin:$HOME/Library/Python/2.7/bin/ - - mkdir -p $HOME/rustsrc - # FIXME(#46924): these two commands are required to enable IPv6, - # they shouldn't exist, please revert once more official solutions appeared. - # see https://github.com/travis-ci/travis-ci/issues/8891#issuecomment-353403729 - - if [ "$TRAVIS_OS_NAME" = linux ]; then - echo '{"ipv6":true,"fixed-cidr-v6":"fd9a:8454:6789:13f7::/64"}' | sudo tee /etc/docker/daemon.json; - sudo service docker restart; - fi + - docker build -t rust -f src/etc/Dockerfile src/etc -install: - - case "$TRAVIS_OS_NAME" in - linux) - travis_retry curl -fo $HOME/stamp https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-17-stamp-x86_64-unknown-linux-musl && - chmod +x $HOME/stamp && - export PATH=$PATH:$HOME - ;; - osx) - if [[ "$RUST_CHECK_TARGET" == dist ]]; then - travis_retry brew update && - travis_retry brew install xz && - travis_retry brew install swig; - fi && - travis_retry curl -fo /usr/local/bin/sccache https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2018-04-02-sccache-x86_64-apple-darwin && - chmod +x /usr/local/bin/sccache && - travis_retry curl -fo /usr/local/bin/stamp https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin && - chmod +x /usr/local/bin/stamp && - travis_retry curl -f http://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-apple-darwin.tar.xz | tar xJf - && - export CC=`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/bin/clang && - export CXX=`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/bin/clang++ && - export AR=ar - ;; - esac - -before_script: - - > - echo "#### Disk usage before running script:"; - df -h; - du . | sort -nr | head -n100 - - > - RUN_SCRIPT="src/ci/init_repo.sh . $HOME/rustsrc"; - if [ "$TRAVIS_OS_NAME" = "osx" ]; then - export RUN_SCRIPT="$RUN_SCRIPT && src/ci/run.sh"; - else - export RUN_SCRIPT="$RUN_SCRIPT && src/ci/docker/run.sh $IMAGE"; - # Enable core dump on Linux. - sudo sh -c 'echo "/checkout/obj/cores/core.%p.%E" > /proc/sys/kernel/core_pattern'; - fi - -# Log time information from this machine and an external machine for insight into possible -# clock drift. Timezones don't matter since relative deltas give all the necessary info. script: - - > - date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true) - - stamp sh -x -c "$RUN_SCRIPT" - - > - date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true) - -after_success: - - > - echo "#### Build successful; Disk usage after running script:"; - df -h; - du . | sort -nr | head -n100 - - > - if [ "$DEPLOY$DEPLOY_ALT" == "1" ]; then - mkdir -p deploy/$TRAVIS_COMMIT; - if [ "$TRAVIS_OS_NAME" == "osx" ]; then - rm -rf build/dist/doc && - cp -r build/dist/* deploy/$TRAVIS_COMMIT; - else - rm -rf obj/build/dist/doc && - cp -r obj/build/dist/* deploy/$TRAVIS_COMMIT; - fi; - ls -la deploy/$TRAVIS_COMMIT; - deploy_dir=rustc-builds; - if [ "$DEPLOY_ALT" == "1" ]; then - deploy_dir=rustc-builds-alt; - fi; - travis_retry aws s3 cp --no-progress --recursive --acl public-read ./deploy s3://rust-lang-ci2/$deploy_dir - fi - -after_failure: - - > - echo "#### Build failed; Disk usage after running script:"; - df -h; - du . | sort -nr | head -n100 - - # Random attempt at debugging currently. Just poking around in here to see if - # anything shows up. - - # Dump backtrace for macOS - - ls -lat $HOME/Library/Logs/DiagnosticReports/ - - find $HOME/Library/Logs/DiagnosticReports - -type f - -name '*.crash' - -not -name '*.stage2-*.crash' - -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' - -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; - -exec head -750 {} \; - -exec echo travis_fold":"end:crashlog \; || true - - # Dump backtrace for Linux - - ln -s . checkout && - for CORE in obj/cores/core.*; do - EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); - if [ -f "$EXE" ]; then - printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; - gdb --batch -q -c "$CORE" "$EXE" - -iex 'set auto-load off' - -iex 'dir src/' - -iex 'set sysroot .' - -ex bt - -ex q; - echo travis_fold":"end:crashlog; - fi; - done || true - - # see #50887 - - cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true - - # attempt to debug anything killed by the oom killer on linux, just to see if - # it happened - - dmesg | grep -i kill + - docker run -v `pwd`:/build rust + sh -c " + ./configure --enable-rustbuild --llvm-root=/usr/lib/llvm-3.7 --enable-quiet-tests && + make tidy && + make check -j4 + " + +# Real testing happens on http://buildbot.rust-lang.org/ +# +# See https://github.com/rust-lang/rust-buildbot +# CONTRIBUTING.md#pull-requests notifications: email: false diff --git a/.travis_rust.yml b/.travis_rust.yml new file mode 100644 index 0000000000000..9e46e6b8ef6b1 --- /dev/null +++ b/.travis_rust.yml @@ -0,0 +1,328 @@ +language: shell +sudo: required +dist: trusty +services: + - docker +addons: + apt: + packages: + - gdb + +git: + depth: 2 + submodules: false + +matrix: + fast_finish: true + include: + # Images used in testing PR and try-build should be run first. + - env: IMAGE=x86_64-gnu-llvm-6.0 RUST_BACKTRACE=1 + if: type = pull_request OR branch = auto + + - env: IMAGE=dist-x86_64-linux DEPLOY=1 + if: branch = try OR branch = auto + + # "alternate" deployments, these are "nightlies" but have LLVM assertions + # turned on, they're deployed to a different location primarily for + # additional testing. + - env: IMAGE=dist-x86_64-linux DEPLOY_ALT=1 CI_JOB_NAME=dist-x86_64-linux-alt + if: branch = try OR branch = auto + + - env: > + RUST_CHECK_TARGET=dist + RUST_CONFIGURE_ARGS="--enable-extended --enable-profiler --enable-lldb --set rust.jemalloc" + SRC=. + DEPLOY_ALT=1 + RUSTC_RETRY_LINKER_ON_SEGFAULT=1 + MACOSX_DEPLOYMENT_TARGET=10.7 + NO_LLVM_ASSERTIONS=1 + NO_DEBUG_ASSERTIONS=1 + CI_JOB_NAME=dist-x86_64-apple-alt + os: osx + osx_image: xcode9.3-moar + if: branch = auto + + # macOS builders. These are placed near the beginning because they are very + # slow to run. + + # OSX builders running tests, these run the full test suite. + # NO_DEBUG_ASSERTIONS=1 to make them go faster, but also do have some + # runners that run `//ignore-debug` tests. + # + # Note that the compiler is compiled to target 10.8 here because the Xcode + # version that we're using, 8.2, cannot compile LLVM for OSX 10.7. + - env: > + RUST_CHECK_TARGET=check + RUST_CONFIGURE_ARGS="--build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc" + SRC=. + RUSTC_RETRY_LINKER_ON_SEGFAULT=1 + MACOSX_DEPLOYMENT_TARGET=10.8 + MACOSX_STD_DEPLOYMENT_TARGET=10.7 + NO_LLVM_ASSERTIONS=1 + NO_DEBUG_ASSERTIONS=1 + CI_JOB_NAME=x86_64-apple + os: osx + osx_image: xcode9.3-moar + if: branch = auto + + - env: > + RUST_CHECK_TARGET=check + RUST_CONFIGURE_ARGS="--build=i686-apple-darwin --set rust.jemalloc" + SRC=. + RUSTC_RETRY_LINKER_ON_SEGFAULT=1 + MACOSX_DEPLOYMENT_TARGET=10.8 + MACOSX_STD_DEPLOYMENT_TARGET=10.7 + NO_LLVM_ASSERTIONS=1 + NO_DEBUG_ASSERTIONS=1 + CI_JOB_NAME=i686-apple + os: osx + osx_image: xcode9.3-moar + if: branch = auto + + # OSX builders producing releases. These do not run the full test suite and + # just produce a bunch of artifacts. + # + # Note that these are running in the `xcode7` image instead of the + # `xcode8.2` image as above. That's because we want to build releases for + # OSX 10.7 and `xcode7` is the latest Xcode able to compile LLVM for 10.7. + - env: > + RUST_CHECK_TARGET=dist + RUST_CONFIGURE_ARGS="--build=i686-apple-darwin --enable-full-tools --enable-profiler --enable-lldb --set rust.jemalloc" + SRC=. + DEPLOY=1 + RUSTC_RETRY_LINKER_ON_SEGFAULT=1 + MACOSX_DEPLOYMENT_TARGET=10.7 + NO_LLVM_ASSERTIONS=1 + NO_DEBUG_ASSERTIONS=1 + DIST_REQUIRE_ALL_TOOLS=1 + CI_JOB_NAME=dist-i686-apple + os: osx + osx_image: xcode9.3-moar + if: branch = auto + + - env: > + RUST_CHECK_TARGET=dist + RUST_CONFIGURE_ARGS="--target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --enable-lldb --set rust.jemalloc" + SRC=. + DEPLOY=1 + RUSTC_RETRY_LINKER_ON_SEGFAULT=1 + MACOSX_DEPLOYMENT_TARGET=10.7 + NO_LLVM_ASSERTIONS=1 + NO_DEBUG_ASSERTIONS=1 + DIST_REQUIRE_ALL_TOOLS=1 + CI_JOB_NAME=dist-x86_64-apple + os: osx + osx_image: xcode9.3-moar + if: branch = auto + + # Linux builders, remaining docker images + - env: IMAGE=arm-android + if: branch = auto + - env: IMAGE=armhf-gnu + if: branch = auto + - env: IMAGE=dist-various-1 DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-various-2 DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-aarch64-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-android DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-arm-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-armhf-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-armv7-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-i586-gnu-i586-i686-musl DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-i686-freebsd DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-i686-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-mips-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-mips64-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-mips64el-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-mipsel-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-powerpc-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-powerpc64-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-powerpc64le-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-s390x-linux DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-x86_64-freebsd DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-x86_64-musl DEPLOY=1 + if: branch = auto + - env: IMAGE=dist-x86_64-netbsd DEPLOY=1 + if: branch = auto + - env: IMAGE=asmjs + if: branch = auto + - env: IMAGE=i686-gnu + if: branch = auto + - env: IMAGE=i686-gnu-nopt + if: branch = auto + - env: IMAGE=wasm32-unknown + if: branch = auto + - env: IMAGE=x86_64-gnu + if: branch = auto + - env: IMAGE=x86_64-gnu-full-bootstrap + if: branch = auto + - env: IMAGE=x86_64-gnu-aux + if: branch = auto + - env: IMAGE=x86_64-gnu-tools + if: branch = auto OR (type = pull_request AND commit_message =~ /(?i:^update.*\b(rls|rustfmt|clippy|miri|cargo)\b)/) + - env: IMAGE=x86_64-gnu-debug + if: branch = auto + - env: IMAGE=x86_64-gnu-nopt + if: branch = auto + - env: IMAGE=x86_64-gnu-distcheck + if: branch = auto + - env: IMAGE=mingw-check + if: type = pull_request OR branch = auto + + - stage: publish toolstate + if: branch = master AND type = push + before_install: [] + install: [] + sudo: false + script: + MESSAGE_FILE=$(mktemp -t msg.XXXXXX); + . src/ci/docker/x86_64-gnu-tools/repo.sh; + commit_toolstate_change "$MESSAGE_FILE" "$TRAVIS_BUILD_DIR/src/tools/publish_toolstate.py" "$(git rev-parse HEAD)" "$(git log --format=%s -n1 HEAD)" "$MESSAGE_FILE" "$TOOLSTATE_REPO_ACCESS_TOKEN"; + +before_install: + # We'll use the AWS cli to download/upload cached docker layers as well as + # push our deployments, so download that here. + - pip install --user awscli; export PATH=$PATH:$HOME/.local/bin:$HOME/Library/Python/2.7/bin/ + - mkdir -p $HOME/rustsrc + # FIXME(#46924): these two commands are required to enable IPv6, + # they shouldn't exist, please revert once more official solutions appeared. + # see https://github.com/travis-ci/travis-ci/issues/8891#issuecomment-353403729 + - if [ "$TRAVIS_OS_NAME" = linux ]; then + echo '{"ipv6":true,"fixed-cidr-v6":"fd9a:8454:6789:13f7::/64"}' | sudo tee /etc/docker/daemon.json; + sudo service docker restart; + fi + +install: + - case "$TRAVIS_OS_NAME" in + linux) + travis_retry curl -fo $HOME/stamp https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-17-stamp-x86_64-unknown-linux-musl && + chmod +x $HOME/stamp && + export PATH=$PATH:$HOME + ;; + osx) + if [[ "$RUST_CHECK_TARGET" == dist ]]; then + travis_retry brew update && + travis_retry brew install xz && + travis_retry brew install swig; + fi && + travis_retry curl -fo /usr/local/bin/sccache https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2018-04-02-sccache-x86_64-apple-darwin && + chmod +x /usr/local/bin/sccache && + travis_retry curl -fo /usr/local/bin/stamp https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin && + chmod +x /usr/local/bin/stamp && + travis_retry curl -f http://releases.llvm.org/7.0.0/clang+llvm-7.0.0-x86_64-apple-darwin.tar.xz | tar xJf - && + export CC=`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/bin/clang && + export CXX=`pwd`/clang+llvm-7.0.0-x86_64-apple-darwin/bin/clang++ && + export AR=ar + ;; + esac + +before_script: + - > + echo "#### Disk usage before running script:"; + df -h; + du . | sort -nr | head -n100 + - > + RUN_SCRIPT="src/ci/init_repo.sh . $HOME/rustsrc"; + if [ "$TRAVIS_OS_NAME" = "osx" ]; then + export RUN_SCRIPT="$RUN_SCRIPT && src/ci/run.sh"; + else + export RUN_SCRIPT="$RUN_SCRIPT && src/ci/docker/run.sh $IMAGE"; + # Enable core dump on Linux. + sudo sh -c 'echo "/checkout/obj/cores/core.%p.%E" > /proc/sys/kernel/core_pattern'; + fi + +# Log time information from this machine and an external machine for insight into possible +# clock drift. Timezones don't matter since relative deltas give all the necessary info. +script: + - > + date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true) + - stamp sh -x -c "$RUN_SCRIPT" + - > + date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true) + +after_success: + - > + echo "#### Build successful; Disk usage after running script:"; + df -h; + du . | sort -nr | head -n100 + - > + if [ "$DEPLOY$DEPLOY_ALT" == "1" ]; then + mkdir -p deploy/$TRAVIS_COMMIT; + if [ "$TRAVIS_OS_NAME" == "osx" ]; then + rm -rf build/dist/doc && + cp -r build/dist/* deploy/$TRAVIS_COMMIT; + else + rm -rf obj/build/dist/doc && + cp -r obj/build/dist/* deploy/$TRAVIS_COMMIT; + fi; + ls -la deploy/$TRAVIS_COMMIT; + deploy_dir=rustc-builds; + if [ "$DEPLOY_ALT" == "1" ]; then + deploy_dir=rustc-builds-alt; + fi; + travis_retry aws s3 cp --no-progress --recursive --acl public-read ./deploy s3://rust-lang-ci2/$deploy_dir + fi + +after_failure: + - > + echo "#### Build failed; Disk usage after running script:"; + df -h; + du . | sort -nr | head -n100 + + # Random attempt at debugging currently. Just poking around in here to see if + # anything shows up. + + # Dump backtrace for macOS + - ls -lat $HOME/Library/Logs/DiagnosticReports/ + - find $HOME/Library/Logs/DiagnosticReports + -type f + -name '*.crash' + -not -name '*.stage2-*.crash' + -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' + -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; + -exec head -750 {} \; + -exec echo travis_fold":"end:crashlog \; || true + + # Dump backtrace for Linux + - ln -s . checkout && + for CORE in obj/cores/core.*; do + EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); + if [ -f "$EXE" ]; then + printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; + gdb --batch -q -c "$CORE" "$EXE" + -iex 'set auto-load off' + -iex 'dir src/' + -iex 'set sysroot .' + -ex bt + -ex q; + echo travis_fold":"end:crashlog; + fi; + done || true + + # see #50887 + - cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true + + # attempt to debug anything killed by the oom killer on linux, just to see if + # it happened + - dmesg | grep -i kill + +notifications: + email: false diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000000..ab3e292f1e8c5 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,14 @@ +node('master') { + stage('Checkout') { + checkout scm + sh 'git submodule update --init --recursive' + } + + stage('Build') { + dir('build') { + sh '../x.py build' + } + } +} + + diff --git a/README.md b/README.md index dc013a1ad2be6..327af708dc040 100644 --- a/README.md +++ b/README.md @@ -1,247 +1,70 @@ -# The Rust Programming Language +# Rust with AVR support -This is the main source code repository for [Rust]. It contains the compiler, -standard library, and documentation. +[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/avr-rust) -[Rust]: https://www.rust-lang.org +This project adds support for the [AVR](https://en.wikipedia.org/wiki/Atmel_AVR) +microcontroller to Rust. -## Quick Start -[quick-start]: #quick-start +It uses the [AVR-LLVM backend](http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AVR/). -Read ["Installation"] from [The Book]. +## Caveats -["Installation"]: https://doc.rust-lang.org/book/ch01-01-installation.html -[The Book]: https://doc.rust-lang.org/book/index.html +While the stock libcore may be compiled, certain code patterns may +still exercise code in LLVM that is broken or that produces +miscompiled code. Looking for existing issues or submitting a new +issue is appreciated! -## Building from Source -[building-from-source]: #building-from-source +## Building and installation -### Building on *nix -1. Make sure you have installed the dependencies: +This will compile Rust with AVR support. This will not create a +fully-fledged cross-compiler, however, as it does not compile any libraries +such as `libcore` or `liblibc`. To do this, the `--target=avr-unknown-unknown` +flag must be passed to `configure`, which is not fully supported yet due to bugs. - * `g++` 4.7 or later or `clang++` 3.x or later - * `python` 2.7 (but not 3.x) - * GNU `make` 3.81 or later - * `cmake` 3.4.3 or later - * `curl` - * `git` +First make sure you've installed all dependencies for building, as specified in +the main Rust repository [here](https://github.com/rust-lang/rust/#building-from-source). +Then use the following commands: -2. Clone the [source] with `git`: +``` bash +# Grab the avr-rust sources +git clone https://github.com/avr-rust/rust.git - ```sh - $ git clone https://github.com/rust-lang/rust.git - $ cd rust - ``` +# Create a directory to place built files in +mkdir build && cd build -[source]: https://github.com/rust-lang/rust +# Generate Makefile using settings suitable for an experimental compiler +../rust/configure \ + --enable-debug \ + --disable-docs \ + --enable-llvm-assertions \ + --enable-debug-assertions \ + --enable-optimize \ + --enable-llvm-release-debuginfo \ + --experimental-targets=AVR \ + --prefix=/opt/avr-rust -3. Build and install: +# Build the compiler, optionally install it to /opt/avr-rust +make +make install - ```sh - $ git submodule update --init --recursive --progress - $ ./x.py build && sudo ./x.py install - ``` +# Register the toolchain with rustup +rustup toolchain link avr-toolchain $(realpath $(find . -name 'stage1')) - > ***Note:*** Install locations can be adjusted by copying the config file - > from `./config.toml.example` to `./config.toml`, and - > adjusting the `prefix` option under `[install]`. Various other options, such - > as enabling debug information, are also supported, and are documented in - > the config file. - - When complete, `sudo ./x.py install` will place several programs into - `/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the - API-documentation tool. This install does not include [Cargo], - Rust's package manager, which you may also want to build. - -[Cargo]: https://github.com/rust-lang/cargo - -### Building on Windows -[building-on-windows]: #building-on-windows - -There are two prominent ABIs in use on Windows: the native (MSVC) ABI used by -Visual Studio, and the GNU ABI used by the GCC toolchain. Which version of Rust -you need depends largely on what C/C++ libraries you want to interoperate with: -for interop with software produced by Visual Studio use the MSVC build of Rust; -for interop with GNU software built using the MinGW/MSYS2 toolchain use the GNU -build. - -#### MinGW -[windows-mingw]: #windows-mingw - -[MSYS2][msys2] can be used to easily build Rust on Windows: - -[msys2]: https://msys2.github.io/ - -1. Grab the latest [MSYS2 installer][msys2] and go through the installer. - -2. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed - MSYS2 (i.e. `C:\msys64`), depending on whether you want 32-bit or 64-bit - Rust. (As of the latest version of MSYS2 you have to run `msys2_shell.cmd - -mingw32` or `msys2_shell.cmd -mingw64` from the command line instead) - -3. From this terminal, install the required tools: - - ```sh - # Update package mirrors (may be needed if you have a fresh install of MSYS2) - $ pacman -Sy pacman-mirrors - - # Install build tools needed for Rust. If you're building a 32-bit compiler, - # then replace "x86_64" below with "i686". If you've already got git, python, - # or CMake installed and in PATH you can remove them from this list. Note - # that it is important that you do **not** use the 'python2' and 'cmake' - # packages from the 'msys2' subsystem. The build has historically been known - # to fail with these packages. - $ pacman -S git \ - make \ - diffutils \ - tar \ - mingw-w64-x86_64-python2 \ - mingw-w64-x86_64-cmake \ - mingw-w64-x86_64-gcc - ``` - -4. Navigate to Rust's source code (or clone it), then build it: - - ```sh - $ ./x.py build && ./x.py install - ``` - -#### MSVC -[windows-msvc]: #windows-msvc - -MSVC builds of Rust additionally require an installation of Visual Studio 2013 -(or later) so `rustc` can use its linker. Make sure to check the “C++ tools” -option. - -With these dependencies installed, you can build the compiler in a `cmd.exe` -shell with: - -```sh -> python x.py build -``` - -Currently, building Rust only works with some known versions of Visual Studio. If -you have a more recent version installed the build system doesn't understand -then you may need to force rustbuild to use an older version. This can be done -by manually calling the appropriate vcvars file before running the bootstrap. - -```batch -> CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat" -> python x.py build -``` - -#### Specifying an ABI -[specifying-an-abi]: #specifying-an-abi - -Each specific ABI can also be used from either environment (for example, using -the GNU ABI in PowerShell) by using an explicit build triple. The available -Windows build triples are: -- GNU ABI (using GCC) - - `i686-pc-windows-gnu` - - `x86_64-pc-windows-gnu` -- The MSVC ABI - - `i686-pc-windows-msvc` - - `x86_64-pc-windows-msvc` - -The build triple can be specified by either specifying `--build=` when -invoking `x.py` commands, or by copying the `config.toml` file (as described -in Building From Source), and modifying the `build` option under the `[build]` -section. - -### Configure and Make -[configure-and-make]: #configure-and-make - -While it's not the recommended build system, this project also provides a -configure script and makefile (the latter of which just invokes `x.py`). - -```sh -$ ./configure -$ make && sudo make install -``` - -When using the configure script, the generated `config.mk` file may override the -`config.toml` file. To go back to the `config.toml` file, delete the generated -`config.mk` file. - -## Building Documentation -[building-documentation]: #building-documentation - -If you’d like to build the documentation, it’s almost the same: - -```sh -$ ./x.py doc +# Optionally enable the avr toolchain globally +rustup default avr-toolchain ``` -The generated documentation will appear under `doc` in the `build` directory for -the ABI used. I.e., if the ABI was `x86_64-pc-windows-msvc`, the directory will be -`build\x86_64-pc-windows-msvc\doc`. - -## Notes -[notes]: #notes - -Since the Rust compiler is written in Rust, it must be built by a -precompiled "snapshot" version of itself (made in an earlier stage of -development). As such, source builds require a connection to the Internet, to -fetch snapshots, and an OS that can execute the available snapshot binaries. - -Snapshot binaries are currently built and tested on several platforms: - -| Platform / Architecture | x86 | x86_64 | -|--------------------------------|-----|--------| -| Windows (7, 8, Server 2008 R2) | ✓ | ✓ | -| Linux (2.6.18 or later) | ✓ | ✓ | -| OSX (10.7 Lion or later) | ✓ | ✓ | - -You may find that other platforms work, but these are our officially -supported build environments that are most likely to work. - -Rust currently needs between 600MiB and 1.5GiB of RAM to build, depending on platform. -If it hits swap, it will take a very long time to build. - -There is more advice about hacking on Rust in [CONTRIBUTING.md]. - -[CONTRIBUTING.md]: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md - -## Getting Help -[getting-help]: #getting-help - -The Rust community congregates in a few places: - -* [Stack Overflow] - Direct questions about using the language. -* [users.rust-lang.org] - General discussion and broader questions. -* [/r/rust] - News and general discussion. - -[Stack Overflow]: https://stackoverflow.com/questions/tagged/rust -[/r/rust]: https://reddit.com/r/rust -[users.rust-lang.org]: https://users.rust-lang.org/ - -## Contributing -[contributing]: #contributing - -To contribute to Rust, please see [CONTRIBUTING](CONTRIBUTING.md). - -Rust has an [IRC] culture and most real-time collaboration happens in a -variety of channels on Mozilla's IRC network, irc.mozilla.org. The -most popular channel is [#rust], a venue for general discussion about -Rust. And a good place to ask for help would be [#rust-beginners]. - -The [rustc guide] might be a good place to start if you want to find out how -various parts of the compiler work. +## Usage -Also, you may find the [rustdocs for the compiler itself][rustdocs] useful. +# With Xargo (recommended) -[IRC]: https://en.wikipedia.org/wiki/Internet_Relay_Chat -[#rust]: irc://irc.mozilla.org/rust -[#rust-beginners]: irc://irc.mozilla.org/rust-beginners -[rustc guide]: https://rust-lang.github.io/rustc-guide/about-this-guide.html -[rustdocs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ +Take a look at the example [blink](https://github.com/avr-rust/blink) program. -## License -[license]: #license +# Vanilla `rustc` -Rust is primarily distributed under the terms of both the MIT license -and the Apache License (Version 2.0), with portions covered by various -BSD-like licenses. +AVR support is enabled by passing the `--target avr-unknown-unknown` flag to `rustc`. -See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and -[COPYRIGHT](COPYRIGHT) for details. +Note that the Rust `libcore` library (essentially required for every Rust program), +must be manually compiled for it to be used, as it will not be built for AVR during +compiler compilation (yet). Work is currently being done in order to allow `libcore` +to be automatically compiled for AVR. diff --git a/RUST_README.md b/RUST_README.md new file mode 100644 index 0000000000000..dc013a1ad2be6 --- /dev/null +++ b/RUST_README.md @@ -0,0 +1,247 @@ +# The Rust Programming Language + +This is the main source code repository for [Rust]. It contains the compiler, +standard library, and documentation. + +[Rust]: https://www.rust-lang.org + +## Quick Start +[quick-start]: #quick-start + +Read ["Installation"] from [The Book]. + +["Installation"]: https://doc.rust-lang.org/book/ch01-01-installation.html +[The Book]: https://doc.rust-lang.org/book/index.html + +## Building from Source +[building-from-source]: #building-from-source + +### Building on *nix +1. Make sure you have installed the dependencies: + + * `g++` 4.7 or later or `clang++` 3.x or later + * `python` 2.7 (but not 3.x) + * GNU `make` 3.81 or later + * `cmake` 3.4.3 or later + * `curl` + * `git` + +2. Clone the [source] with `git`: + + ```sh + $ git clone https://github.com/rust-lang/rust.git + $ cd rust + ``` + +[source]: https://github.com/rust-lang/rust + +3. Build and install: + + ```sh + $ git submodule update --init --recursive --progress + $ ./x.py build && sudo ./x.py install + ``` + + > ***Note:*** Install locations can be adjusted by copying the config file + > from `./config.toml.example` to `./config.toml`, and + > adjusting the `prefix` option under `[install]`. Various other options, such + > as enabling debug information, are also supported, and are documented in + > the config file. + + When complete, `sudo ./x.py install` will place several programs into + `/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the + API-documentation tool. This install does not include [Cargo], + Rust's package manager, which you may also want to build. + +[Cargo]: https://github.com/rust-lang/cargo + +### Building on Windows +[building-on-windows]: #building-on-windows + +There are two prominent ABIs in use on Windows: the native (MSVC) ABI used by +Visual Studio, and the GNU ABI used by the GCC toolchain. Which version of Rust +you need depends largely on what C/C++ libraries you want to interoperate with: +for interop with software produced by Visual Studio use the MSVC build of Rust; +for interop with GNU software built using the MinGW/MSYS2 toolchain use the GNU +build. + +#### MinGW +[windows-mingw]: #windows-mingw + +[MSYS2][msys2] can be used to easily build Rust on Windows: + +[msys2]: https://msys2.github.io/ + +1. Grab the latest [MSYS2 installer][msys2] and go through the installer. + +2. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed + MSYS2 (i.e. `C:\msys64`), depending on whether you want 32-bit or 64-bit + Rust. (As of the latest version of MSYS2 you have to run `msys2_shell.cmd + -mingw32` or `msys2_shell.cmd -mingw64` from the command line instead) + +3. From this terminal, install the required tools: + + ```sh + # Update package mirrors (may be needed if you have a fresh install of MSYS2) + $ pacman -Sy pacman-mirrors + + # Install build tools needed for Rust. If you're building a 32-bit compiler, + # then replace "x86_64" below with "i686". If you've already got git, python, + # or CMake installed and in PATH you can remove them from this list. Note + # that it is important that you do **not** use the 'python2' and 'cmake' + # packages from the 'msys2' subsystem. The build has historically been known + # to fail with these packages. + $ pacman -S git \ + make \ + diffutils \ + tar \ + mingw-w64-x86_64-python2 \ + mingw-w64-x86_64-cmake \ + mingw-w64-x86_64-gcc + ``` + +4. Navigate to Rust's source code (or clone it), then build it: + + ```sh + $ ./x.py build && ./x.py install + ``` + +#### MSVC +[windows-msvc]: #windows-msvc + +MSVC builds of Rust additionally require an installation of Visual Studio 2013 +(or later) so `rustc` can use its linker. Make sure to check the “C++ tools” +option. + +With these dependencies installed, you can build the compiler in a `cmd.exe` +shell with: + +```sh +> python x.py build +``` + +Currently, building Rust only works with some known versions of Visual Studio. If +you have a more recent version installed the build system doesn't understand +then you may need to force rustbuild to use an older version. This can be done +by manually calling the appropriate vcvars file before running the bootstrap. + +```batch +> CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat" +> python x.py build +``` + +#### Specifying an ABI +[specifying-an-abi]: #specifying-an-abi + +Each specific ABI can also be used from either environment (for example, using +the GNU ABI in PowerShell) by using an explicit build triple. The available +Windows build triples are: +- GNU ABI (using GCC) + - `i686-pc-windows-gnu` + - `x86_64-pc-windows-gnu` +- The MSVC ABI + - `i686-pc-windows-msvc` + - `x86_64-pc-windows-msvc` + +The build triple can be specified by either specifying `--build=` when +invoking `x.py` commands, or by copying the `config.toml` file (as described +in Building From Source), and modifying the `build` option under the `[build]` +section. + +### Configure and Make +[configure-and-make]: #configure-and-make + +While it's not the recommended build system, this project also provides a +configure script and makefile (the latter of which just invokes `x.py`). + +```sh +$ ./configure +$ make && sudo make install +``` + +When using the configure script, the generated `config.mk` file may override the +`config.toml` file. To go back to the `config.toml` file, delete the generated +`config.mk` file. + +## Building Documentation +[building-documentation]: #building-documentation + +If you’d like to build the documentation, it’s almost the same: + +```sh +$ ./x.py doc +``` + +The generated documentation will appear under `doc` in the `build` directory for +the ABI used. I.e., if the ABI was `x86_64-pc-windows-msvc`, the directory will be +`build\x86_64-pc-windows-msvc\doc`. + +## Notes +[notes]: #notes + +Since the Rust compiler is written in Rust, it must be built by a +precompiled "snapshot" version of itself (made in an earlier stage of +development). As such, source builds require a connection to the Internet, to +fetch snapshots, and an OS that can execute the available snapshot binaries. + +Snapshot binaries are currently built and tested on several platforms: + +| Platform / Architecture | x86 | x86_64 | +|--------------------------------|-----|--------| +| Windows (7, 8, Server 2008 R2) | ✓ | ✓ | +| Linux (2.6.18 or later) | ✓ | ✓ | +| OSX (10.7 Lion or later) | ✓ | ✓ | + +You may find that other platforms work, but these are our officially +supported build environments that are most likely to work. + +Rust currently needs between 600MiB and 1.5GiB of RAM to build, depending on platform. +If it hits swap, it will take a very long time to build. + +There is more advice about hacking on Rust in [CONTRIBUTING.md]. + +[CONTRIBUTING.md]: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md + +## Getting Help +[getting-help]: #getting-help + +The Rust community congregates in a few places: + +* [Stack Overflow] - Direct questions about using the language. +* [users.rust-lang.org] - General discussion and broader questions. +* [/r/rust] - News and general discussion. + +[Stack Overflow]: https://stackoverflow.com/questions/tagged/rust +[/r/rust]: https://reddit.com/r/rust +[users.rust-lang.org]: https://users.rust-lang.org/ + +## Contributing +[contributing]: #contributing + +To contribute to Rust, please see [CONTRIBUTING](CONTRIBUTING.md). + +Rust has an [IRC] culture and most real-time collaboration happens in a +variety of channels on Mozilla's IRC network, irc.mozilla.org. The +most popular channel is [#rust], a venue for general discussion about +Rust. And a good place to ask for help would be [#rust-beginners]. + +The [rustc guide] might be a good place to start if you want to find out how +various parts of the compiler work. + +Also, you may find the [rustdocs for the compiler itself][rustdocs] useful. + +[IRC]: https://en.wikipedia.org/wiki/Internet_Relay_Chat +[#rust]: irc://irc.mozilla.org/rust +[#rust-beginners]: irc://irc.mozilla.org/rust-beginners +[rustc guide]: https://rust-lang.github.io/rustc-guide/about-this-guide.html +[rustdocs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ + +## License +[license]: #license + +Rust is primarily distributed under the terms of both the MIT license +and the Apache License (Version 2.0), with portions covered by various +BSD-like licenses. + +See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and +[COPYRIGHT](COPYRIGHT) for details. diff --git a/config.toml.example b/config.toml.example index f75e220de47e7..14406522a791e 100644 --- a/config.toml.example +++ b/config.toml.example @@ -68,7 +68,7 @@ # not built by default and the experimental Rust compilation targets that depend # on them will not work unless the user opts in to building them. By default the # `WebAssembly` and `RISCV` targets are enabled when compiling LLVM from scratch. -#experimental-targets = "WebAssembly;RISCV" +#experimental-targets = "AVR;WebAssembly;RISCV" # Cap the number of parallel linker invocations when compiling LLVM. # This can be useful when building LLVM with debug info, which significantly diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 2ae9da9c085d4..ba4020c419d87 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -519,7 +519,7 @@ impl Config { set(&mut config.llvm_link_shared, llvm.link_shared); config.llvm_targets = llvm.targets.clone(); config.llvm_experimental_targets = llvm.experimental_targets.clone() - .unwrap_or_else(|| "WebAssembly;RISCV".to_string()); + .unwrap_or_else(|| "AVR;WebAssembly;RISCV".to_string()); config.llvm_link_jobs = llvm.link_jobs; config.llvm_version_suffix = llvm.version_suffix.clone(); config.llvm_clang_cl = llvm.clang_cl.clone(); diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index 3211937d3ddc7..01ce64d3b83d2 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -116,6 +116,8 @@ impl_stable_hash_for!(enum ::rustc_target::spec::abi::Abi { Msp430Interrupt, X86Interrupt, AmdGpuKernel, + AvrInterrupt, + AvrNonBlockingInterrupt, Rust, C, System, diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index b58d80e24857d..9da49c3f73500 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1397,6 +1397,7 @@ pub fn default_lib_output() -> CrateType { pub fn default_configuration(sess: &Session) -> ast::CrateConfig { let end = &sess.target.target.target_endian; let arch = &sess.target.target.arch; + let cpu = &sess.target.target.options.cpu; let wordsz = &sess.target.target.target_pointer_width; let os = &sess.target.target.target_os; let env = &sess.target.target.target_env; @@ -1426,6 +1427,10 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig { Symbol::intern("target_vendor"), Some(Symbol::intern(vendor)), )); + if sess.target.target.options.is_specific_cpu() { + ret.insert((Symbol::intern("target_cpu"), Some(Symbol::intern(cpu)))); + } + if sess.target.target.options.has_elf_tls { ret.insert((Symbol::intern("target_thread_local"), None)); } diff --git a/src/librustc_codegen_llvm/abi.rs b/src/librustc_codegen_llvm/abi.rs index b8954dee794f7..64b67b0d1a43c 100644 --- a/src/librustc_codegen_llvm/abi.rs +++ b/src/librustc_codegen_llvm/abi.rs @@ -425,6 +425,8 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> { Msp430Interrupt => Conv::Msp430Intr, X86Interrupt => Conv::X86Intr, AmdGpuKernel => Conv::AmdGpuKernel, + AvrInterrupt => Conv::AvrInterrupt, + AvrNonBlockingInterrupt => Conv::AvrNonBlockingInterrupt, // These API constants ought to be more specific... Cdecl => Conv::C, @@ -714,6 +716,8 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> { match self.conv { Conv::C => llvm::CCallConv, Conv::AmdGpuKernel => llvm::AmdGpuKernel, + Conv::AvrInterrupt => llvm::AvrInterrupt, + Conv::AvrNonBlockingInterrupt => llvm::AvrNonBlockingInterrupt, Conv::ArmAapcs => llvm::ArmAapcsCallConv, Conv::Msp430Intr => llvm::Msp430Intr, Conv::PtxKernel => llvm::PtxKernel, diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index 4732db88ec1cb..1826b636a1fdf 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -55,6 +55,8 @@ pub enum CallConv { X86_64_Win64 = 79, X86_VectorCall = 80, X86_Intr = 83, + AvrNonBlockingInterrupt = 84, + AvrInterrupt = 85, AmdGpuKernel = 91, } diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index ce482087bbae5..949aadd8b2a48 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -81,7 +81,7 @@ fn main() { let is_crossed = target != host; let mut optional_components = - vec!["x86", "arm", "aarch64", "amdgpu", "mips", "powerpc", + vec!["x86", "arm", "aarch64", "amdgpu", "avr", "mips", "powerpc", "systemz", "jsbackend", "webassembly", "msp430", "sparc", "nvptx"]; let mut version_cmd = Command::new(&llvm_config); diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 10f35e5598b2b..254bb551f286c 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -52,6 +52,12 @@ pub fn initialize_available_targets() { LLVMInitializeARMTargetMC, LLVMInitializeARMAsmPrinter, LLVMInitializeARMAsmParser); + init_target!(llvm_component = "avr", + LLVMInitializeAVRTargetInfo, + LLVMInitializeAVRTarget, + LLVMInitializeAVRTargetMC, + LLVMInitializeAVRAsmPrinter, + LLVMInitializeAVRAsmParser); init_target!(llvm_component = "aarch64", LLVMInitializeAArch64TargetInfo, LLVMInitializeAArch64Target, diff --git a/src/librustc_target/abi/call/avr.rs b/src/librustc_target/abi/call/avr.rs new file mode 100644 index 0000000000000..318495d93f2b1 --- /dev/null +++ b/src/librustc_target/abi/call/avr.rs @@ -0,0 +1,43 @@ +// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(non_upper_case_globals)] + +use abi::call::{FnType, ArgType}; + +fn classify_ret_ty(ret: &mut ArgType) { + if ret.layout.is_aggregate() { + ret.make_indirect(); + } else { + ret.extend_integer_width_to(8); // Is 8 correct? + } +} + +fn classify_arg_ty(arg: &mut ArgType) { + if arg.layout.is_aggregate() { + arg.make_indirect(); + } else { + arg.extend_integer_width_to(8); + } +} + +pub fn compute_abi_info(fty: &mut FnType) { + if !fty.ret.is_ignore() { + classify_ret_ty(&mut fty.ret); + } + + for arg in &mut fty.args { + if arg.is_ignore() { + continue; + } + + classify_arg_ty(arg); + } +} diff --git a/src/librustc_target/abi/call/mod.rs b/src/librustc_target/abi/call/mod.rs index 1c3763c6e37f4..b4bbfee8b6011 100644 --- a/src/librustc_target/abi/call/mod.rs +++ b/src/librustc_target/abi/call/mod.rs @@ -16,6 +16,7 @@ mod aarch64; mod amdgpu; mod arm; mod asmjs; +mod avr; mod hexagon; mod mips; mod mips64; @@ -462,6 +463,8 @@ pub enum Conv { X86_64Win64, AmdGpuKernel, + AvrInterrupt, + AvrNonBlockingInterrupt, } /// Metadata describing how the arguments to a native function @@ -519,6 +522,7 @@ impl<'a, Ty> FnType<'a, Ty> { wasm32::compute_abi_info(self) } } + "avr" => avr::compute_abi_info(self), "msp430" => msp430::compute_abi_info(self), "sparc" => sparc::compute_abi_info(cx, self), "sparc64" => sparc64::compute_abi_info(cx, self), diff --git a/src/librustc_target/spec/abi.rs b/src/librustc_target/spec/abi.rs index 919744fe046e7..a1ec631335c7d 100644 --- a/src/librustc_target/spec/abi.rs +++ b/src/librustc_target/spec/abi.rs @@ -28,6 +28,8 @@ pub enum Abi { Msp430Interrupt, X86Interrupt, AmdGpuKernel, + AvrInterrupt, + AvrNonBlockingInterrupt, // Multiplatform / generic ABIs Rust, @@ -65,6 +67,9 @@ const AbiDatas: &[AbiData] = &[ AbiData {abi: Abi::Msp430Interrupt, name: "msp430-interrupt", generic: false }, AbiData {abi: Abi::X86Interrupt, name: "x86-interrupt", generic: false }, AbiData {abi: Abi::AmdGpuKernel, name: "amdgpu-kernel", generic: false }, + AbiData {abi: Abi::AvrInterrupt, name: "avr-interrupt", generic: false }, + AbiData {abi: Abi::AvrNonBlockingInterrupt, name: "avr-non-blocking-interrupt", + generic: false }, // Cross-platform ABIs AbiData {abi: Abi::Rust, name: "Rust", generic: true }, diff --git a/src/librustc_target/spec/avr_unknown_unknown.rs b/src/librustc_target/spec/avr_unknown_unknown.rs new file mode 100644 index 0000000000000..7cb8358453f28 --- /dev/null +++ b/src/librustc_target/spec/avr_unknown_unknown.rs @@ -0,0 +1,27 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use spec::{LinkerFlavor, Target, TargetResult}; + +pub fn target() -> TargetResult { + Ok(Target { + llvm_target: "avr-unknown-unknown".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "16".to_string(), + data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".to_string(), + arch: "avr".to_string(), + linker_flavor: LinkerFlavor::Gcc, + target_os: "unknown".to_string(), + target_env: "".to_string(), + target_vendor: "unknown".to_string(), + target_c_int_width: 16.to_string(), + options: super::none_base::opts(), + }) +} diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index aef8770bcc69b..09606d9a4cfc5 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -65,6 +65,7 @@ mod haiku_base; mod hermit_base; mod linux_base; mod linux_musl_base; +mod none_base; mod openbsd_base; mod netbsd_base; mod solaris_base; @@ -364,6 +365,8 @@ supported_targets! { ("aarch64-fuchsia", aarch64_fuchsia), ("x86_64-fuchsia", x86_64_fuchsia), + ("avr-unknown-unknown", avr_unknown_unknown), + ("x86_64-unknown-l4re-uclibc", x86_64_unknown_l4re_uclibc), ("x86_64-unknown-redox", x86_64_unknown_redox), @@ -444,7 +447,7 @@ pub struct Target { /// Vendor name to use for conditional compilation. pub target_vendor: String, /// Architecture to use for ABI considerations. Valid options: "x86", - /// "x86_64", "arm", "aarch64", "mips", "powerpc", and "powerpc64". + /// "x86_64", "arm", "aarch64", "avr", "mips", "powerpc", and "powerpc64". pub arch: String, /// [Data layout](http://llvm.org/docs/LangRef.html#data-layout) to pass to LLVM. pub data_layout: String, @@ -785,6 +788,12 @@ impl Default for TargetOptions { } } +impl TargetOptions { + pub fn is_specific_cpu(&self) -> bool { + self.cpu != "generic" + } +} + impl Target { /// Given a function ABI, turn it into the correct ABI for this target. pub fn adjust_abi(&self, abi: Abi) -> Abi { diff --git a/src/librustc_target/spec/none_base.rs b/src/librustc_target/spec/none_base.rs new file mode 100644 index 0000000000000..6afdcb6ecf1c5 --- /dev/null +++ b/src/librustc_target/spec/none_base.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::default::Default; +use spec::{LinkerFlavor, LinkArgs, TargetOptions}; + +pub fn opts() -> TargetOptions { + let mut args = LinkArgs::new(); + + args.insert(LinkerFlavor::Gcc, vec![ + // We want to be able to strip as much executable code as possible + // from the linker command line, and this flag indicates to the + // linker that it can avoid linking in dynamic libraries that don't + // actually satisfy any symbols up to that point (as with many other + // resolutions the linker does). This option only applies to all + // following libraries so we're sure to pass it as one of the first + // arguments. + "-Wl,--as-needed".to_string(), + ]); + + TargetOptions { + dynamic_linking: false, + executables: true, + linker_is_gnu: true, + has_rpath: false, + pre_link_args: args, + position_independent_executables: true, + .. Default::default() + } +} diff --git a/src/libstd/env.rs b/src/libstd/env.rs index d14efa2e3c76d..ced0682d207a6 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -821,6 +821,7 @@ pub mod consts { /// - x86_64 /// - arm /// - aarch64 + /// - avr /// - mips /// - mips64 /// - powerpc @@ -933,6 +934,11 @@ mod arch { pub const ARCH: &str = "aarch64"; } +#[cfg(target_arch = "avr")] +mod arch { + pub const ARCH: &'static str = "avr"; +} + #[cfg(target_arch = "mips")] mod arch { pub const ARCH: &str = "mips"; diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 4eca0c942f34e..5d2d6f2327d09 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -331,6 +331,9 @@ declare_features! ( // Allows `extern "x86-interrupt" fn()`. (active, abi_x86_interrupt, "1.17.0", Some(40180), None), + // `extern "avr-interrupt" fn()` + (active, abi_avr_interrupt, "1.18.0", Some(000), None), + // Allows the `try {...}` expression. (active, try_blocks, "1.29.0", Some(31436), None), @@ -1475,6 +1478,11 @@ impl<'a> PostExpansionVisitor<'a> { Abi::X86Interrupt => { gate_feature_post!(&self, abi_x86_interrupt, span, "x86-interrupt ABI is experimental and subject to change"); + } + Abi::AvrInterrupt | Abi::AvrNonBlockingInterrupt => { + gate_feature_post!(&self, abi_avr_interrupt, span, + "avr-interrupt and avr-non-blocking-interrupt ABIs are \ + experimental and subject to change"); }, Abi::AmdGpuKernel => { gate_feature_post!(&self, abi_amdgpu_kernel, span, diff --git a/src/llvm b/src/llvm index 95185c8c801c7..256a0879cabb5 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 95185c8c801c765ac1072392d081d265af9fb310 +Subproject commit 256a0879cabb5460b2da3a69235cb5571588da81 diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 4d95368c00f1e..8476575e58714 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -127,6 +127,12 @@ void LLVMRustPassManagerBuilderPopulateThinLTOPassManager( #define SUBTARGET_AARCH64 #endif +#ifdef LLVM_COMPONENT_AVR +#define SUBTARGET_AVR SUBTARGET(AVR) +#else +#define SUBTARGET_AVR +#endif + #ifdef LLVM_COMPONENT_MIPS #define SUBTARGET_MIPS SUBTARGET(Mips) #else @@ -173,6 +179,7 @@ void LLVMRustPassManagerBuilderPopulateThinLTOPassManager( SUBTARGET_X86 \ SUBTARGET_ARM \ SUBTARGET_AARCH64 \ + SUBTARGET_AVR \ SUBTARGET_MIPS \ SUBTARGET_PPC \ SUBTARGET_SYSTEMZ \ diff --git a/src/test/run-pass/cfg-target-cpu.rs b/src/test/run-pass/cfg-target-cpu.rs new file mode 100644 index 0000000000000..0553d2350a74d --- /dev/null +++ b/src/test/run-pass/cfg-target-cpu.rs @@ -0,0 +1,18 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn main() { + if cfg!(target_cpu = "cortex-a8") { + println!("Running on Cortex A8!"); + } else { + println!("Running on an arbitrary cpu"); + } +} + diff --git a/src/test/ui/feature-gates/feature-gate-abi-avr-interrupt.rs b/src/test/ui/feature-gates/feature-gate-abi-avr-interrupt.rs new file mode 100644 index 0000000000000..806bff25e7dd8 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-abi-avr-interrupt.rs @@ -0,0 +1,19 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the AVR interrupt ABI cannot be used when avr_interrupt +// feature gate is not used. + +extern "avr-interrupt" fn foo() {} +//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + +fn main() { + foo(); +} diff --git a/src/test/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr b/src/test/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr new file mode 100644 index 0000000000000..023b6121784f7 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr @@ -0,0 +1,11 @@ +error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change + --> $DIR/feature-gate-abi-avr-interrupt.rs:14:1 + | +LL | extern "avr-interrupt" fn foo() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(abi_avr_interrupt)] to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 381d808e8028f..3732f60380446 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -31,6 +31,7 @@ const OS_TABLE: &'static [(&'static str, &'static str)] = &[ ("linux", "linux"), ("mingw32", "windows"), ("netbsd", "netbsd"), + ("none", "none"), ("openbsd", "openbsd"), ("redox", "redox"), ("solaris", "solaris"), @@ -48,6 +49,7 @@ const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[ ("armv7", "arm"), ("armv7s", "arm"), ("asmjs", "asmjs"), + ("avr", "avr"), ("hexagon", "hexagon"), ("i386", "x86"), ("i586", "x86"),