Skip to content

Commit 8b79ff9

Browse files
riccajasonclaude
andcommitted
arch: gate x86_64 syscall_entry asm out of cfg(test)
What: src/arch/x86_64/syscall.rs: the global_asm! defining `syscall_entry` was gated `#[cfg(not(fuzzing))]`; widen to `#[cfg(not(any(fuzzing, test)))]` so it matches its four sibling asm blocks and is excluded under `cargo test`. Why: Under `cargo test` the crate already compiles a host shim, `#[cfg(any(fuzzing, test))] mod fuzz_asm_stubs`, which provides a `#[no_mangle] syscall_entry` stub. The real global_asm being gated only `not(fuzzing)` meant it stayed compiled under test too, so `syscall_entry` had two definitions. On Mach-O the leading-underscore symbol convention separated them (`syscall_entry` asm vs `_syscall_entry` stub), so `cargo test --target x86_64-apple-darwin` linked fine and the bug stayed hidden. On ELF there is no underscore: the first CI run on a Linux runner failed to link the lib-test binary with `rust-lld: error: duplicate symbol: syscall_entry`. The four sibling asm blocks (context_switch, timer_isr_stub, yield_save_and_switch, gdt_reload_segments) were already `not(any(fuzzing, test))`; this was the lone block missing `test`, which is why the linker reported exactly one duplicate. Behaviorally inert for the shipping kernel: in a real build (not test, not fuzzing) the cfg still evaluates true and the asm is compiled, identical to before. Only the test build changes -- it now defers to the existing no-op stub, exactly as the other four symbols already do. Out of scope: No change to the syscall ABI, the asm body, or any SAFETY contract; only the cfg predicate widens. Verification: - make check-all -> all three architectures build cleanly - cargo test --lib --target x86_64-apple-darwin -> 892 passed; 0 failed - the ELF lib-test link (the original CI failure) is confirmed by the next CI run Staged files: src/arch/x86_64/syscall.rs Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 159c06e commit 8b79ff9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/arch/x86_64/syscall.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ pub unsafe fn init() {
132132
// RBX, RBP, R12-R15 (callee-saved)
133133
// SyscallFrame ← RSP points here when handler is called
134134

135-
#[cfg(not(fuzzing))]
135+
#[cfg(not(any(fuzzing, test)))]
136136
core::arch::global_asm!(
137137
".global syscall_entry",
138138
"syscall_entry:",

0 commit comments

Comments
 (0)