From 38e8e85443634a2b3093e149dc1b0f90dbd84912 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 16 Dec 2025 11:05:14 -0500 Subject: [PATCH 1/5] Add CI compiling rustc --- .github/workflows/nightly_rustc.yml | 66 +++++++++++++++++++ .../bootstrap.m68k-unknown-linux-gnu.toml | 18 +++++ .../bootstrap.x86_64-unknown-linux-gnu.toml | 11 ++++ 3 files changed, 95 insertions(+) create mode 100644 .github/workflows/nightly_rustc.yml create mode 100644 tests/bootstraps/bootstrap.m68k-unknown-linux-gnu.toml create mode 100644 tests/bootstraps/bootstrap.x86_64-unknown-linux-gnu.toml diff --git a/.github/workflows/nightly_rustc.yml b/.github/workflows/nightly_rustc.yml new file mode 100644 index 00000000000..d8e1e877db1 --- /dev/null +++ b/.github/workflows/nightly_rustc.yml @@ -0,0 +1,66 @@ +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" + gcc_urls: > + https://github.com/rust-lang/gcc/releases/latest/download/gcc-15.deb + - host_target: "m68k-unknown-linux-gnu" + gcc_urls: > + https://github.com/rust-lang/gcc/releases/latest/download/gcc-15.deb + https://github.com/cross-cg-gcc-tools/cross-gcc/releases/latest/download/gcc-m68k-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: | + 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: Compile rustc + run: | + cd rust + ./x build --host=${{ matrix.arch.host_target }} --stage 2 --config ../rustc_codegen_gcc/tests/bootstraps/bootstrap.${{ matrix.arch.host_target }}.toml diff --git a/tests/bootstraps/bootstrap.m68k-unknown-linux-gnu.toml b/tests/bootstraps/bootstrap.m68k-unknown-linux-gnu.toml new file mode 100644 index 00000000000..e7a7626ad01 --- /dev/null +++ b/tests/bootstraps/bootstrap.m68k-unknown-linux-gnu.toml @@ -0,0 +1,18 @@ +profile = "compiler" +change-id = 140732 + +[build] +target = ["m68k-unknown-linux-gnu"] + +[rust] +codegen-backends = ["gcc"] +deny-warnings = false +debug-assertions = false +debug-assertions-std = false + +[gcc] +download-ci-gcc = true +libgccjit-libs-dir = "/home/runner/libgccjit-libs-dir" + +[target.m68k-unknown-linux-gnu] +cc = "/home/runner/work/rustc_codegen_gcc/rustc_codegen_gcc/cross-gcc/usr/bin/m68k-unknown-linux-gnu-gcc" diff --git a/tests/bootstraps/bootstrap.x86_64-unknown-linux-gnu.toml b/tests/bootstraps/bootstrap.x86_64-unknown-linux-gnu.toml new file mode 100644 index 00000000000..32daaa57237 --- /dev/null +++ b/tests/bootstraps/bootstrap.x86_64-unknown-linux-gnu.toml @@ -0,0 +1,11 @@ +profile = "compiler" +change-id = 140732 + +[rust] +codegen-backends = ["gcc"] +deny-warnings = false +debug-assertions = false +debug-assertions-std = false + +[gcc] +download-ci-gcc = true From 3860631c56fc417fcc81263d0433c066017a39f6 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 16 Dec 2025 13:52:41 -0500 Subject: [PATCH 2/5] Compile program in the nightly CI --- .github/workflows/nightly_rustc.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/nightly_rustc.yml b/.github/workflows/nightly_rustc.yml index d8e1e877db1..c3ee506e99f 100644 --- a/.github/workflows/nightly_rustc.yml +++ b/.github/workflows/nightly_rustc.yml @@ -64,3 +64,20 @@ jobs: run: | cd rust ./x build --host=${{ matrix.arch.host_target }} --stage 2 --config ../rustc_codegen_gcc/tests/bootstraps/bootstrap.${{ matrix.arch.host_target }}.toml + + - name: Link toolchain + run: rustup toolchain link my-toolchain build/${{ matrix.arch.host_target }}/stage2 + + - name: Compile test program + run: | + cd rustc_codegen_gcc/tests/hello-world + cargo +my-toolchain build + + objcopy --dump-section .comment=comment target/debug/hello_world + grep "rustc version .* with libgccjit" comment + grep 'GCC: ' comment + + 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) From 577068a04f904d95a25908a9ac39a588f8071001 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 16 Dec 2025 14:26:44 -0500 Subject: [PATCH 3/5] Add smoke test --- .github/workflows/nightly_rustc.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/nightly_rustc.yml b/.github/workflows/nightly_rustc.yml index c3ee506e99f..db653e3c895 100644 --- a/.github/workflows/nightly_rustc.yml +++ b/.github/workflows/nightly_rustc.yml @@ -68,6 +68,11 @@ jobs: - name: Link toolchain run: 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 From b3fbe1d331c9d94c44c5872632cfe4b1cbd10de7 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 16 Dec 2025 15:22:42 -0500 Subject: [PATCH 4/5] Fix link toolchain --- .github/workflows/nightly_rustc.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightly_rustc.yml b/.github/workflows/nightly_rustc.yml index db653e3c895..abca033b87e 100644 --- a/.github/workflows/nightly_rustc.yml +++ b/.github/workflows/nightly_rustc.yml @@ -66,7 +66,14 @@ jobs: ./x build --host=${{ matrix.arch.host_target }} --stage 2 --config ../rustc_codegen_gcc/tests/bootstraps/bootstrap.${{ matrix.arch.host_target }}.toml - name: Link toolchain - run: rustup toolchain link my-toolchain build/${{ matrix.arch.host_target }}/stage2 + run: | + cd rust + 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: | From 869b8af1ab258379fbae352b68b181ba1c459962 Mon Sep 17 00:00:00 2001 From: Antoni Boucher Date: Tue, 16 Dec 2025 14:06:18 -0500 Subject: [PATCH 5/5] Create libgccjit-libs-dir --- .github/workflows/nightly_rustc.yml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightly_rustc.yml b/.github/workflows/nightly_rustc.yml index abca033b87e..8a7ab9bd8b4 100644 --- a/.github/workflows/nightly_rustc.yml +++ b/.github/workflows/nightly_rustc.yml @@ -17,12 +17,13 @@ jobs: 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 - https://github.com/cross-cg-gcc-tools/cross-gcc/releases/latest/download/gcc-m68k-15.deb steps: - uses: actions/checkout@v4 @@ -36,6 +37,8 @@ jobs: fetch-depth: 10 - run: | + echo $HOME + echo "*****" ls echo "*****" ls .. @@ -59,9 +62,32 @@ jobs: 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-deb -x gcc-${{ matrix.arch.cross_target }}-15.deb cross-gcc + echo **** + ls cross-gcc + echo **** + ls cross-gcc/usr/lib + echo **** + ls -R + 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/libgccjit.so + + echo "$(pwd)/cross-gcc/usr/bin" >> $GITHUB_PATH + + ls /home/runner/libgccjit-libs-dir/x86_64-unknown-linux-gnu/m68k-unknown-linux-gnu/libgccjit.so + echo **** + ls -R /home/runner/libgccjit-libs-dir - name: Compile rustc run: | + echo $PATH cd rust ./x build --host=${{ matrix.arch.host_target }} --stage 2 --config ../rustc_codegen_gcc/tests/bootstraps/bootstrap.${{ matrix.arch.host_target }}.toml