Debugging Wild Linker on Illumos: A Journey Through ELF, DTrace and Kernel Internals
Share this article
In the relentless pursuit of faster build times, Wild has emerged as a compelling open-source linker alternative to LLD and Mold, promising dramatic speed improvements—like linking Clang in just 120ms. However, when developer Daniel Levin attempted to integrate Wild into his Rust workflow on Illumos (a Solaris derivative), he encountered a baffling obstacle: binaries linked with Wild immediately crashed with SIGKILL errors, while those from GNU ld worked flawfully. This sent him down a rabbit hole of systems debugging, exposing subtle OS-specific constraints.
The Illumos Enigma
Levin's journey began when Wild's test suite failed catastrophically on Illumos—only 10 of 77 integration tests passed. The culprit was a recurring SIGKILL signal killing programs at launch. Initial analysis with GDB proved futile:
(gdb) b _start
Breakpoint 1 at 0x401374
(gdb) r
During startup program terminated with signal SIGKILL, Killed.
Binary comparisons showed no obvious defects, pushing Levin to leverage Illumos' powerful DTrace toolkit.
DTrace to the Rescue
Using DTrace's signal-send probe, Levin traced the SIGKILL origin:
❯ sudo dtrace -n 'proc:::signal-send /args[2] == 9/ { stack(); }'
genunix`psignal+0x34
elfexec`elfexec+0x480
The stack trace pointed to elfexec+0x480 in the kernel's ELF loader. Without debug symbols, Levin audited the Illumos kernel source, discovering a strict validation rule: binaries with a PHDR program header must include a PT_INTERP header. Wild’s output violated this:
❯ readelf -l wild-linked-binary
Program Headers:
PHDR 0x40 R 0x8
LOAD 0x0 R 0x1000
LOAD 0x370 R E 0x1000
GNU_STACK 0x0 RW 0x10
Linux tolerates this configuration, but Illumos deems it invalid and kills the process.
Fixing the Toolchain
Levin submitted a kernel workaround and turned to Rust integration. Directly specifying Wild via rustflags failed due to Clang's Illumos driver quirks:
[target.x86_64-unknown-illumos]
linker = "clang"
rustflags = ["-C", "link-arg=--ld-path=/path/to/wild"] // Silently ignored
He patched Clang’s driver to accept --ld-path and modified Wild to support Illumos’ elf_x86_64_sol2 emulation. Final configuration:
rustflags = ["-C", "link-arg=--ld-path=/home/omnios/.cargo/bin/wild"]
This enabled Wild to link functional Rust binaries, confirmed via .comment section checks.
Broader Implications
This saga underscores the hidden complexities of cross-platform linking. While Wild delivers exceptional speed, its Linux-centric assumptions clash with Illumos’ strict ELF enforcement. Levin’s fixes—submitted as PR #163000 to Clang—aim to simplify future porting. For developers, it highlights DTrace’s unparalleled debugging power and the value of venturing beyond the "Linux monoculture" to uncover systemic blind spots. As Levin reflects, 'It took just 15 minutes to pinpoint the kernel issue with DTrace—a testament to observability tools done right.'
Source: Daniel Levin via roci.co.za