Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: enable split-object compilation for static build #109652

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KAction
Copy link
Contributor

@KAction KAction commented Jan 17, 2021

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:

GEN     include/applet_tables.h include/NUM_APPLETS.h
HOSTCC  applets/usage_pod
CC      applets/applets.o
LD      applets/built-in.o

/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
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@ofborg ofborg bot added the 6.topic: stdenv Standard environment label Jan 17, 2021
@SuperSandro2000 SuperSandro2000 marked this pull request as draft January 17, 2021 18:03
@SuperSandro2000
Copy link
Member

I marked this as a draft to not accidentally merge it and break busybox. Feel free to undraft it when you think it is ready.

@stale
Copy link

stale bot commented Jul 21, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 21, 2021
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:

    GEN     include/applet_tables.h include/NUM_APPLETS.h
    HOSTCC  applets/usage_pod
    CC      applets/applets.o
    LD      applets/built-in.o
  /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.
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 29, 2021
@stale
Copy link

stale bot commented Apr 27, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: stdenv Standard environment 10.rebuild-darwin: 0 10.rebuild-linux: 0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants