-
Notifications
You must be signed in to change notification settings - Fork 93
175 lines (143 loc) · 6.18 KB
/
nightly_rustc.yml
File metadata and controls
175 lines (143 loc) · 6.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
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
- name: Free Disk Space
uses: endersonmenezes/free-disk-space@v3
with:
remove_android: true
remove_dotnet: true
remove_haskell: true
remove_tool_cache: true
remove_swap: true
remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
remove_packages_one_command: true
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"
- name: Install packages
if: ${{ matrix.arch.cross_target != '' }}
run: |
sudo apt-get update
sudo apt-get install qemu-system qemu-user-static
# `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
- name: Generate Debian qemu image
if: ${{ matrix.arch.cross_target != '' }}
run: |
dd if=/dev/zero of=debian.img bs=1M count=15360
mkfs.ext4 debian.img -L root
mkdir vm
sudo mount debian.img vm
sudo debootstrap --no-check-gpg --arch=${{ matrix.arch.name }} --foreign unstable vm ${{ matrix.arch.url }}
sudo cp $(which qemu-${{ matrix.arch.cross_target }}-static) vm/usr/bin/
- name: Download cross-compiling libgccjit.so and move it 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
dir=$HOME/libgccjit-libs-dir/x86_64-unknown-linux-gnu/${{ matrix.arch.host_target }}
mkdir -p $dir
sudo mv cross-gcc/usr/lib/libgccjit.so.0.0.1 $dir/libgccjit.so
echo "$(pwd)/cross-gcc/usr/bin" >> $GITHUB_PATH
- name: Download native libgccjit.so and move it in libgccjit-libs-dir
if: ${{ matrix.arch.cross_target != '' }}
run: |
curl -LO https://github.com/cross-cg-gcc-tools/native-gcc/releases/latest/download/libgccjit-${{ matrix.arch.cross_target }}.so
dir=$HOME/libgccjit-libs-dir/${{ matrix.arch.host_target }}/${{ matrix.arch.host_target }}
mkdir -p $dir
mv libgccjit-${{ matrix.arch.cross_target }}.so $dir/libgccjit.so
- name: Patch linux-raw-sys and rustix.
if: ${{ matrix.arch.cross_target != '' }}
run: |
cd rust
cat <<'EOF' > patch.toml
[patch.crates-io]
linux-raw-sys = { git = "https://github.com/antoyo/linux-raw-sys", branch = "m68k-support" }
rustix = { git = "https://github.com/antoyo/rustix", branch = "m68k-support" }
EOF
cat patch.toml >> Cargo.toml
cat patch.toml >> compiler/rustc_codegen_gcc/Cargo.toml
cargo update -p rustix
cd compiler/rustc_codegen_gcc/
cargo update -p rustix
echo Checking Rust
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
echo Checking rustc_codegen_gcc
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
- 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
- name: Link toolchain
if: ${{ matrix.arch.cross_target == '' }}
run: |
cd rust
rustup toolchain link my-toolchain build/${{ matrix.arch.host_target }}/stage2
- name: Smoke test
if: ${{ matrix.arch.cross_target == '' }}
run: |
rustc +my-toolchain -V > output
grep rustc output
- name: Copy toolchain in VM
if: ${{ matrix.arch.cross_target != '' }}
run: |
echo 1 .
ls
echo 2 vm
ls vm
echo 3 vm/home
ls vm/home
echo ****
sudo rsync -a --exclude=stage2/lib/rustlib/src --exclude=stage2/lib/rustlib/rustc-src/ rust/build/m68k-unknown-linux-gnu/stage2 vm/home/stage2
- name: Smoke test
if: ${{ matrix.arch.cross_target != '' }}
run: |
sudo chroot vm qemu-m68k-static /home/stage2/rustc > output
grep rustc output
- 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)