Repository navigation
183 lines (168 loc) · 8.71 KB
/
Copy pathfullrust-toolchain.yml
File metadata and controls
183 lines (168 loc) · 8.71 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
176
177
178
179
180
181
182
183
name: fullrust toolchain
# The upstream-watch workflow looks runs up by this name to avoid re-dispatching
# a build it already dispatched.
run-name: fullrust toolchain ${{ inputs.minor }} ${{ inputs.version }} ${{ inputs.overlay }}
# Build the patched stage1 compiler and attach it (with the bootstrap cargo) as a
# release asset. This is the slow, rare half (LLVM + rustc from source, ~1–2 h);
# the fast `fullrust image` workflow packages the asset into a container. Run it
# once per Rust version. Analogous to decryptd's Release workflow producing the
# binary that its Docker workflow then ships.
#
# One runner builds the host std plus std for EVERY fullrust target the minor's
# overlay registers (x86_64, aarch64, i686, armv7 once ported) in a single
# `x.py build library`, and the gate tests each target: x86_64 and i686
# natively, aarch64 and armv7 under qemu-user (binfmt_misc). Versus x86_64
# alone this adds the AArch64 + ARM LLVM backends (a one-time ~15–25% on a
# cold LLVM build; cached after), ~3 more std builds (~5–10 min) and the
# extra test runs (~5 min, qemu included).
on:
workflow_dispatch:
inputs:
minor:
description: "Rust minor to build (e.g. 1.100)"
required: true
default: "1.100"
type: string
version:
description: "Exact Rust release to build (blank = the newest <minor>.N point release upstream)"
required: false
default: ""
type: string
overlay:
description: "Expected overlay hash (set by upstream-watch; blank = don't check)"
required: false
default: ""
type: string
publish:
description: "Publish the toolchain release asset (untick to only build + test)"
required: false
default: true
type: boolean
# One build per minor at a time (two would race on the release asset).
concurrency:
group: fullrust-toolchain-${{ inputs.minor }}
cancel-in-progress: false
permissions:
contents: write # create/update the toolchain release + upload the asset
actions: write # dispatch `fullrust image` for the freshly published minor
jobs:
build:
name: build stage1 (${{ inputs.minor }})
# Pinned, not ubuntu-latest: the host rustc/cargo produced here link the
# runner's glibc/libstdc++ (GLIBC_2.39 / GLIBCXX_3.4.32 on 24.04). The image
# (docker/Dockerfile) bases on debian:trixie to satisfy exactly that floor;
# letting the runner drift to a newer Ubuntu would raise it and break the image.
runs-on: ubuntu-24.04
timeout-minutes: 350
steps:
- uses: actions/checkout@v6
# Point releases (1.99.1, …) carry the regression fixes of their minor, so
# build the newest one unless an exact version is asked for.
- name: Resolve the Rust release
id: ver
env:
MINOR: ${{ inputs.minor }}
VERSION: ${{ inputs.version }}
EXPECT_OVERLAY: ${{ inputs.overlay }}
run: |
set -euo pipefail
if [ -z "$VERSION" ]; then
VERSION="$(git ls-remote --tags --refs https://github.com/rust-lang/rust.git "refs/tags/$MINOR.*" \
| sed 's|.*refs/tags/||' | grep -E "^${MINOR//./\\.}\.[0-9]+$" | sort -V | tail -1)"
fi
[ -n "$VERSION" ] && [ "${VERSION%.*}" = "$MINOR" ] || { echo "::error::no Rust release for $MINOR (got '$VERSION')"; exit 1; }
# Recorded in the release body; upstream-watch rebuilds a minor whose
# overlay (patch + bootstrap config) no longer matches it.
OVERLAY="$(cat "toolchain/patches/fullrust-$MINOR.patch" "toolchain/bootstrap-$MINOR.toml" | sha256sum | cut -c1-12)"
if [ -n "$EXPECT_OVERLAY" ] && [ "$EXPECT_OVERLAY" != "$OVERLAY" ]; then
echo "::warning::overlay is $OVERLAY, dispatch expected $EXPECT_OVERLAY (master moved on); building $OVERLAY"
fi
echo "building Rust $VERSION, overlay $OVERLAY"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "overlay=$OVERLAY" >> "$GITHUB_OUTPUT"
- name: Free disk space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
large-packages: false
swap-storage: false
- name: Install build dependencies
run: |
sudo apt-get update
# Ubuntu 26.04 turned qemu-user-static into a virtual package
# (provided by qemu-user-binfmt); install whichever is real here.
qemu="qemu-user-static binfmt-support"
apt-cache show qemu-user-static 2>/dev/null | grep -q '^Version:' || qemu=qemu-user-binfmt
sudo apt-get install -y --no-install-recommends \
python3 cmake ninja-build clang git build-essential $qemu
# The gate runs aarch64/armv7 test binaries directly through
# binfmt_misc (not an explicit qemu prefix), so tests that exec
# themselves work too. Make sure the handlers are registered.
for a in aarch64 arm; do
if ! grep -qx enabled "/proc/sys/fs/binfmt_misc/qemu-$a" 2>/dev/null; then
sudo systemctl restart systemd-binfmt || sudo update-binfmts --enable "qemu-$a" || true
fi
grep -qx enabled "/proc/sys/fs/binfmt_misc/qemu-$a" \
|| { echo "::error::qemu-$a binfmt_misc handler not registered"; exit 1; }
done
# Restore/save split (not `actions/cache`) so the build is cached as soon
# as it succeeds — even if the test step below then fails, a re-run after
# a std-only fix rebuilds incrementally instead of from scratch.
- name: Restore toolchain build cache
id: cache
uses: actions/cache/restore@v4
with:
path: toolchain/rust-${{ inputs.minor }}/build
key: fullrust-build-${{ inputs.minor }}-${{ hashFiles(format('toolchain/patches/fullrust-{0}.patch', inputs.minor), format('toolchain/bootstrap-{0}.toml', inputs.minor)) }}
restore-keys: fullrust-build-${{ inputs.minor }}-
- name: Build the fullrust toolchain
working-directory: toolchain
run: ./build-fork.sh "${{ steps.ver.outputs.version }}"
# Saved even when the build step fails (e.g. a new version's overlay not
# compiling yet): LLVM + the compiler are the 1–2 h part, and keeping them
# makes the fix-and-rerun loop incremental via the restore-keys prefix.
- name: Save toolchain build cache
if: ${{ !cancelled() && steps.cache.outcome == 'success' && steps.cache.outputs.cache-hit != 'true' }}
uses: actions/cache/save@v4
with:
path: toolchain/rust-${{ inputs.minor }}/build
key: ${{ steps.cache.outputs.cache-primary-key }}
# Gate publishing on the built toolchain actually producing working
# binaries: build + run the core test crates for every fullrust target
# std was built for (unwind-only crates are skipped on panic=abort armv7).
- name: Run test crates (every target)
id: tests
working-directory: toolchain
run: |
set -euo pipefail
. ./targets.sh
targets="$(fr_sysroot_targets "rust-${{ inputs.minor }}/build/x86_64-unknown-linux-gnu/stage1" | paste -sd' ')"
echo "fullrust targets built: $targets"
echo "targets=$targets" >> "$GITHUB_OUTPUT"
./run-tests.sh "${{ inputs.minor }}" --target all
- name: Package stage1 + cargo
if: inputs.publish
working-directory: toolchain
run: ./docker/package-toolchain.sh "${{ inputs.minor }}" "$GITHUB_WORKSPACE/fullrust-toolchain-${{ inputs.minor }}-x86_64.tar.gz"
- name: Publish toolchain release asset
if: inputs.publish
uses: softprops/action-gh-release@v2
with:
tag_name: toolchain-${{ inputs.minor }}
name: fullrust toolchain ${{ inputs.minor }}
files: fullrust-toolchain-${{ inputs.minor }}-x86_64.tar.gz
body: |
Prebuilt fullrust stage1 toolchain (x86_64 Linux host rustc with
the built-in fullrust targets, the host sysroot + a fullrust sysroot
per target, rust-lld) and the bootstrap cargo, for Rust ${{ steps.ver.outputs.version }}
(overlay ${{ steps.ver.outputs.overlay }}).
Targets: ${{ steps.tests.outputs.targets }}.
Consumed by the `fullrust image` workflow to build
`ghcr.io/${{ github.repository_owner }}/fullrust`.
# A new toolchain asset is useless until it's in the image — rebuild that
# minor's image now rather than relying on someone remembering to.
- name: Rebuild this minor's image
if: inputs.publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run fullrust-image.yml -R "$GITHUB_REPOSITORY" --ref "$GITHUB_REF_NAME" -f minor="${{ inputs.minor }}"