roadmap BUILT

184. Extend the std port (milestone 27) to x86_64

Milestone 27 (std on the native ABI) is built for aarch64 and riscv64; this is the third architecture, following milestone 27's shape rather than re-deriving it. It needed no design fork: the shape was already built twice.

What was built

The target spec, and why each field differs from x86_64-unknown-none

It is the built-in x86_64-unknown-none spec with the kernel's assumptions taken out:

Field Chosen Why
code-model small The built-in kernel model assumes every symbol is in the top 2 GiB. A program linked at 0x40_0000 is not. It links anyway, because a low address also fits a sign-extended 32-bit displacement, which is why the no_std programs built on x86_64-unknown-none work; small is the model whose assumption is true.
relocation-model static, no PIE The kernel's ELF loader maps at link addresses and applies no relocations. The built-in spec defaults to static-PIE, which .cargo/config.toml overrides by flag for the no_std programs; here it is in the spec, as on the other two nife targets.
features -mmx,-sse,...,+soft-float Copied. A correctness requirement: kernel/src/arch/x86_64/ saves no FPU or SSE state on a context switch.
rustc-abi softfloat Copied. Current nightlies refuse a soft-float x86 custom target without it.
disable-redzone, data-layout, llvm-target, stack-probes, plt-by-default unchanged Copied from the built-in spec.
os, singlethread, executables, metadata.std as the other two nife specs "os": "nife" is what selects the PAL through every dispatcher.

What it delivered, measured

std_exerciser passes on x86_64, where it used to skip: kernel::user::std_tests::a_whole_std_program_runs_on_the_native_abi ... ok, under QEMU's PVH loader and again under OVMF firmware. The full gate is green on all three architectures: aarch64 321 passed, 2 skipped; riscv64 328 passed, 1 skipped; x86_64 206 passed, 69 skipped, in 275 tests. One test moved from the skip column to the pass column (std_exerciser), and one entered the skip column (ripgrep_tests, newly compiled on x86_64; see BUGS).

The pass is evidence, because breaking the arm turns it red. Swapping the x86_64 invoke arm's result register from rdi to rsi and rerunning only that test fails it with std_exerciser: a sink message the contract does not define: 0x10000000.

Soft-float is checked with a program that does float work, because zero xmm in std_exerciser would prove nothing: it does no float arithmetic. A probe doing f64 and f32 arithmetic, built for x86_64-unknown-nife, disassembles to 0 instructions naming an xmm, mm or x87 register and 9 calls into __adddf3, __muldf3, __divdf3, __subdf3, __mulsf3 and __floatundidf. The same probe against a copy of the spec with +sse,+sse2 and no rustc-abi has 92 vector-register instructions and no helper calls. The grep and the control are in notes/std/x86-64-target.md.

The abort sweep holds on three targets: std-aborts: 26 process-ending bodies across 82 compiled std sources, all accounted for.

Unmodified ripgrep 14.1.1 builds for x86_64-unknown-nife with zero source changes: a 4.1 MB ELF (4,147,048 bytes), against 4.7 MB on aarch64 and 10.7 MB on riscv64. It does not run on x86_64 yet; see BUGS.

The entry point is the one real divergence

The kernel enters ring 3 with rsp on a page boundary, so rsp % 16 == 0, while the x86-64 psABI promises a function rsp % 16 == 8, as if a call had pushed a return address. aarch64 and RISC-V push nothing on a call and have no such offset. So on x86_64 _start is a global_asm! stub that calls the Rust entry and then ud2s, which makes the psABI's assumption true. Without SSE nothing faults on a misaligned stack, so getting this wrong would have passed every test and stayed latent until someone enabled a vector feature.

fs, net and thread on x86_64

x86_64 Why
allocation, stdio, Instant, SystemTime, SystemRng, env, process::exit wired and exercised std_exerciser's transcript is byte-identical to the other two architectures'
std::fs compiled, unexercised The PAL has nothing architecture-specific in it. What is missing is a disk: fs_service::wire_servers finds its RedoxFS disk with virtio::find_block_device_n, which is virtio-mmio only, and q35 has no virtio-mmio bus; no x86_64 runner attaches a RedoxFS image either
std::net compiled, unexercised The x86_64 runner attaches no NIC
thread::spawn Unsupported The same on every architecture: DECISIONS ยง105 declined it until a customer needs it

A program that is granted neither a directory nor a network gets Unsupported from both on x86_64, exactly as on the other two, and that is asserted: those are two lines of the transcript that passes.

BUGS

Follow-on

Prior art

Milestone 27's two targets and notes/std.md, copied rather than re-derived. Hermit, milestone 27's citation, applies identically.

Index row

std on x86_64: x86_64-unknown-nife (small code model, static, soft-float with no SSE state), the PAL's x86_64 arms, and std_exerciser passing under QEMU where it used to skip, falsified by breaking an arm. std::fs/std::net compile but have no server device on x86_64; unmodified ripgrep builds and waits on a RedoxFS disk there.