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

deduplicate the native and cross bootstraps #263684

Open
ghost opened this issue Oct 27, 2023 · 1 comment
Open

deduplicate the native and cross bootstraps #263684

ghost opened this issue Oct 27, 2023 · 1 comment
Milestone

Comments

@ghost
Copy link

ghost commented Oct 27, 2023

There is a huge amount of duplication between the cross bootstrap and stdenv/linux. Both of them go through the same dance. The goal is to deduplicate this dance with no loss of functionality.

Here is what the cross bootstrap looks like:

  1. Build pkgsBuildBuild.stdenv
  2. Use pkgsBuildBuild.stdenv to compile the bintools (bintoolsNoLibc)
  3. Use pkgsBuildBuild.stdenv to compile a bare-bones compiler (gccWithoutTargetLibc / clangNoLibc)
  4. Use the bare-bones compiler to compile the bintools
  5. Use the bare-bones compiler to compile the libc
  6. Use the bare-bones compiler to compile real compiler
  7. Use the real compiler to compile the libc

Here are the native linux stages:

  1. Unpack the bootstrap-files
  2. Use the bootstrap-files compiler+bintools to compile the bintools
  3. Use the bootstrap-files compiler and new bintools to the bare-bones compiler (xgcc)
  4. Use the bare-bones compiler to compile the bintools
  5. Use the bare-bones compiler to compile the libc
  6. Use the bare-bones compiler to compile the real compiler
  7. Use the real compiler to compile the libc
  8. Use the real compiler to compile the bintools

The only native bootstrap step that doesn't correspond to anything in the cross bootstrap is the very last one. It exists only because the native bootstrap has a disallowedReferences entry for the bootstrap-files, but cross bootstrap doesn't care about that. This stage would simply be skipped in the cross case. Or we could keep it and add the disallowedReferences check to the cross bootstrap as well.

Ultimately what will happen is that instead of taking a bootstrap-files, stdenv/linux/default.nix as an argument, it will instead take any stdenv as an argument. That argument can then be any of these:

  • an unpacked bootstrap-files (which has the same approximate shape as stdenv)
  • pkgsBuildBuild.stdenv
  • pkgsCross.${targetPlatform}.freshBootstrapFiles, providing a simple and straightforward way to say "rebuild the bootstrap-files and then use them to bootstrap" (useful for testing)
  • the minimal-bootstrap end product
  • pkgsCross.${firstPlatform}.pkgsCross.${secondPlatform}.pkgsBuildTarget.stdenv, allowing to chain together cross compilations
    • this is useful with the minimal-bootstrap, since that only supports 32-bit x86.
@ghost ghost added the 0.kind: bug label Oct 27, 2023
@ghost ghost added this to the 24.05 milestone Oct 27, 2023
@reckenrode
Copy link
Contributor

I’m not suggesting to add it to the scope of this issue, but I’m watching it with interest from the Darwin side to see if there’s anything that can be brought over. I have plans for Darwin cross in 24.05, and one of the major pains with fixing it is how the stdenv and cross bootstraps are so different.

@wegank wegank modified the milestones: 24.05, 24.11 May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants