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

significantly reduce size of bootstrap gcc and binutils #36383

Merged
merged 3 commits into from Nov 3, 2019

Conversation

dtzWill
Copy link
Member

@dtzWill dtzWill commented Mar 6, 2018

Removals:

  • gcc: drop LTO support in GCC
  • binutils: don't include support for "all targets"

stdenv bootstrap will build more feature-complete versions
of these anyway, and they require significant space.

On x86_64-musl bootstrap tarball, here's the difference:

  • compressed: 28M -> 20M
  • uncompressed: 201M -> 119M

Which brings them back to around what the sizes were
when I last generated the bootstrap tarball
(using gcc6, some time early 2018)

  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • 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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

I've tested the resulting bootstrap tools are sufficient for bootstrapping
a new stdenv, after which they shouldn't have any impact anyway :).

dtzWill added a commit to dtzWill/nixpkgs that referenced this pull request Mar 6, 2018
compressed: 28M -> 20M
uncompressed: 201M -> 119M

Built using:
NixOS@94f3dc4

cc NixOS#36383
@dtzWill dtzWill requested a review from dezgeg March 6, 2018 18:21
@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Partial log (click to expand)

/nix/store/cjhrjh6brgy1wahgbh5wqrflnb447bf8-cctools-binutils-darwin-wrapper
/nix/store/m81z2skf0g9pg8xv2lykq9l5sdxyi646-gcc-wrapper-7.3.0

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Partial log (click to expand)

  /nix/store/zqz10zwkg8szv3r6hh716rai9shgack3-isl-0.17.1
copying path '/nix/store/pxas4iymr7nmiw8v2f9dpdjc20n6c0dv-expand-response-params' from 'https://cache.nixos.org'...
copying path '/nix/store/02wdcrzydpjdgygrifgkkxi5qsl5866w-gcc-7.3.0-lib' from 'https://cache.nixos.org'...
copying path '/nix/store/zqz10zwkg8szv3r6hh716rai9shgack3-isl-0.17.1' from 'https://cache.nixos.org'...
copying path '/nix/store/0vj17gip63r5ix80qfjxixmjf3rpm6lh-mpfr-3.1.6' from 'https://cache.nixos.org'...
copying path '/nix/store/bnljkawp8gjg3jbn6kc9ja20byfxsg73-libmpc-1.1.0' from 'https://cache.nixos.org'...
copying path '/nix/store/mqv160qjigci73nwyfa9pk1a4aphlqnw-gcc-7.3.0' from 'https://cache.nixos.org'...
copying path '/nix/store/2amadx7k6dklsmjmp6bp4cby8jrg73ay-gcc-wrapper-7.3.0' from 'https://cache.nixos.org'...
/nix/store/3yiy9i2h9v3ff08qi81xlj97jgv8ycrw-binutils-wrapper-2.28.1
/nix/store/2amadx7k6dklsmjmp6bp4cby8jrg73ay-gcc-wrapper-7.3.0

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Partial log (click to expand)


fetching path ‘/nix/store/7ygz301k24r5jaii99rmi7rinjkwbplj-gcc-wrapper-7.3.0’...

*** Downloading ‘https://cache.nixos.org/nar/16xl9sbgylvgrb6l77zh9jc9lvqvhah8v5yywkdrwifknky873a5.nar.xz’ (signed by ‘cache.nixos.org-1’) to ‘/nix/store/7ygz301k24r5jaii99rmi7rinjkwbplj-gcc-wrapper-7.3.0’...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100  6824  100  6824    0     0   6824      0  0:00:01 --:--:--  0:00:01 13250

/nix/store/cmxaqb5cbzy4jk26na842n6hy1s4yn19-binutils-wrapper-2.28.1
/nix/store/7ygz301k24r5jaii99rmi7rinjkwbplj-gcc-wrapper-7.3.0

@dezgeg
Copy link
Contributor

dezgeg commented Mar 6, 2018

Hmm, I guess if we're recompiling GCC anyway, we should as well do it in a way to avoid this conditional: https://github.com/dtzWill/nixpkgs/blob/94f3dc4fdf0c6b32816d67f422d8220e9954c76e/pkgs/stdenv/linux/make-bootstrap-tools.nix#L145

@dtzWill
Copy link
Member Author

dtzWill commented Mar 6, 2018

Curiously we don't just link libisl statically, but also a few other things like libmpc, libgmp-- currently the references from our stdenv.cc.cc do not mention any of them.

Perhaps the conditional should be moved higher in the code? If they're not needed normally they probably aren't needed during bootstrap... :). At least not for gcc, which the position in the script suggests is what they're included for.

Also statically linking them during cross as well would be nice, but not sure I'd like to include fixing that in this (unless someone else has a good idea how to do it safely/properly?).

@dtzWill
Copy link
Member Author

dtzWill commented Apr 26, 2018

@dezgeg okay to merge as-is (without addressing the conditional inclusion of libisl)?

@dezgeg
Copy link
Contributor

dezgeg commented Apr 26, 2018

Seems ok I guess.

@dtzWill
Copy link
Member Author

dtzWill commented Apr 26, 2018

Haha, well it can wait for now :). It's not an urgent change for anything I'm doing at the moment, we can revisit when we have stronger motivation / time. Thanks!

@dtzWill
Copy link
Member Author

dtzWill commented Sep 26, 2018

Resolved conflicts and tweaked tarball generation to be smaller but not require more resources during decompression. Don't have updated numbers for this yet (rebuilding) but in other uses I've found it makes a small difference and doesn't take inordinate amount of time :).

@GrahamcOfBorg GrahamcOfBorg added the 6.topic: stdenv Standard environment label Sep 26, 2018
@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: binutils, gcc7

Partial log (click to expand)

these paths will be fetched (32.28 MiB download, 125.32 MiB unpacked):
  /nix/store/1py0m9bhz4jkszlffqbnksqdw1rf64d5-gcc-wrapper-7.3.0
  /nix/store/qgilx8bpva0d3jg99g53kr9swhjady8y-gcc-7.3.0
  /nix/store/z1f5fla70bjgmfp9pnzqp72lbzhsn3vl-gcc-7.3.0-lib
copying path '/nix/store/z1f5fla70bjgmfp9pnzqp72lbzhsn3vl-gcc-7.3.0-lib' from 'https://cache.nixos.org'...
copying path '/nix/store/qgilx8bpva0d3jg99g53kr9swhjady8y-gcc-7.3.0' from 'https://cache.nixos.org'...
copying path '/nix/store/1py0m9bhz4jkszlffqbnksqdw1rf64d5-gcc-wrapper-7.3.0' from 'https://cache.nixos.org'...
/nix/store/b0r9zqjypc5inqvs709770k221ksfi44-binutils-wrapper-2.30
/nix/store/1py0m9bhz4jkszlffqbnksqdw1rf64d5-gcc-wrapper-7.3.0

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: binutils, gcc7

Partial log (click to expand)

these paths will be fetched (20.75 MiB download, 97.30 MiB unpacked):
  /nix/store/8s60cvic2p87szj16bmz7mz1b5wdagi7-gcc-7.3.0
  /nix/store/9ha4n70sl6112j4wfpbimdi9xwncglwh-gcc-wrapper-7.3.0
  /nix/store/g3czn3wlv3xgs8icrm1mb0g9j7c1iarc-gcc-7.3.0-lib
copying path '/nix/store/g3czn3wlv3xgs8icrm1mb0g9j7c1iarc-gcc-7.3.0-lib' from 'https://cache.nixos.org'...
copying path '/nix/store/8s60cvic2p87szj16bmz7mz1b5wdagi7-gcc-7.3.0' from 'https://cache.nixos.org'...
copying path '/nix/store/9ha4n70sl6112j4wfpbimdi9xwncglwh-gcc-wrapper-7.3.0' from 'https://cache.nixos.org'...
/nix/store/jw3j4ljl6ggzwls5vj2qnykvqvml3cf1-binutils-wrapper-2.30
/nix/store/9ha4n70sl6112j4wfpbimdi9xwncglwh-gcc-wrapper-7.3.0

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: binutils, gcc7

Partial log (click to expand)

these paths will be fetched (0.01 MiB download, 0.02 MiB unpacked):
  /nix/store/icvmi8fyfykw8pkfi1shl3nhjwb0x0ni-binutils-wrapper-2.30
copying path '/nix/store/icvmi8fyfykw8pkfi1shl3nhjwb0x0ni-binutils-wrapper-2.30' from 'https://cache.nixos.org'...
/nix/store/icvmi8fyfykw8pkfi1shl3nhjwb0x0ni-binutils-wrapper-2.30
/nix/store/qidjv1minlnixkgxp61919id2hb71s4b-gcc-wrapper-7.3.0

@dtzWill
Copy link
Member Author

dtzWill commented Nov 2, 2018

Alright let's get this in. Thanks folks!
Edit: gah conflicts again. NVM.

@dtzWill
Copy link
Member Author

dtzWill commented Dec 31, 2018

Tagged this before updating, JIC: https://github.com/dtzWill/nixpkgs/releases/tag/pr36383-1

Apparently this option trades compression time for size,
and explicitly does so without increasing resources needed in decomp.

Doesn't make tarball creation unbearable, so add it to options!
@matthewbauer
Copy link
Member

@dtzWill What's the status of this PR?

@dtzWill
Copy link
Member Author

dtzWill commented Feb 4, 2019 via email

@mmahut
Copy link
Member

mmahut commented Aug 19, 2019

Are there any updates on this pull request, please?

@danbst
Copy link
Contributor

danbst commented Aug 21, 2019

@dtzWill nobody asked, so let me try: why? If this is only used for bootrstrap, why care then?

If this is for cases, when some new platform has to be boostrapped on an embedded device, then we can use cross tools on a powerful machine for this (and copy closure thereafter), right?

@dtzWill
Copy link
Member Author

dtzWill commented Oct 15, 2019

@dtzWill nobody asked, so let me try: why? If this is only used for bootrstrap, why care then?

If this is for cases, when some new platform has to be boostrapped on an embedded device, then we can use cross tools on a powerful machine for this (and copy closure thereafter), right?

Thank you, this is a good question that slightly caught me off-guard. Which is good 👍. Here's a few reasons I came up with:

  • Any change to any package used during "bootstrap" requires building from base bootstrap-- which currently is around 4 "stages" before rid of the beginning seed.
  • There are significant amount of folks building w/o trusting NixOS's binary cache (it would appear), and this is relevant to all of them
  • Bloat is bad no matter where it is found
  • The size increase addressed here happened after last time $NIXOS_BUILD_ORACLE built, years ago, the bootstrap tarballs commonly used. This PR fixes regressions introduced since then so any newly generated bootstrap (for trust or functionality reasons) doesn't require 2x the bits.
  • Bootstrap bits are trusted bits, fewer the better
  • Bootstrap bits (compressed) require longer to fetch and cost more to host, fewer the better

That's what I have now, anyone care to add or comment? (yes please)

@FRidh FRidh merged commit 43c721d into NixOS:master Nov 3, 2019
@c0bw3b
Copy link
Contributor

c0bw3b commented Nov 3, 2019

This is breaking ofBorg evals, as in #72660

trace: `mkStrict' is obsolete; use `mkOverride 0' instead.
trace: `lib.nixpkgsVersion` is deprecated, use `lib.version` instead!
trace: Warning: `showVal` is deprecated and will be removed in the next release, please use `traceSeqN`
trace: lib.zip is deprecated, use lib.zipAttrsWith instead
error: while evaluating the attribute 'constituents' of the derivation 'nixpkgs-20.03pre999999.ofborg' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-1-lassulus.ewr1.nix.ci/pkgs/build-support/trivial-builders.nix:7:14:
while evaluating the attribute 'buildCommand' of the derivation 'stdenv-bootstrap-tools' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-1-lassulus.ewr1.nix.ci/pkgs/stdenv/linux/make-bootstrap-tools.nix:197:5:
while evaluating the attribute 'buildCommand' of the derivation 'stdenv-bootstrap-tools' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-1-lassulus.ewr1.nix.ci/pkgs/stdenv/linux/make-bootstrap-tools.nix:48:7:
while evaluating anonymous function at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-1-lassulus.ewr1.nix.ci/lib/customisation.nix:77:32, called from /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-1-lassulus.ewr1.nix.ci/pkgs/stdenv/linux/make-bootstrap-tools.nix:36:13:
while evaluating 'makeOverridable' at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-1-lassulus.ewr1.nix.ci/lib/customisation.nix:67:24, called from /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-1-lassulus.ewr1.nix.ci/lib/customisation.nix:77:41:
anonymous function at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-1-lassulus.ewr1.nix.ci/pkgs/development/compilers/gcc/8/default.nix:1:1 called with unexpected argument 'enableLTO', at /var/lib/ofborg/checkout/repo/38dca4e3aa6bca43ea96d2fcc04e8229/mr-est/eval-1-lassulus.ewr1.nix.ci/lib/customisation.nix:69:16

@FRidh
Copy link
Member

FRidh commented Nov 3, 2019

fix in #72713

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants