| @@ -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 | |||
| @@ -0,0 +1,14 @@ | |||
| node('master') { | |||
| stage('Checkout') { | |||
| checkout scm | |||
| sh 'git submodule update --init --recursive' | |||
| } | |||
|
|
|||
| stage('Build') { | |||
| dir('build') { | |||
| sh '../x.py build' | |||
| } | |||
| } | |||
| } | |||
|
|
|||
|
|
|||
| @@ -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. | |||
| [](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=<triple>` 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. | |||
| @@ -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=<triple>` 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. | |||
| @@ -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 <LICENSE-APACHE or | |||
| // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |||
| // <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<Ty>(ret: &mut ArgType<Ty>) { | |||
| if ret.layout.is_aggregate() { | |||
| ret.make_indirect(); | |||
| } else { | |||
| ret.extend_integer_width_to(8); // Is 8 correct? | |||
| } | |||
| } | |||
|
|
|||
| fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>) { | |||
| if arg.layout.is_aggregate() { | |||
| arg.make_indirect(); | |||
| } else { | |||
| arg.extend_integer_width_to(8); | |||
| } | |||
| } | |||
|
|
|||
| pub fn compute_abi_info<Ty>(fty: &mut FnType<Ty>) { | |||
| 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); | |||
| } | |||
| } | |||
| @@ -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 <LICENSE-APACHE or | |||
| // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |||
| // <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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(), | |||
| }) | |||
| } | |||
| @@ -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 <LICENSE-APACHE or | |||
| // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |||
| // <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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() | |||
| } | |||
| } | |||
| @@ -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 <LICENSE-APACHE or | |||
| // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |||
| // <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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"); | |||
| } | |||
| } | |||
|
|
|||
| @@ -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 <LICENSE-APACHE or | |||
| // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |||
| // <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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(); | |||
| } | |||
| @@ -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`. | |||