Skip to content

deduplicate the native and cross bootstraps #263684

@ghost

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions