Skip to content

Commit f4caf7f

Browse files
committed
Split nightly action in two actions
1 parent 9d9105e commit f4caf7f

File tree

2 files changed

+144
-95
lines changed

2 files changed

+144
-95
lines changed
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: Nightly cross-compilation of rustc with rustc_codegen_gcc
2+
3+
on:
4+
pull_request:
5+
# TODO: remove pull_request and add schedule to run during the night.
6+
7+
env:
8+
# Enable backtraces for easier debugging
9+
RUST_BACKTRACE: 1
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-24.04
14+
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
arch:
19+
- host_target: "m68k-unknown-linux-gnu"
20+
cross_target: "m68k"
21+
debian_url: "http://ftp.ports.debian.org/debian-ports"
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
path: "rustc_codegen_gcc"
27+
28+
- uses: actions/checkout@v4
29+
with:
30+
repository: "rust-lang/rust"
31+
path: "rust"
32+
fetch-depth: 10
33+
34+
# The compilation of rustc for m68k requires a lot of disk space, so free some space up.
35+
- name: Free Disk Space
36+
uses: endersonmenezes/free-disk-space@v3
37+
with:
38+
remove_android: true
39+
remove_dotnet: true
40+
remove_haskell: true
41+
remove_tool_cache: true
42+
remove_swap: true
43+
remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
44+
remove_packages_one_command: true
45+
remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
46+
47+
- name: Install packages
48+
run: |
49+
sudo apt-get update
50+
sudo apt-get install debootstrap qemu-system qemu-user-static
51+
52+
# `rustup show` installs from rust-toolchain.toml
53+
- name: Setup rust toolchain
54+
run: rustup show
55+
56+
- name: Setup rust cache
57+
uses: Swatinem/rust-cache@v2
58+
59+
- name: Download and install artifacts
60+
run: |
61+
curl -L -o package.deb https://github.com/rust-lang/gcc/releases/latest/download/gcc-15.deb
62+
sudo dpkg --force-overwrite -i package.deb
63+
64+
- name: Generate Debian qemu image
65+
run: |
66+
dd if=/dev/zero of=debian.img bs=1M count=15360
67+
mkfs.ext4 debian.img -L root
68+
mkdir vm
69+
sudo mount debian.img vm
70+
sudo debootstrap --no-check-gpg --arch=${{ matrix.arch.cross_target }} --foreign unstable vm ${{ matrix.arch.debian_url }}
71+
sudo cp $(which qemu-${{ matrix.arch.cross_target }}-static) vm/usr/bin/
72+
73+
- name: Download cross-compiling libgccjit.so and move it in libgccjit-libs-dir
74+
run: |
75+
curl -LO https://github.com/cross-cg-gcc-tools/cross-gcc/releases/latest/download/gcc-${{ matrix.arch.cross_target }}-15.deb
76+
77+
sudo dpkg-deb -x gcc-${{ matrix.arch.cross_target }}-15.deb cross-gcc
78+
dir=$HOME/libgccjit-libs-dir/x86_64-unknown-linux-gnu/${{ matrix.arch.host_target }}
79+
mkdir -p $dir
80+
sudo mv cross-gcc/usr/lib/libgccjit.so.0.0.1 $dir/libgccjit.so
81+
82+
echo "$(pwd)/cross-gcc/usr/bin" >> $GITHUB_PATH
83+
84+
- name: Download native libgccjit.so and move it in libgccjit-libs-dir
85+
run: |
86+
curl -LO https://github.com/cross-cg-gcc-tools/native-gcc/releases/latest/download/libgccjit-${{ matrix.arch.cross_target }}.so
87+
88+
dir=$HOME/libgccjit-libs-dir/${{ matrix.arch.host_target }}/${{ matrix.arch.host_target }}
89+
mkdir -p $dir
90+
mv libgccjit-${{ matrix.arch.cross_target }}.so $dir/libgccjit.so
91+
92+
- name: Patch linux-raw-sys and rustix.
93+
run: |
94+
cd rust
95+
96+
cat <<'EOF' > patch.toml
97+
[patch.crates-io]
98+
linux-raw-sys = { git = "https://github.com/antoyo/linux-raw-sys", branch = "m68k-support" }
99+
rustix = { git = "https://github.com/antoyo/rustix", branch = "m68k-support" }
100+
EOF
101+
102+
cat patch.toml >> Cargo.toml
103+
cat patch.toml >> compiler/rustc_codegen_gcc/Cargo.toml
104+
105+
cargo update -p rustix
106+
cd compiler/rustc_codegen_gcc/
107+
cargo update -p rustix
108+
109+
cd ../..
110+
111+
echo Checking Rust
112+
cargo tree -i linux-raw-sys 2>&1 | grep "was not used in the crate graph" && (echo "Unused patches found"; cargo tree; exit 1) || exit 0
113+
114+
echo Checking rustc_codegen_gcc
115+
cargo tree --manifest-path compiler/rustc_codegen_gcc/Cargo.toml -i linux-raw-sys 2>&1 | grep "was not used in the crate graph" && (echo "Unused patches found"; cargo tree; exit 1) || exit 0
116+
117+
- name: Compile rustc
118+
run: |
119+
cd rust
120+
./x build --host=${{ matrix.arch.host_target }} --stage 2 --config ../rustc_codegen_gcc/tests/bootstraps/bootstrap.${{ matrix.arch.host_target }}.toml
121+
122+
- name: Copy toolchain in VM
123+
run: |
124+
sudo rsync -a --exclude=stage2/lib/rustlib/src --exclude=stage2/lib/rustlib/rustc-src/ rust/build/${{ matrix.arch.host_target }}/stage2/ vm/home/stage2
125+
126+
- name: Smoke test
127+
run: |
128+
sudo chroot vm qemu-${{ matrix.arch.cross_target }}-static /bin/sh -c '/home/stage2/bin/rustc' > output
129+
grep rustc output
130+
131+
# TODO: compile a test program for m68k when the compiler works.
132+
#- name: Compile test program
133+
#run: |
134+
#cd rustc_codegen_gcc/tests/hello-world
135+
#cargo +my-toolchain build
136+
137+
#objcopy --dump-section .comment=comment target/debug/hello_world
138+
#grep "rustc version .* with libgccjit" comment
139+
#grep 'GCC: ' comment
140+
141+
#cargo +my-toolchain run > hello_world_stdout
142+
143+
#expected_output="40"
144+
#test $(cat hello_world_stdout) == $expected_output || (echo "Output differs. Actual output: $(cat hello_world_stdout)"; exit 1)

.github/workflows/nightly_rustc.yml

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ jobs:
1717
matrix:
1818
arch:
1919
- host_target: "x86_64-unknown-linux-gnu"
20-
cross_target: ""
21-
- host_target: "m68k-unknown-linux-gnu"
22-
cross_target: "m68k"
23-
debian_url: "http://ftp.ports.debian.org/debian-ports"
2420

2521
steps:
2622
- uses: actions/checkout@v4
@@ -33,25 +29,6 @@ jobs:
3329
path: "rust"
3430
fetch-depth: 10
3531

36-
# The compilation of rustc for m68k requires a lot of disk space, so free some space up.
37-
- name: Free Disk Space
38-
uses: endersonmenezes/free-disk-space@v3
39-
with:
40-
remove_android: true
41-
remove_dotnet: true
42-
remove_haskell: true
43-
remove_tool_cache: true
44-
remove_swap: true
45-
remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
46-
remove_packages_one_command: true
47-
remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
48-
49-
- name: Install packages
50-
if: ${{ matrix.arch.cross_target != '' }}
51-
run: |
52-
sudo apt-get update
53-
sudo apt-get install debootstrap qemu-system qemu-user-static
54-
5532
# `rustup show` installs from rust-toolchain.toml
5633
- name: Setup rust toolchain
5734
run: rustup show
@@ -64,94 +41,22 @@ jobs:
6441
curl -L -o package.deb https://github.com/rust-lang/gcc/releases/latest/download/gcc-15.deb
6542
sudo dpkg --force-overwrite -i package.deb
6643
67-
- name: Generate Debian qemu image
68-
if: ${{ matrix.arch.cross_target != '' }}
69-
run: |
70-
dd if=/dev/zero of=debian.img bs=1M count=15360
71-
mkfs.ext4 debian.img -L root
72-
mkdir vm
73-
sudo mount debian.img vm
74-
sudo debootstrap --no-check-gpg --arch=${{ matrix.arch.cross_target }} --foreign unstable vm ${{ matrix.arch.debian_url }}
75-
sudo cp $(which qemu-${{ matrix.arch.cross_target }}-static) vm/usr/bin/
76-
77-
- name: Download cross-compiling libgccjit.so and move it in libgccjit-libs-dir
78-
if: ${{ matrix.arch.cross_target != '' }}
79-
run: |
80-
curl -LO https://github.com/cross-cg-gcc-tools/cross-gcc/releases/latest/download/gcc-${{ matrix.arch.cross_target }}-15.deb
81-
82-
sudo dpkg-deb -x gcc-${{ matrix.arch.cross_target }}-15.deb cross-gcc
83-
dir=$HOME/libgccjit-libs-dir/x86_64-unknown-linux-gnu/${{ matrix.arch.host_target }}
84-
mkdir -p $dir
85-
sudo mv cross-gcc/usr/lib/libgccjit.so.0.0.1 $dir/libgccjit.so
86-
87-
echo "$(pwd)/cross-gcc/usr/bin" >> $GITHUB_PATH
88-
89-
- name: Download native libgccjit.so and move it in libgccjit-libs-dir
90-
if: ${{ matrix.arch.cross_target != '' }}
91-
run: |
92-
curl -LO https://github.com/cross-cg-gcc-tools/native-gcc/releases/latest/download/libgccjit-${{ matrix.arch.cross_target }}.so
93-
94-
dir=$HOME/libgccjit-libs-dir/${{ matrix.arch.host_target }}/${{ matrix.arch.host_target }}
95-
mkdir -p $dir
96-
mv libgccjit-${{ matrix.arch.cross_target }}.so $dir/libgccjit.so
97-
98-
- name: Patch linux-raw-sys and rustix.
99-
if: ${{ matrix.arch.cross_target != '' }}
100-
run: |
101-
cd rust
102-
103-
cat <<'EOF' > patch.toml
104-
[patch.crates-io]
105-
linux-raw-sys = { git = "https://github.com/antoyo/linux-raw-sys", branch = "m68k-support" }
106-
rustix = { git = "https://github.com/antoyo/rustix", branch = "m68k-support" }
107-
EOF
108-
109-
cat patch.toml >> Cargo.toml
110-
cat patch.toml >> compiler/rustc_codegen_gcc/Cargo.toml
111-
112-
cargo update -p rustix
113-
cd compiler/rustc_codegen_gcc/
114-
cargo update -p rustix
115-
116-
cd ../..
117-
118-
echo Checking Rust
119-
cargo tree -i linux-raw-sys 2>&1 | grep "was not used in the crate graph" && (echo "Unused patches found"; cargo tree; exit 1) || exit 0
120-
121-
echo Checking rustc_codegen_gcc
122-
cargo tree --manifest-path compiler/rustc_codegen_gcc/Cargo.toml -i linux-raw-sys 2>&1 | grep "was not used in the crate graph" && (echo "Unused patches found"; cargo tree; exit 1) || exit 0
123-
12444
- name: Compile rustc
12545
run: |
12646
cd rust
12747
./x build --host=${{ matrix.arch.host_target }} --stage 2 --config ../rustc_codegen_gcc/tests/bootstraps/bootstrap.${{ matrix.arch.host_target }}.toml
12848
12949
- name: Link toolchain
130-
if: ${{ matrix.arch.cross_target == '' }}
13150
run: |
13251
cd rust
13352
rustup toolchain link my-toolchain build/${{ matrix.arch.host_target }}/stage2
13453
13554
- name: Smoke test
136-
if: ${{ matrix.arch.cross_target == '' }}
13755
run: |
13856
rustc +my-toolchain -V > output
13957
grep rustc output
14058
141-
- name: Copy toolchain in VM
142-
if: ${{ matrix.arch.cross_target != '' }}
143-
run: |
144-
sudo rsync -a --exclude=stage2/lib/rustlib/src --exclude=stage2/lib/rustlib/rustc-src/ rust/build/${{ matrix.arch.host_target }}/stage2/ vm/home/stage2
145-
146-
- name: Smoke test
147-
if: ${{ matrix.arch.cross_target != '' }}
148-
run: |
149-
sudo chroot vm qemu-${{ matrix.arch.cross_target }}-static /bin/sh -c '/home/stage2/bin/rustc' > output
150-
grep rustc output
151-
15259
- name: Compile test program
153-
# TODO: also compile a test program for m68k when the compiler works.
154-
if: ${{ matrix.arch.cross_target == '' }}
15560
run: |
15661
cd rustc_codegen_gcc/tests/hello-world
15762
cargo +my-toolchain build

0 commit comments

Comments
 (0)