gcc: for cross compilers, don't build libgcc twice#249682
Merged
Conversation
Cross-compiled binaries currently end up with two different libgcc outpaths in their closure. This is harmless, but confusing. The two libgccs are: - One of them is the "first" targetPlatform libgcc, which is built by the "first" cross-compiler. This "first libgcc" and "first compiler" are used to build the targetPlatform glibc. - Once glibc is built, we *rebuild* the cross-compiler, since gcc can't enable most of its features unless you give it an already-compiled targetPlatform glibc. When this "second" compiler is built, it also builds an extra copy of libgcc. This commit discards the second, extra libgcc, and instead puts a reference to the first (correct) libgcc into the "second compiler" `.passthru.libgcc`, so that anybody expecting `stdenv.cc.cc.libgcc` to exist will still find it there. Closes #249680
Member
|
before: $ nix path-info -rsSh $(chase result) | LC_ALL=C sort -hk3
/nix/store/ryg2qa9qmzgv3gbj5x1s3ngj9an4dlir-libgcc-aarch64-unknown-linux-gnu-12.3.0 535.6K 535.6K
/nix/store/20x7c06lpvkzzaz5gif7qv3slj8js13g-linux-headers-6.4 6.0M 6.0M
/nix/store/zb4kxl0a6mmb456jb82c8250yk337hpp-glibc-aarch64-unknown-linux-gnu-2.37-8 39.5M 40.0M
/nix/store/15dk0vg596r9s4qnbhdrv8f17j85d6m1-glibc-aarch64-unknown-linux-gnu-2.37-8-bin 2.9M 42.9M
/nix/store/ks5pfn0i1hhg0lyvg3vs9w4ss34074d2-ncurses-aarch64-unknown-linux-gnu-6.4 3.9M 43.9M
/nix/store/597n4rdf9pvkl0xwisf7vp85g4b7550n-glibc-aarch64-unknown-linux-gnu-2.37-8-dev 2.2M 51.1M
/nix/store/z7hdlh9az0921i0lndb92kbm5yw1sssw-aarch64-unknown-linux-gnu-stage-final-gcc-12.3.0-libgcc 480.8K 51.5M
/nix/store/c6a6p6z0gp1cfc8xpkijkklpslddy5dd-aarch64-unknown-linux-gnu-stage-final-gcc-12.3.0-lib 8.0M 59.5M
/nix/store/1vspj5rw3anw190m753by8b9avja2hw3-gmp-with-cxx-aarch64-unknown-linux-gnu-6.3.0 656.0K 60.1M
/nix/store/cjzravcp3qwyzp0vw4lkc3axplys98al-spigot-aarch64-unknown-linux-gnu-20220606.eb585f8 1.2M 65.2Mafter: $ nix path-info -rsSh $(chase result) | LC_ALL=C sort -hk3
/nix/store/ryg2qa9qmzgv3gbj5x1s3ngj9an4dlir-libgcc-aarch64-unknown-linux-gnu-12.3.0 535.6K 535.6K
/nix/store/zb4kxl0a6mmb456jb82c8250yk337hpp-glibc-aarch64-unknown-linux-gnu-2.37-8 39.5M 40.0M
/nix/store/prj327q5afj9xx9ghzg0kdq2qwxi25ng-ncurses-aarch64-unknown-linux-gnu-6.4 3.9M 43.9M
/nix/store/0hs8ldbjxrbjihpfag054f6jpfr1jmq7-aarch64-unknown-linux-gnu-stage-final-gcc-12.3.0-lib 8.1M 48.1M
/nix/store/jfp807gjzxnfjffhpjgvfjaw127a13m9-gmp-with-cxx-aarch64-unknown-linux-gnu-6.3.0 656.0K 48.8M
/nix/store/w633g3prpnn25gi2nig064wfj176pwsx-spigot-aarch64-unknown-linux-gnu-20220606.eb585f8 1.2M 53.9Mworks |
Artturin
approved these changes
Sep 8, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of changes
Cross-compiled binaries currently end up with two different libgcc outpaths in their closure. This is harmless, but confusing.
The two libgccs are:
One of them is the "first" targetPlatform libgcc, which is built by the "first" cross-compiler. This "first libgcc" and "first compiler" are used to build the targetPlatform glibc.
Once glibc is built, we rebuild the cross-compiler, since gcc can't enable most of its features unless you give it an already-compiled targetPlatform glibc. When this "second" compiler is built, it also builds an extra copy of libgcc.
This commit discards the second, extra libgcc, and instead puts a reference to the first (correct) libgcc into the "second compiler"
.passthru.libgcc, so that anybody expectingstdenv.cc.cc.libgccto exist will still find it there.Closes #249680
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)