kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

System-linker compatibility

This roadmap tracks the remaining linker work needed for kit ld to act as the system linker over kit's supported target set. The near-term driver is Rust using kit ld through rustc, but the target is broader: C, Rust, assembler objects, archives, DSOs/dylibs/import libraries, PIE executables, shared libraries, and relocatable links should all behave like the platform linker for the supported arch/OS pairs.

Related: LINKER.md, ../LINK.md, ../OBJ.md, ../DRIVER.md, SYSROOTS.md.

Scope

The support set is format-driven:

The linker should preserve format boundaries. ELF --as-needed and TLSDESC rules must not leak into Mach-O dylib or COFF import-library semantics. COFF's archive search behavior, Mach-O atom/GOT/TLV behavior, and ELF dynamic-section rules stay target-specific policy behind shared object and relocation APIs.

Current state

The Rust-driven compatibility pass established these paths:

This is a useful system-linker subset, not completion. The open work below is the gap between "Rust examples link" and "the platform linker can be replaced over the support set."

Workstreams

1. Ordered input and dependency selection

ELF --as-needed must become real linker semantics, not a driver/script special case.

The linker needs to model, per ordered DSO input:

ELF behavior:

GNU linker scripts should lower into the same ordered input model:

Mach-O and COFF need separate parity checks rather than ELF semantics:

2. ELF TLS model planning

ELF TLS must be planned before final relocation application and dynamic-section synthesis. The planner should classify each TLS relocation or relocation sequence by:

The action should be explicit:

This pass should own the decision; architecture code should own only the instruction byte rewrite once a sequence has been validated.

3. TLSDESC completion

The current AArch64 TLSDESC path accepts Rust/LLVM executable-local cases by relaxing the four instruction relocations to materialize the local-exec offset. Full TLSDESC support needs more:

Imported TLSDESC references are real DSO uses and must select their provider under --as-needed.

4. Architecture relocation and relaxation parity

Each supported architecture needs both relocation coverage and checked relaxations for the code shapes produced by modern toolchains.

Open areas include:

Relocation tests should pin both the descriptor table and representative byte patches so enum additions are covered immediately.

5. Shared libraries and relocatable links

Replacing a system linker requires more than executable links:

The near-term Rust path mostly exercises final executables; shared-library and relocatable coverage should be broadened deliberately.

6. Runtime/sysroot interoperability

System-linker replacement depends on finding the same runtime inputs as the platform toolchain:

The driver should prefer explicit command-line inputs, then sysroot/target layout, and finally host defaults only where that is safe. Runtime validation should distinguish linker failure from a too-minimal test container, such as an Alpine image missing libgcc_s.so.1.

7. Diagnostics and tracing

The linker needs precise diagnostics for unsupported system-linker cases:

Use KIT_TRACE for opt-in structured tracing. Do not add global state.

Validation matrix

For each supported arch/OS/libc family, track these lanes:

The first priority remains the verified Rust support set, because it is a good system-linker driver and produces real toolchain objects. The second priority is small focused fixtures for every feature above, so failures are explainable and do not depend on large external runtimes.

Acceptance criteria

kit ld is complete enough to be the system linker for a target when: