-
-
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: document some tips in debugging stdenv bootstrap tower #208478
Conversation
a5f8cb8
to
7b1b4a0
Compare
There are some other utilities present in the final stdenv like xz and things rebuilt multiple times during the bootstrap like perl. Should those be addressed here? |
Good question. Some of the secondary dependencies are volatile in nature: they come and go with patches and release updates. It's quite a big list (dumped it below). Some dependencies are very important, like We can pick more interesting cases and document them as well. So far I mainly followed toolchain-like packages: those that produce code (gcc, binutils), or those that provide code for embedding (glibc). The whole bootstrap list: $ for stage in 0 1 2 3 4; do echo "stage${stage} used in:"; nix-store --query --graph $(nix-instantiate -A stdenv) | grep -P -v '[.]sh|[.]patch|bash|[.]tar' | grep -P ".*bootstrap-stage${stage}-stdenv.*->.*" | sed 's/"[0-9a-z]\{32\}-/"/g'; done
stage0 used in:
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
"bootstrap-stage0-stdenv-linux.drv" -> "bootstrap-stage2-gcc-wrapper-.drv" [color = "red"];
"bootstrap-stage0-stdenv-linux.drv" -> "bootstrap-stage0-glibc-bootstrap.drv" [color = "magenta"];
"bootstrap-stage0-stdenv-linux.drv" -> "bootstrap-stage1-gcc-wrapper-.drv" [color = "blue"];
"bootstrap-stage0-stdenv-linux.drv" -> "bootstrap-stage0-binutils-wrapper-.drv" [color = "red"];
"bootstrap-stage0-stdenv-linux.drv" -> "bootstrap-stage3-gcc-wrapper-.drv" [color = "black"];
"bootstrap-stage0-stdenv-linux.drv" -> "bootstrap-stage4-gcc-wrapper-13.0.0.drv" [color = "burlywood"];
stage1 used in:
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
"bootstrap-stage1-stdenv-linux.drv" -> "gnum4-1.4.19.drv" [color = "red"];
"bootstrap-stage1-stdenv-linux.drv" -> "bison-3.8.2.drv" [color = "black"];
"bootstrap-stage1-stdenv-linux.drv" -> "binutils-wrapper-2.39.drv" [color = "black"];
"bootstrap-stage1-stdenv-linux.drv" -> "expand-response-params.drv" [color = "red"];
"bootstrap-stage1-stdenv-linux.drv" -> "binutils-2.39.drv" [color = "red"];
"bootstrap-stage1-stdenv-linux.drv" -> "gettext-0.21.drv" [color = "red"];
"bootstrap-stage1-stdenv-linux.drv" -> "texinfo-6.8.drv" [color = "green"];
"bootstrap-stage1-stdenv-linux.drv" -> "xz-5.4.0.drv" [color = "red"];
"bootstrap-stage1-stdenv-linux.drv" -> "binutils-wrapper-2.39.drv" [color = "green"];
"bootstrap-stage1-stdenv-linux.drv" -> "zlib-1.2.13.drv" [color = "burlywood"];
"bootstrap-stage1-stdenv-linux.drv" -> "perl-5.36.0.drv" [color = "burlywood"];
stage2 used in:
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
"bootstrap-stage2-stdenv-linux.drv" -> "linux-headers-6.1.drv" [color = "black"];
"bootstrap-stage2-stdenv-linux.drv" -> "libidn2-2.3.2.drv" [color = "green"];
"bootstrap-stage2-stdenv-linux.drv" -> "libunistring-1.0.drv" [color = "red"];
"bootstrap-stage2-stdenv-linux.drv" -> "bootstrap-stage0-glibc-iconv-bootstrap.drv" [color = "blue"];
"bootstrap-stage2-stdenv-linux.drv" -> "binutils-2.39.drv" [color = "burlywood"];
"bootstrap-stage2-stdenv-linux.drv" -> "expand-response-params.drv" [color = "burlywood"];
"bootstrap-stage2-stdenv-linux.drv" -> "patchelf-0.15.0.drv" [color = "black"];
"bootstrap-stage2-stdenv-linux.drv" -> "glibc-2.35-224.drv" [color = "burlywood"];
"bootstrap-stage2-stdenv-linux.drv" -> "python3-minimal-3.10.8.drv" [color = "magenta"];
"bootstrap-stage2-stdenv-linux.drv" -> "autoconf-archive-2022.09.03.drv" [color = "burlywood"];
"bootstrap-stage2-stdenv-linux.drv" -> "xz-5.4.0.drv" [color = "green"];
"bootstrap-stage2-stdenv-linux.drv" -> "bzip2-1.0.8.drv" [color = "red"];
"bootstrap-stage2-stdenv-linux.drv" -> "hook.drv" [color = "green"];
"bootstrap-stage2-stdenv-linux.drv" -> "libtool-2.4.7.drv" [color = "burlywood"];
"bootstrap-stage2-stdenv-linux.drv" -> "autoconf-2.71.drv" [color = "blue"];
"bootstrap-stage2-stdenv-linux.drv" -> "automake-1.16.5.drv" [color = "black"];
"bootstrap-stage2-stdenv-linux.drv" -> "zlib-1.2.13.drv" [color = "magenta"];
"bootstrap-stage2-stdenv-linux.drv" -> "gettext-0.21.drv" [color = "black"];
"bootstrap-stage2-stdenv-linux.drv" -> "pkg-config-wrapper-0.29.2.drv" [color = "red"];
"bootstrap-stage2-stdenv-linux.drv" -> "expat-2.5.0.drv" [color = "red"];
"bootstrap-stage2-stdenv-linux.drv" -> "pkg-config-0.29.2.drv" [color = "black"];
"bootstrap-stage2-stdenv-linux.drv" -> "libxcrypt-4.4.33.drv" [color = "magenta"];
"bootstrap-stage2-stdenv-linux.drv" -> "texinfo-6.8.drv" [color = "black"];
"bootstrap-stage2-stdenv-linux.drv" -> "help2man-1.49.2.drv" [color = "blue"];
"bootstrap-stage2-stdenv-linux.drv" -> "perl5.36.0-gettext-1.07.drv" [color = "green"];
"bootstrap-stage2-stdenv-linux.drv" -> "perl-5.36.0.drv" [color = "red"];
"bootstrap-stage2-stdenv-linux.drv" -> "file-5.43.drv" [color = "black"];
"bootstrap-stage2-stdenv-linux.drv" -> "nuke-references.drv" [color = "red"];
"bootstrap-stage2-stdenv-linux.drv" -> "libffi-3.4.4.drv" [color = "black"];
stage3 used in:
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
"bootstrap-stage3-stdenv-linux.drv" -> "gettext-0.21.drv" [color = "burlywood"];
"bootstrap-stage3-stdenv-linux.drv" -> "texinfo-6.8.drv" [color = "black"];
"bootstrap-stage3-stdenv-linux.drv" -> "zlib-1.2.13.drv" [color = "green"];
"bootstrap-stage3-stdenv-linux.drv" -> "gcc-13.0.0.drv" [color = "red"];
"bootstrap-stage3-stdenv-linux.drv" -> "mpfr-stage3-4.1.1.drv" [color = "burlywood"];
"bootstrap-stage3-stdenv-linux.drv" -> "libmpc-stage3-1.2.1.drv" [color = "magenta"];
"bootstrap-stage3-stdenv-linux.drv" -> "mpfr-4.1.1.drv" [color = "blue"];
"bootstrap-stage3-stdenv-linux.drv" -> "expand-response-params.drv" [color = "green"];
"bootstrap-stage3-stdenv-linux.drv" -> "xz-5.4.0.drv" [color = "green"];
"bootstrap-stage3-stdenv-linux.drv" -> "flex-2.6.4.drv" [color = "blue"];
"bootstrap-stage3-stdenv-linux.drv" -> "help2man-1.49.2.drv" [color = "red"];
"bootstrap-stage3-stdenv-linux.drv" -> "perl5.36.0-gettext-1.07.drv" [color = "black"];
"bootstrap-stage3-stdenv-linux.drv" -> "perl-5.36.0.drv" [color = "red"];
"bootstrap-stage3-stdenv-linux.drv" -> "gmp-with-cxx-6.2.1.drv" [color = "burlywood"];
"bootstrap-stage3-stdenv-linux.drv" -> "which-2.21.drv" [color = "green"];
"bootstrap-stage3-stdenv-linux.drv" -> "libxcrypt-4.4.33.drv" [color = "green"];
"bootstrap-stage3-stdenv-linux.drv" -> "isl-stage3-0.20.drv" [color = "burlywood"];
"bootstrap-stage3-stdenv-linux.drv" -> "gmp-with-cxx-stage3-6.2.1.drv" [color = "black"];
"bootstrap-stage3-stdenv-linux.drv" -> "hook.drv" [color = "green"];
"bootstrap-stage3-stdenv-linux.drv" -> "libtool-2.4.7.drv" [color = "blue"];
"bootstrap-stage3-stdenv-linux.drv" -> "autoconf-2.71.drv" [color = "blue"];
"bootstrap-stage3-stdenv-linux.drv" -> "automake-1.16.5.drv" [color = "burlywood"];
"bootstrap-stage3-stdenv-linux.drv" -> "file-5.43.drv" [color = "green"];
stage4 used in:
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
"bootstrap-stage4-stdenv-linux.drv" -> "attr-2.5.1.drv" [color = "burlywood"];
"bootstrap-stage4-stdenv-linux.drv" -> "gmp-with-cxx-stage4-6.2.1.drv" [color = "green"];
"bootstrap-stage4-stdenv-linux.drv" -> "diffutils-3.8.drv" [color = "blue"];
"bootstrap-stage4-stdenv-linux.drv" -> "bzip2-1.0.8.drv" [color = "green"];
"bootstrap-stage4-stdenv-linux.drv" -> "hook.drv" [color = "magenta"];
"bootstrap-stage4-stdenv-linux.drv" -> "automake-1.16.5.drv" [color = "burlywood"];
"bootstrap-stage4-stdenv-linux.drv" -> "autoconf-2.71.drv" [color = "red"];
"bootstrap-stage4-stdenv-linux.drv" -> "libtool-2.4.7.drv" [color = "burlywood"];
"bootstrap-stage4-stdenv-linux.drv" -> "patchelf-0.15.0.drv" [color = "green"];
"bootstrap-stage4-stdenv-linux.drv" -> "gnused-4.9.drv" [color = "black"];
"bootstrap-stage4-stdenv-linux.drv" -> "gnugrep-3.7.drv" [color = "black"];
"bootstrap-stage4-stdenv-linux.drv" -> "gnutar-1.34.drv" [color = "red"];
"bootstrap-stage4-stdenv-linux.drv" -> "help2man-1.49.2.drv" [color = "blue"];
"bootstrap-stage4-stdenv-linux.drv" -> "gcc-wrapper-13.0.0.drv" [color = "red"];
"bootstrap-stage4-stdenv-linux.drv" -> "xz-5.4.0.drv" [color = "black"];
"bootstrap-stage4-stdenv-linux.drv" -> "coreutils-9.1.drv" [color = "blue"];
"bootstrap-stage4-stdenv-linux.drv" -> "perl5.36.0-gettext-1.07.drv" [color = "burlywood"];
"bootstrap-stage4-stdenv-linux.drv" -> "gawk-5.2.1.drv" [color = "burlywood"];
"bootstrap-stage4-stdenv-linux.drv" -> "perl-5.36.0.drv" [color = "blue"];
"bootstrap-stage4-stdenv-linux.drv" -> "patch-2.7.6.drv" [color = "burlywood"];
"bootstrap-stage4-stdenv-linux.drv" -> "binutils-wrapper-2.39.drv" [color = "burlywood"];
"bootstrap-stage4-stdenv-linux.drv" -> "gzip-1.12.drv" [color = "magenta"];
"bootstrap-stage4-stdenv-linux.drv" -> "gnumake-4.4.drv" [color = "blue"];
"bootstrap-stage4-stdenv-linux.drv" -> "file-5.43.drv" [color = "green"];
"bootstrap-stage4-stdenv-linux.drv" -> "setup-hook.drv" [color = "green"];
"bootstrap-stage4-stdenv-linux.drv" -> "ed-1.18.drv" [color = "black"];
"bootstrap-stage4-stdenv-linux.drv" -> "lzip-1.23.drv" [color = "burlywood"];
"bootstrap-stage4-stdenv-linux.drv" -> "glibc-iconv-2.35.drv" [color = "green"];
"bootstrap-stage4-stdenv-linux.drv" -> "acl-2.3.1.drv" [color = "blue"];
"bootstrap-stage4-stdenv-linux.drv" -> "binutils-2.39.drv" [color = "red"];
"bootstrap-stage4-stdenv-linux.drv" -> "findutils-4.9.0.drv" [color = "burlywood"];
"bootstrap-stage4-stdenv-linux.drv" -> "libxcrypt-4.4.33.drv" [color = "magenta"];
"bootstrap-stage4-stdenv-linux.drv" -> "pcre-8.45.drv" [color = "green"]; |
Looking at this again, I'd say you do actually address the other utilities implicitly in the new section on bootstrap goals. I just wanted to be sure that we knew where they should come from. The goals sound good to me. Maybe add some justification like "These goals ensure the final stdenv has been built exclusively by packages available in the final stdenv so that compiler versions and environments etc. are consistent". That at least is how I understand the goals. Is there any mechanical way to check that those those goals are met? I think the Can you put the command to generate that list in the comments too? That looks very helpful. |
e33dc67
to
cf4c9b8
Compare
I think I get what you say. I added the following blurb:
I think we are on the same page, but just in case I'll try to explain myself a bit. I did not include your definition as is because (AFAIU) there is a fundamental problem of bootstrap process that has to be solved by pulling package definitions from non-final stdenv:
To untie this infinitely unfolding cycle final The final result is morally equivalent to your phrasing: "final stdenv has been built exclusively by packages available in the final stdenv". But mechanically we do it the other way around: we declare that previous ( Thus the more vague wording around the goals. I hope I did not make things worse with this brain dump.
I don't think there is a good way to detect even our current
Sounds good. Added. |
Rephrasing the blurb slightly and fixing the typo:
I think this PR is good other than some other minor typos.
I did not actually check, but I guess it is not a given that the file, especially since it's a binary, would make it through without being changed. That is unfortunate but oh well. |
cf4c9b8
to
5f06d36
Compare
Applied this wording.
Thank you! |
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.
Hey, thanks for documenting all of this!
Except for lib{mpfr,mpc,isl,gmp}.a
all of my review comments are just typos and minor stuff. But please do take a look at the comments about how those are handled so we don't mislead people into thinking they are built by the final gcc['s stage1 bootstrap compiler] -- they aren't!
Can we also get rid of the libmpfr hack if we add a second gcc rebuild? Seems like it, so it might actually be worth it. |
The ideal solution is to make gcc's stage1 and stage2 be separate nix derivations. Then we don't have to build gcc twice (or rather we don't have to build it four times). I think @Ericson2314 was the first to suggest this approach. |
bb12159
to
f5376df
Compare
Thank you, Adam! I applied (and squashed) all your suggestions as is. Great point on gcc's static libraries! The are very important to cal out. |
Something got mangled with the goals, 1 and 2 are almost the same now. I think 2 should be the one about being compiled by the bootstrap compiler? |
Just a few comments added: - added a few one-liners to explore which tools are rebuilt at each stdenv iteration during bootstrap - explicitly listed available toolchains and their sources for on each bootstrap step: glibc, binutils, gcc, coreutils. - added mention of static libraries linked into gcc Co-authored-by: Adam Joseph <[email protected]>
f5376df
to
062e14b
Compare
Good catch! Re-numbered to start from
|
Thanks for doing this! I do want to make it saner per things like building GCC separately just as @amjoseph-nixpkgs said, but yes let that not be a reason not to document how things exist currently. I learned stuff reading this too! |
…ments express #208478 as assertions
Just a few comments added:
bootstrap step: glibc, binutils, gcc, coreutils.
Should help slightly in explaining and untangling #208412
Description of changes
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