RFC: enable split-object compilation for static build #109652
Draft
+14
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Create new adapter that passes extra flags through NIX_CFLAGS_COMPILE
and NIX_CFLAGS_LINK that instruct linker to eliminate unused symbols (as
opposed to unused objects).
Disk usage save varies greatly: pkgsStatic.mmh won a lot (9.4Mb -> 8.2Mb),
pkgsStatic.coreutils improvement is around 10Kb out of 9Mb.
This patch is imperfect and does not seem to cause rebuild of musl libc,
so improvement may be bigger. Another problem is that it breaks packages
that seems to do partial linkage, e.g busybox:
/nix/store/f7b0y2q80kgnqjkjmh7cng048wsy6mw9-x86_64-unknown-linux-musl-binutils-2.31.1/bin/x86_6
4-unknown-linux-musl-ld: gc-sections requires either an entry or an undefined symbol
collect2: error: ld returned 1 exit status
make[1]: *** [scripts/Makefile.build:264: applets/built-in.o] Error 1
make: *** [Makefile:372: applets_dir] Error 2
So I am looking for advice where and how to apply these changes.
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)