forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
421 lines (373 loc) · 15.5 KB
/
Copy pathfork-arm64e.yml
File metadata and controls
421 lines (373 loc) · 15.5 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
name: Fork arm64e validation
# Fork-only CypherAir validation. Drop this workflow before proposing the
# upstreamable arm64e core to rust-lang/rust.
on:
workflow_dispatch:
push:
branches:
- codex/arm64e-upstream-prep-2026-04-24
pull_request:
branches:
- main
permissions:
contents: read
concurrency:
group: fork-arm64e-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
arm64e:
if: github.repository == 'cypherair/rust'
strategy:
fail-fast: false
matrix:
include:
- runner_label: macos-15
runner_name: macos-15
- runner_label: macos-26
runner_name: macos-26
name: arm64e targeted validation (${{ matrix.runner_name }})
runs-on: ${{ matrix.runner_label }}
timeout-minutes: 240
defaults:
run:
shell: bash
steps:
- name: Checkout source
uses: actions/checkout@v5
with:
fetch-depth: 2
submodules: recursive
# CypherAir fork push runs reproduced a shallow-clone case where bootstrap could not
# safely treat HEAD^1 as the upstream nightly base commit. Keep this in sync with src/stage0.
- name: Fetch nightly base ref
run: |
git fetch --no-tags --prune --depth=1 origin \
+refs/heads/main:refs/remotes/origin/main
- name: Show environment
run: |
mkdir -p /tmp/arm64e-diagnostics
{
echo "github.event_name=${GITHUB_EVENT_NAME}"
echo "runner_label=${{ matrix.runner_name }}"
sw_vers
uname -a
sysctl -n kern.osproductversion kern.osversion
sysctl -n machdep.cpu.brand_string 2>/dev/null || true
git show -s --format='HEAD: %H %P %ae %s' HEAD
git show -s --format='origin/main: %H %P %ae %s' refs/remotes/origin/main
python3 --version
clang --version
rustc -vV || true
} | tee /tmp/arm64e-diagnostics/runner-fingerprint.txt
- name: Check arm64e codegen crates
id: check_codegen
run: |
python3 x.py check compiler/rustc_codegen_ssa compiler/rustc_codegen_llvm --stage 1
- name: Run targeted arm64e tests
id: targeted_tests
run: |
python3 x.py test --stage 1 --force-rerun \
tests/codegen-llvm/arm64e-apple-ptrauth.rs \
tests/codegen-llvm/arm64e-apple-ptrauth-calls.rs \
tests/codegen-llvm/arm64e-apple-ptrauth-fnptr-data.rs \
tests/codegen-llvm/arm64e-apple-ptrauth-invoke.rs \
tests/assembly-llvm/arm64e-apple-ptrauth-calls.rs \
tests/assembly-llvm/targets/targets-macho.rs \
tests/ui/compile-flags/invalid/branch-protection-arm64e-apple-pac-ret.rs \
tests/ui/compile-flags/invalid/target-feature-arm64e-apple-ptrauth-disable.rs
- name: Build stage1 arm64e std toolchain
id: build_stage1
run: |
python3 x.py build compiler/rustc library/std --stage 1 --target arm64e-apple-darwin
- name: Prepare arm64e smoke helpers
run: |
mkdir -p /tmp/arm64e-diagnostics
cat > /tmp/arm64e_collect_smoke.py <<'PY'
import argparse
import json
import pathlib
import re
import subprocess
import sys
def run_capture(cmd, timeout=None):
proc = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
return {
"cmd": cmd,
"returncode": proc.returncode,
"signal": -proc.returncode if proc.returncode < 0 else None,
"stdout": proc.stdout,
"stderr": proc.stderr,
}
def load_text(path):
try:
return pathlib.Path(path).read_text()
except FileNotFoundError:
return None
parser = argparse.ArgumentParser()
parser.add_argument("--name", required=True)
parser.add_argument("--rustc", required=True)
parser.add_argument("--source", required=True)
parser.add_argument("--output-base", required=True)
parser.add_argument("--json-out", required=True)
parser.add_argument("--target", default="arm64e-apple-darwin")
parser.add_argument("--emit", default="link")
parser.add_argument("--run-binary", action="store_true")
parser.add_argument("--expected-stdout")
parser.add_argument("--expected-stdout-regex")
parser.add_argument("--asm-pattern")
args = parser.parse_args()
output_base = pathlib.Path(args.output_base)
compile_cmd = [
args.rustc,
args.source,
"--target",
args.target,
"-O",
"--emit",
args.emit,
"-o",
str(output_base),
]
payload = {
"name": args.name,
"target": args.target,
"emit": args.emit,
"compile": run_capture(compile_cmd),
"output_base": str(output_base),
"paths": {
"source": args.source,
"binary": str(output_base),
"asm": str(output_base.with_suffix(".s")),
"ir": str(output_base.with_suffix(".ll")),
},
}
overall_ok = payload["compile"]["returncode"] == 0
if overall_ok:
payload["file"] = run_capture(["/usr/bin/file", str(output_base)])
else:
payload["file"] = None
asm_path = output_base.with_suffix(".s")
asm_text = load_text(asm_path)
if asm_text is not None and args.asm_pattern:
payload["asm_matches"] = re.findall(args.asm_pattern, asm_text)
else:
payload["asm_matches"] = []
if args.run_binary and overall_ok:
payload["run"] = run_capture([str(output_base)], timeout=30)
if payload["run"]["returncode"] != 0:
overall_ok = False
stdout = payload["run"]["stdout"]
if args.expected_stdout is not None:
if stdout.rstrip("\n") != args.expected_stdout.rstrip("\n"):
payload["stdout_mismatch"] = {
"expected": args.expected_stdout,
"actual": stdout,
}
overall_ok = False
if args.expected_stdout_regex is not None:
if re.fullmatch(args.expected_stdout_regex, stdout.strip()) is None:
payload["stdout_regex_mismatch"] = {
"expected_regex": args.expected_stdout_regex,
"actual": stdout,
}
overall_ok = False
else:
payload["run"] = None
json_path = pathlib.Path(args.json_out)
json_path.write_text(json.dumps(payload, indent=2, sort_keys=True))
print(f"== {args.name} compile ==")
print(f"returncode={payload['compile']['returncode']}")
if payload["compile"]["stdout"]:
print("-- stdout --")
print(payload["compile"]["stdout"], end="")
if payload["compile"]["stderr"]:
print("-- stderr --")
print(payload["compile"]["stderr"], end="")
if payload["file"] is not None:
print("== file ==")
print(payload["file"]["stdout"], end="")
if payload["run"] is not None:
print("== run ==")
print(f"returncode={payload['run']['returncode']}")
if payload["run"]["signal"] is not None:
print(f"signal={payload['run']['signal']}")
print("-- stdout --")
print(payload["run"]["stdout"], end="")
print("-- stderr --")
print(payload["run"]["stderr"], end="")
if payload["asm_matches"]:
print("== asm matches ==")
for match in payload["asm_matches"]:
print(match)
sys.exit(0 if overall_ok else 1)
PY
- name: Diagnose arm64e hello runtime
id: hello_diag
continue-on-error: true
run: |
HOST_TRIPLE="$(rustc -vV | sed -n 's/^host: //p')"
STAGE1="build/${HOST_TRIPLE}/stage1/bin/rustc"
cat > /tmp/arm64e-diagnostics/arm64e_hello.rs <<'EOF'
fn main() {
println!("hello-stage1");
}
EOF
python3 /tmp/arm64e_collect_smoke.py \
--name hello \
--rustc "$STAGE1" \
--source /tmp/arm64e-diagnostics/arm64e_hello.rs \
--output-base /tmp/arm64e-diagnostics/arm64e_hello \
--json-out /tmp/arm64e-diagnostics/arm64e_hello.json \
--emit link \
--run-binary \
--expected-stdout 'hello-stage1'
- name: Diagnose arm64e thread id runtime
id: thread_id_diag
continue-on-error: true
run: |
HOST_TRIPLE="$(rustc -vV | sed -n 's/^host: //p')"
STAGE1="build/${HOST_TRIPLE}/stage1/bin/rustc"
cat > /tmp/arm64e-diagnostics/arm64e_thread_id.rs <<'EOF'
fn main() {
println!("{:?}", std::thread::current().id());
}
EOF
python3 /tmp/arm64e_collect_smoke.py \
--name thread_id \
--rustc "$STAGE1" \
--source /tmp/arm64e-diagnostics/arm64e_thread_id.rs \
--output-base /tmp/arm64e-diagnostics/arm64e_thread_id \
--json-out /tmp/arm64e-diagnostics/arm64e_thread_id.json \
--emit link \
--run-binary \
--expected-stdout-regex '^ThreadId\([0-9]+\)$'
- name: Diagnose arm64e function pointer runtime
id: fnptr_diag
continue-on-error: true
run: |
HOST_TRIPLE="$(rustc -vV | sed -n 's/^host: //p')"
STAGE1="build/${HOST_TRIPLE}/stage1/bin/rustc"
cat > /tmp/arm64e-diagnostics/arm64e_fnptr.rs <<'EOF'
#[inline(never)]
pub extern "C" fn target(x: i32) -> i32 { x + 1 }
fn main() {
let f: extern "C" fn(i32) -> i32 = target;
println!("{}", f(41));
}
EOF
python3 /tmp/arm64e_collect_smoke.py \
--name fnptr \
--rustc "$STAGE1" \
--source /tmp/arm64e-diagnostics/arm64e_fnptr.rs \
--output-base /tmp/arm64e-diagnostics/arm64e_fnptr \
--json-out /tmp/arm64e-diagnostics/arm64e_fnptr.json \
--emit llvm-ir,asm,link \
--run-binary \
--expected-stdout '42' \
--asm-pattern 'braaz|blraaz|blr'
echo "LLVM IR excerpt:"
sed -n '1,40p' /tmp/arm64e-diagnostics/arm64e_fnptr.ll || true
echo
echo "Assembly excerpt:"
sed -n '1,40p' /tmp/arm64e-diagnostics/arm64e_fnptr.s || true
- name: Diagnose arm64e TLS runtime
id: tls_diag
continue-on-error: true
run: |
HOST_TRIPLE="$(rustc -vV | sed -n 's/^host: //p')"
STAGE1="build/${HOST_TRIPLE}/stage1/bin/rustc"
cat > /tmp/arm64e-diagnostics/arm64e_tls_smoke.rs <<'EOF'
use std::cell::RefCell;
fn main() {
thread_local! {
static S: RefCell<String> = RefCell::default();
}
S.with(|x| *x.borrow_mut() = "pika pika".to_string());
S.with(|x| println!("{}", x.borrow()));
}
EOF
python3 /tmp/arm64e_collect_smoke.py \
--name tls \
--rustc "$STAGE1" \
--source /tmp/arm64e-diagnostics/arm64e_tls_smoke.rs \
--output-base /tmp/arm64e-diagnostics/arm64e_tls_smoke \
--json-out /tmp/arm64e-diagnostics/arm64e_tls_smoke.json \
--emit llvm-ir,asm,link \
--run-binary \
--expected-stdout 'pika pika' \
--asm-pattern 'braaz|blraaz|blr'
echo "LLVM IR excerpt:"
sed -n '1,40p' /tmp/arm64e-diagnostics/arm64e_tls_smoke.ll || true
echo
echo "Assembly excerpt:"
sed -n '1,60p' /tmp/arm64e-diagnostics/arm64e_tls_smoke.s || true
- name: Upload arm64e diagnostics
if: always()
uses: actions/upload-artifact@v4
with:
name: arm64e-diagnostics-${{ matrix.runner_name }}
if-no-files-found: ignore
path: /tmp/arm64e-diagnostics
- name: Summarize arm64e validation
if: always()
run: |
python3 - <<'PY' >> "$GITHUB_STEP_SUMMARY"
import json
import pathlib
root = pathlib.Path("/tmp/arm64e-diagnostics")
cases = [
("hello", "arm64e_hello.json"),
("thread_id", "arm64e_thread_id.json"),
("fnptr", "arm64e_fnptr.json"),
("tls", "arm64e_tls_smoke.json"),
]
def sanitize(text):
if text is None:
return ""
text = text.strip()
if not text:
return ""
return text.replace("|", "\\|").replace("\n", "<br>")
print("## arm64e validation (${{ matrix.runner_name }})")
print()
print("- check_codegen: ${{ steps.check_codegen.outcome }}")
print("- targeted_tests: ${{ steps.targeted_tests.outcome }}")
print("- build_stage1: ${{ steps.build_stage1.outcome }}")
print("- hello_diag (non-blocking): ${{ steps.hello_diag.outcome }}")
print("- thread_id_diag (non-blocking): ${{ steps.thread_id_diag.outcome }}")
print("- fnptr_diag (non-blocking): ${{ steps.fnptr_diag.outcome }}")
print("- tls_diag (non-blocking): ${{ steps.tls_diag.outcome }}")
print()
print("| case | compile | run | rc/signal | file | stdout | asm hits |")
print("| --- | --- | --- | --- | --- | --- | --- |")
for case_name, json_name in cases:
path = root / json_name
if not path.exists():
print(f"| {case_name} | missing | missing | | | | |")
continue
data = json.loads(path.read_text())
compile_status = "ok" if data["compile"]["returncode"] == 0 else "fail"
run = data.get("run")
if run is None:
run_status = "not-run"
rc_signal = ""
stdout = ""
else:
run_status = "ok" if run["returncode"] == 0 else "fail"
rc_signal = f"rc={run['returncode']}"
if run.get("signal") is not None:
rc_signal += f" sig={run['signal']}"
stdout = sanitize(run.get("stdout"))
file_output = sanitize((data.get("file") or {}).get("stdout"))
asm_hits = sanitize(",".join(data.get("asm_matches") or []))
print(
f"| {case_name} | {compile_status} | {run_status} | {sanitize(rc_signal)} | "
f"{file_output} | {stdout} | {asm_hits} |"
)
print()
print("The four host-binary smoke steps are non-blocking diagnostics for fork runner coverage; targeted tests and stage1 build remain blocking.")
PY
{
echo "Smoke diagnostic JSON files:"
ls -1 /tmp/arm64e-diagnostics/*.json
}