Skip to content

Select debug compression by linker capability#240

Merged
dpc merged 1 commit into
rustshop:masterfrom
dpc:dpc/jj-sqzoqwsromon
Jul 22, 2026
Merged

Select debug compression by linker capability#240
dpc merged 1 commit into
rustshop:masterfrom
dpc:dpc/jj-sqzoqwsromon

Conversation

@dpc

@dpc dpc commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Posted by Tau

Summary

Select compressed-debug formats according to each linker's declared capability. mkClangTarget keeps zstd as the default; only the four built-in Nixpkgs GNU/Linux cross targets explicitly use zlib because their target-prefixed ld.bfd builds reject zstd.

Details

Native Wild and mold accept zstd and remain on zstd. Custom and future mkClangTarget users also retain zstd by default and may explicitly select another supported format. Native Darwin behavior is unchanged.

The built-in non-native Linux cells use Nixpkgs target-prefixed GNU ld.bfd. Direct AArch64, i686, and RISC-V probes report zstd unsupported and zlib supported. Nixpkgs exposes no stable compression-capability attribute, so those four target definitions declare their known zlib requirement instead of inferring support or globally lowering the policy.

Enabling zstd in those BFD linkers would require rebuilding cross binutils and rewrapping each cross Clang toolchain. This change avoids that dependency/cache expansion while preserving zstd everywhere the selected linker supports it.

The focused check performs two real Cargo links:

  • native x86_64 through Wild with zstd;
  • x86_64→AArch64 through GNU BFD with zlib.

It verifies the exact linker/flag combinations, option acceptance, ELF architecture, and compressed .debug_info in both outputs. The check is independent of PR #239.

Reviewers can validate the change with nix develop -c selfci check --candidate sqzoqwsromon.

Select compressed-debug formats according to each linker’s declared capability instead of globally lowering the policy. `mkClangTarget` keeps zstd as its default, while the four built-in Nixpkgs GNU/Linux cross targets explicitly use zlib because their cross-binutils linkers lack zstd support. Add focused native Wild+zstd and x86_64-to-AArch64 BFD+zlib link coverage and document the behavior.

### Details

The built-in `mkClangTarget` inventory contains four Linux GNU targets and two native-only Darwin targets. A target matching the build architecture short-circuits through `mkNativeTarget`; non-native Linux cells use Nixpkgs target-prefixed GNU ld.bfd. Direct AArch64, i686, and RISC-V probes show those cross-binutils linkers reject zstd but accept zlib, while native Wild and mold accept zstd. Nixpkgs exposes no stable compression capability signal, so each built-in GNU cross target declares its known zlib policy explicitly rather than inferring support or globally lowering the default.

Custom and future `mkClangTarget` users retain zstd by default and can declare another supported format explicitly. Native Wild/mold remain on zstd, and Darwin native behavior remains unchanged. The x86_64-linux check performs real native and AArch64 Cargo links, ties each configured format to its selected linker, verifies linker acceptance and ELF architecture, and requires compressed `.debug_info` from both outputs.

The initial implementation and review used zlib for every `mkClangTarget`; user feedback identified that this degraded zstd-capable custom linkers. The capability-specific revision preserves zstd by default and limits zlib to the known-incompatible built-in cells. Independent re-review found no correctness, policy, test-quality, scope, or portability issues and returned PASS. Focused linker probes/builds, Linux and Darwin target evaluations, formatting, `nix flake check --no-build`, and `selfci check --candidate sqzoqwsromon` passed.
@dpc
dpc force-pushed the dpc/jj-sqzoqwsromon branch from 22dd6a1 to 3c2f1cf Compare July 22, 2026 07:12
@dpc dpc changed the title Fix debug compression for GNU cross linkers Select debug compression by linker capability Jul 22, 2026
@dpc
dpc merged commit f00197a into rustshop:master Jul 22, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant