-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
stdenv/linux/default.nix: add gcc rebuild during bootstrap #209063
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please.
Sorry, last minute "fix" slipped in and there is a one unwanted reference to bootstrap tools that fails the --- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -459,7 +459,8 @@ in
# other purposes (binutils and top-level pkgs) too.
inherit (prevStage)
bash gettext gnum4 bison
- perl texinfo which xz
+ perl texinfo which
+ # xz - rebuild to pull in rebuilt version into final stdenv
zlib linuxHeaders libidn2 libunistring;
${localSystem.libc} = getLibc prevStage; I'll push it in a few minutes along with comment updates. |
4965bd8
to
6428d11
Compare
Pushed the update. Was able to build Should be ready to test. |
Currently attempting to bootstrap my entire server from this branch, will see if it builds. |
I'm rebuilding my entire aarch64 test VM with a pretty standard Xfce + Firefox on this branch. Then I will try again with GCC 11. |
I've successfully built about two thirds of my server config with this branch, including pretty much every compiler under the sun (Clang, GHC, gfortran, rustc, Ruby, Python, Erlang, Elixir) in the chain. I'll leave it running to build the server config and also my desktop config overnight and see how that goes, but it's very likely this is good to go on x86_64-linux. |
6428d11
to
3c51469
Compare
Aaaand the server config is built, with one unrelated failure (#209118). Time for the desktop, and time for me to go get some sleep. |
The desktop build ended up running out of disk space, but it got almost all the way there. I think this should really be good to go. Has anyone tested aarch64 with GCC 11 yet? |
Does this still not violate the stance that none of the files in bootstrap or generated by bootstrap tools are not used directly? |
3c51469
to
1210fc2
Compare
Got another snag: --- a/pkgs/development/compilers/gcc/11/default.nix
+++ b/pkgs/development/compilers/gcc/11/default.nix
@@ -221,6 +221,7 @@ stdenv.mkDerivation ({
};
targetConfig = if targetPlatform != hostPlatform then targetPlatform.config else null;
+ targetPlatformConfig = targetPlatform.config;
buildFlags = optional
(targetPlatform == hostPlatform && hostPlatform == buildPlatform)
diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh
index 113bd83ea53..71a997a7df9 100644
--- a/pkgs/development/compilers/gcc/builder.sh
+++ b/pkgs/development/compilers/gcc/builder.sh
@@ -203,6 +203,17 @@ preInstall() {
ln -s lib "$out/${targetConfig}/lib32"
ln -s lib "${!outputLib}/${targetConfig}/lib32"
fi
+
+ # cc-wrappers uses --sysroot=/nix/dir/does/not/exist as a way to
+ # drop default sysheaders search path. Unfortunately that switches
+ # clang++ into searching libraries in gcc in cross-compiler paths:
+ # from ${!outputLib}/lib (native)
+ # to ${!outputLib}/${targetPlatformConfig}/lib
+ # We create the symlink to make both native and cross paths
+ # available even if the toolchain is not the cross-compiler.
+ if [ ! -e ${!outputLib}/${targetPlatformConfig} ] ; then
+ ln -s . ${!outputLib}/${targetPlatformConfig}
+ fi
} Applied to all |
68f9e71
to
3e48d0b
Compare
Restores excessive rebuilds of |
Proposed 2 of 3 |
Proposed one |
Filed upstream bug for poor build parallelism in |
763c276
to
8ee2b7c
Compare
No functional change. No need to retest. Rebased against current While at it added missing minor rename: --- a/pkgs/stdenv/linux/default.nix
+++ b/pkgs/stdenv/linux/default.nix
@@ -415,7 +415,7 @@ in
gcc-unwrapped =
let makeStaticLibrariesAndMark = pkg:
lib.makeOverridable (pkg.override { stdenv = self.makeStaticLibraries self.stdenv; })
- .overrideAttrs (a: { pname = "${a.pname}-stage3"; });
+ .overrideAttrs (a: { pname = "${a.pname}-stage4"; });
in super.gcc-unwrapped.override {
# Link GCC statically against GMP etc. This makes sense because
# these builds of the libraries are only used by GCC, so it
@@ -466,7 +466,7 @@ in
# force gmp to rebuild so we have the option of dynamically linking
# libgmp without creating a reference path from:
# stage5.gcc -> stage4.coreutils -> stage3.glibc -> bootstrap
- gmp = lib.makeOverridable (super.gmp.override { stdenv = self.stdenv; }).overrideAttrs (a: { pname = "${a.pname}-stage4"; });
+ gmp = lib.makeOverridable (super.gmp.override { stdenv = self.stdenv; }).overrideAttrs (a: { pname = "${a.pname}-stage5"; });
# To allow users' overrides inhibit dependencies too heavy for
# bootstrap, like guile: https://github.com/NixOS/nixpkgs/issues/181188 |
Before the change our rebuild chain was the followin: - `bootstrapTools` install - `binutils` built by `bootstrapTools` - `glibc` built by `bootstrapTools` - `gcc` built by `bootstrapTools` As a result `glibc` contained code generated by `bootstrapTools`'s `gcc`. And (what worse) copied `libgcc_s.so.1` as is from `bootstrapTools`'s `gcc`. Such `libgcc_s.so.1` was not compatible with `nixpkgs` `gcc` at least on `aarch64` where newer `libgcc` is expected to have new symbols. As a result linking failed as: ld: /build/test.o: in function `foo(int)': test.cpp:(.text+0x2c): undefined reference to `__aarch64_ldadd4_acq_rel' collect2: error: ld returned 1 exit status The change rejigs rebuild sequence as: - `bootstrapTools` install - `binutils` built by `bootstrapTools` - `gcc` built by `bootstrapTools` - `glibc` built by `gcc` - `gcc` built by `gcc` As a result `glibc` gets built by fresher `gcc` and embeds a copy of `libgcc_s.so.1`. Co-authored-by: Rick van Schijndel <[email protected]>
8ee2b7c
to
03da08b
Compare
Rebased past |
@ofborg build icu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not merge this.
It causes an extra three recompiles of gcc
all platforms (six instead of three), even platforms for which it gives no benefit.
#209870 provides all the same benefits, with no extra rebuilds, and lets you start using stdenv
as soon as the second compile of gcc
is finished (i.e. in parallel with the third compile).
@trofi should we just close this as superseded maybe? |
Sure. I did not yet get the feedback from @Ericson2314 and I think it's a prerequisite. If the PR languished for a month and problem persisted for as long as I used You will need another form of the #208412 Not the first time I (and others) threw away most of the effort around the bootstrap bootstrap improvements away. I can keep the patch locally indefinitely. I already have about 200 of them :) |
All I meant was that #209870 achieves the same thing and seems to be a better approach. Are there issues with that change that don't occur with this one? |
Good question. I don't know. It's too hard for me to reason about it as a whole. I usually diff before/after state to see the difference. It's very hard to do there. |
I initially tried factoring it into multiple PRs, but ended up getting "i don't see the point of this" feedback for the parts that were not useful separately from external-bootstrap (example). So to avoid time being wasted on those unproductive discussions I put it all under a single PR. If you think about it, there's really no reason for people to merge isolated parts of #209870 since none of it is useful without the whole thing. If you want to review it in pieces it isn't hard; the major changes are in only two files:
Everything else is just fixing breakage (like I could make the PR smaller if it were okay to break |
Description of changes
A bit of background how set of changes came to be with more words: https://trofi.github.io/posts/275-nixpkgs-bootstrap-deep-dive.html
before the change our rebuild chain was roughly the followin:
bootstrapTools
installbinutils
built bybootstrapTools
glibc
built bybootstrapTools
gcc
built bybootstrapTools
As a result
glibc
contained code generated bybootstrapTools
'sgcc
. And (what worse) copiedlibgcc_s.so.1
as is from it.Such
libgcc_s.so.1
was not compatible withnixpkgs
gcc
atleast on
aarch64
where newerlibgcc
is expected to have new symbols.As a result linking failed as:
The change rejigs rebuild sequence as:
bootstrapTools
installbinutils
built bybootstrapTools
gcc
built bybootstrapTools
glibc
built bygcc
gcc
built bygcc
As a result
glibc
gets built by freshergcc
and embeds a copyof
libgcc_s.so.1
.To make it work as is I had to use a --sysroot= to evade
accidental pull of system headers embedded by
gcc
.While at it decreased rebuild counts for
bash
andxz
. These aresimple tools we can use as is built by
bootstrapTools
until webuild final stage.
List of packages with more than one build before the change:
List of packages with more than one build after the change:
Things done
sandbox = true
set 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/
)nixos/doc/manual/md-to-db.sh
to update generated release notes