Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/heimdall

xtask/libc-build/README.md

libc-build: one recipe for glibc, musl and Eyra

cargo xtask libc-build --libc glibc|musl|eyra <crate dir> [--static] [--debug limited] [--panic abort] [--out dir] [--jobs n]

It builds the binary of the package in <crate dir> against the C library the one flag names and prints <sha256> <binary> on stdout. Everything runs in the toolchain container from Containerfile (podman); the xtask builds that image (tag = sha256 of the Containerfile and the patches), copies the workspace (without target and .git) to <out>/src, runs cargo there, then checks and hashes the ELF on the host. Default <out> is target/libc-build/<package>-<libc> in this repository; <out>/cargo-home is the cargo home.

--libc target RUSTFLAGS std the result must be
glibc x86_64-unknown-linux-gnu none (--static: -C target-feature=+crt-static) prebuilt dynamic: PT_INTERP + DT_NEEDED; --static: neither
musl x86_64-unknown-linux-musl none prebuilt no PT_INTERP, no DT_NEEDED, no glibc markers
eyra x86_64-unknown-linux-gnu -C relocation-model=static -C target-feature=+crt-static -C llvm-args=-enable-tail-merge=false -C llvm-args=-opt-disable=tailcallelim -Z merge-functions=disabled -Z plt=yes -Zbuild-std=std,core,alloc,panic_abort,test ET_EXEC (non-PIE), no PT_INTERP, no DT_NEEDED, no glibc markers (GLIBC_TUNABLES, __libc_start_main, GLIBC_2.)

All three use the same compiler: nightly-2026-10-05 (the one Mímir's driver pins). --debug and --panic set CARGO_PROFILE_RELEASE_DEBUG / CARGO_PROFILE_RELEASE_PANIC; RUSTFLAGS stay as above. The code is xtask/src/libc_build.rs: a trait LibcBuild (toolchain, target, rustflags, build-std, Cargo patches, lock pins, features, check) with Glibc, Musl and Eyra.

Eyra disables tail merging so separate source calls retain separate call instructions. It disables tail-call elimination so final calls in compiled Rust code remain calls; rustc's allocator shims and assembly keep their jumps. Six direct tail jumps remain in the pinned program: four allocator shims and two assembly jumps. It disables function merging so distinct functions retain distinct addresses. -Z plt=yes avoids calls through GOT words in this static executable. A nightly update must check all four switches again.

On the pinned nightly, -opt-disable=tailcallelim (S2) also prints pass diagnostics: about 1.4 GB in the pinned program build. Every cargo xtask libc-build --libc eyra run inherits this output into the terminal or CI log; its size depends on the program.

These switches reach every target crate, including core and std, because the recipe rebuilds std from source with -Zbuild-std and an explicit --target. They do not apply to host build scripts or proc macros, or to C code compiled by a build script.

For a subsequent build, use the entire RUSTFLAGS line printed by the xtask. Cargo reads CARGO_ENCODED_RUSTFLAGS before RUSTFLAGS, and either environment setting takes precedence over rustflags in .cargo/config.toml. Clear CARGO_ENCODED_RUSTFLAGS when using the printed RUSTFLAGS; adding these switches only to config while RUSTFLAGS is set silently loses them.

Eyra: what the recipe fixes, so nobody finds it again

Open sites: a call whose number is not a constant at the call, so a static graph cannot name it:

Site Patch Why it stays
syscall(SYS_io_uring_setup/_register/_enter): raw_syscall_errno(number, a) 01 io_uring is opt-in (feature syscall-io_uring) and no crate of Holger's build calls it

The real arm64 kernel's answers are open too: the aarch64 arms are compiled and linked, and checked only under qemu-user until there is an arm64 host.

Known arm64 gaps (x86-64 only after 06; their arm64 work is a later pair):

Part Patch Call site On aarch64
clone (its own x86-64 asm: the child's stack, fn(arg), SYS_exit) 02 libcontainer process/fork.rs, the fallback when clone3 gives ENOSYS: every container start not defined: a program that calls it does not link
syscall(SYS_io_uring_setup/_register/_enter) (its own x86-64 asm, raw_syscall_errno) 01 heimdall-broker's heimdall-broker-selftest (not in Holger's build) not listed: the call panics

The program must opt in to Eyra itself: either a cargo feature eyra (eyra = ["dep:eyra"], an optional eyra = { version = "0.22", features = ["extra-syscalls"] }, #[cfg(feature = "eyra")] extern crate eyra; in main.rs and a build.rs that prints cargo:rustc-link-arg=-nostartfiles when CARGO_FEATURE_EYRA is set), or a plain eyra dependency. The xtask turns the feature on for --libc eyra and refuses a package with neither.

Lane knobs: LIBC_BUILD_PODMAN_ARGS adds podman run flags (for example --cpu-shares 64); the build runs under nice -n 19 with --memory 32g --pids-limit=65536.