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

stdenv: inline and remove actuallySplice (no effect on eval) #263278

Closed
wants to merge 5 commits into from
Closed

stdenv: inline and remove actuallySplice (no effect on eval) #263278

wants to merge 5 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 25, 2023

Description of changes

Split out from

Includes

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

This commit inlines the actuallySplice variable, which is simply
stdenv.buildPlatform!=stdenv.targetPlatform.

Since it isn't anything mysterious, the code becomes much easier to
understand when written that way.

This commit also restructures stdenvBootstappingAndPlatforms, but
in a way that makes absolutely no change to its behavior.

Adam Joseph and others added 5 commits October 24, 2023 00:04
Previously, stdenv used `adjacentPackages==null` to signal that
`actuallySplice` should be `false`.  Let's pass it explicitly for
greater clarity.
It's quite difficult to understand what this `selfBuild` parameter
is signaling, but it turns out to simply indicate which stages have
any kind of cross compilation (i.e. either build!=host or
host!=target).

Let's check that condition directly for greater clarity.
The native stdenv bootstrap (e.g. `pkgs/stdenv/linux/default.nix`)
is very elegantly structured as a sequence of arbitrarily-many
stages.  This makes it easy to refactor and modularize and reuse,
because if a stage gets too complicated we can just split it up into
two separate sequential stages.  We can also insert optional stages.

Unfortunately we can't do the same thing with cross-compiled
stdenvs, because `adjacentPackages` includes the hardwired
assumption that there are exactly two stages after the end of the
native bootstrap stage sequence:

  - The (build==host)!=target stage
  - The build!=(host==target) stage

This commit eliminates that assumption.  Instead of resolving things
like `pkgsBuildHost` to `prevStage`, we instead *search backwards*
for the most recent stage which creates packages on our
buildPlatform and for our hostPlatform.

This commit should not affect eval.

Note that `pkgsTargetTarget`, which becomes `targetPackages` still
has hardwired assumptions.  I think setting `pkgsTargetTarget` to
`nextStage` is just flat-out wrong for every stage except the "main"
stage (the `build!=(host==target)` stage), but I fear that there may
be code that relies on the particular way that it is wrong.  It
looks like `pkgsTargetTarget` and `targetPackages` exist exclusively
in order to provide access to the `postStage` hack; I intend to
submit a separate PR that `throw`s if it is used in any other way,
to see what breaks.

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit inserts extra stages into the cross-compilation stdenv
bootstrap in order to prevent assumptions about the number of stages
from creeping back in (see previous commit).

If this commit is used without the previous commit, eval will fail
badly.  The no-op stages added by this commit serve as an example of
what wasn't possible before the PR which includes them.

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This commit inlines the `actuallySplice` variable, which is simply
`stdenv.buildPlatform!=stdenv.targetPlatform`.

Since it isn't anything mysterious, the code becomes much easier to
understand when written that way.

This commit also restructures `stdenvBootstappingAndPlatforms`, but
in a way that makes absolutely no change to its behavior.
@github-actions github-actions bot added the 6.topic: stdenv Standard environment label Oct 25, 2023
@ghost ghost marked this pull request as ready for review November 12, 2023 00:05
@ghost ghost requested a review from Ericson2314 as a code owner November 12, 2023 00:05
@ghost ghost closed this Jan 23, 2024
@ghost ghost deleted the inline-alwaysSplice branch January 23, 2024 06:45
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants