Add CI compiling rustc #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nightly compilation of rustc with rustc_codegen_gcc | |
| on: | |
| pull_request: | |
| # TODO: remove pull_request and add schedule to run during the night. | |
| env: | |
| # Enable backtraces for easier debugging | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| arch: | |
| - host_target: "x86_64-unknown-linux-gnu" | |
| cross_target: "" | |
| gcc_urls: > | |
| https://github.com/rust-lang/gcc/releases/latest/download/gcc-15.deb | |
| - host_target: "m68k-unknown-linux-gnu" | |
| cross_target: "m68k" | |
| gcc_urls: > | |
| https://github.com/rust-lang/gcc/releases/latest/download/gcc-15.deb | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| path: "rustc_codegen_gcc" | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: "rust-lang/rust" | |
| path: "rust" | |
| fetch-depth: 10 | |
| - run: | | |
| echo $HOME | |
| echo "*****" | |
| ls | |
| echo "*****" | |
| ls .. | |
| echo "*****" | |
| ls rust | |
| echo "*****" | |
| # `rustup show` installs from rust-toolchain.toml | |
| - name: Setup rust toolchain | |
| run: rustup show | |
| - name: Setup rust cache | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Download and install artifacts | |
| run: | | |
| urls=(${{ matrix.arch.gcc_urls }}) | |
| for url in "${urls[@]}"; do | |
| curl -L -o package.deb $url | |
| sudo dpkg --force-overwrite -i package.deb | |
| done | |
| # TODO: patch linux-raw-sys and rustix. | |
| - name: Move libgccjit.so in libgccjit-libs-dir | |
| if: ${{ matrix.arch.cross_target != '' }} | |
| run: | | |
| curl -LO https://github.com/cross-cg-gcc-tools/cross-gcc/releases/latest/download/gcc-${{ matrix.arch.cross_target }}-15.deb | |
| sudo dpkg --instdir=cross-gcc -i gcc-${{ matrix.arch.cross_target }}-15.deb | |
| ls cross-gcc | |
| ls cross-gcc/usr/lib | |
| dir=$HOME/libgccjit-libs-dir/x86_64-unknown-linux-gnu/${{ matrix.arch.host_target }} | |
| mkdir -p $dir | |
| # TODO: create a symlink instead of a copy. | |
| cp cross-gcc/usr/lib/libgccjit.so.0.0.1 $dir | |
| - name: Compile rustc | |
| run: | | |
| cd rust | |
| # TODO: add --host=${{ matrix.arch.host_target }} if needed (should not be since it's in the toml config file) | |
| ./x build --stage 2 --config ../rustc_codegen_gcc/tests/bootstraps/bootstrap.${{ matrix.arch.host_target }}.toml | |
| - name: Link toolchain | |
| run: | | |
| ls | |
| echo **** | |
| ls build | |
| echo **** | |
| ls build/${{ matrix.arch.host_target }} | |
| rustup toolchain link my-toolchain build/${{ matrix.arch.host_target }}/stage2 | |
| - name: Smoke test | |
| run: | | |
| rustc +my-toolchain -V > output | |
| grep rustc output | |
| - name: Compile test program | |
| run: | | |
| cd ../rustc_codegen_gcc/tests/hello-world | |
| cargo +my-toolchain build | |
| cargo +my-toolchain run > hello_world_stdout | |
| expected_output="40" | |
| test $(cat hello_world_stdout) == $expected_output || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1) | |
| objcopy --dump-section .comment=comment target/debug/hello_world | |
| grep --text "^.rustc version .* with libgccjit" comment | |
| grep --text 'libgccjit' comment | |
| grep --text 'GCC: ' comment |