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

Normalize bootstrapping #21415

Merged
merged 8 commits into from Jan 13, 2017
Merged

Normalize bootstrapping #21415

merged 8 commits into from Jan 13, 2017

Conversation

Ericson2314
Copy link
Member

@Ericson2314 Ericson2314 commented Dec 25, 2016

Split out from #21268

This PR introduces a new abstraction for dealing with stdenv bootstrapping. It doesn't really make anything shorter, but at least it enforces a consistent ideom across all of them. I've made all the stdenvs but darwin really embrace the new abstraction. Darwin is a bit bigger, and so I made minimal changes to make it use it, but I'll refactor it to make it embrace the new abstraction too if wanted.

#21268 builds on this to make cross compiling not a dirty hack.

@mention-bot
Copy link

@Ericson2314, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @errge, @gridaphobe, @LnL7 and @copumpkin to be potential reviewers.

@cstrahan
Copy link
Contributor

Hey @Ericson2314, I'd say this on IRC but it looks like you disconnected: thanks a ton for doing all this refactoring work! The cross compiling stuff has looked a little sketchy for a while, and I'm really looking forward to seeing the wrinkles ironed out. 🍻

Oh, and Happy Holidays!

@Ericson2314 Ericson2314 added the 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on label Dec 25, 2016
@Ericson2314 Ericson2314 added this to the 17.03 milestone Dec 25, 2016
@shlevy
Copy link
Member

shlevy commented Dec 26, 2016

Bit busy with the holidays, but will review this when I get the chance!

@Ericson2314
Copy link
Member Author

Ericson2314 commented Jan 7, 2017

@shlevy any sort of ETA?

@nbp If @shlevy or @cstrahan gives this a go I want to merge and then try the single-fixpoint stuff we scratched at in the other PR's thread.

@shlevy
Copy link
Member

shlevy commented Jan 7, 2017

Review started, will probably take a few days to finish going through it all

@Ericson2314
Copy link
Member Author

Ericson2314 commented Jan 7, 2017

@shlevy Thanks so much! Oh and to be clear, I've written it with the intention of a commit-by-commit review, which should make it more bights but each one less of a mouthful.

@Ericson2314 Ericson2314 self-assigned this Jan 7, 2017
@Ericson2314
Copy link
Member Author

@shlevy friendly ping :)

Copy link
Member

@shlevy shlevy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain a bit more what this new abstraction is and why its preferable?

EDIT: This review is first commit only.

rec {
# It would be nice to just use `++`, but we can't forget about the old
# `basecase`. I (@Ericson2314) am tempted to use a heterogeneous list instead.
extendStages = { baseCase, stageFuns }: more: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document this or, if its use should be obvious from context, move it to a let at the top so it's not exported.

# isn't already set.
withAllowCustomOverrides = lib.lists.imap
(index: stageFun: prevStage:
{ allowCustomOverrides = index == 1; } # first element, 1-indexed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match the comment ("all but the final stage") if the list has the stages in order...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh whoops! Yeah originally I had reverse order.

Copy link
Member

@shlevy shlevy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't seem to approve commits separately, 👍 on "top-level: Inherit system and platform in stage.nix not all-packages.nix"

@shlevy shlevy self-requested a review January 13, 2017 13:06
Copy link
Member

@shlevy shlevy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of "top-level: Modernize stdenv.overrides giving it self and super"

Please find some place (perhaps the nixpkgs manual changelog?) to document this change.

Otherwise 👍

Copy link
Member

@shlevy shlevy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of "top-level: Do stdenvOverrides in stage.nix even if crossSystem exists.":

Expand in commit message why the previous comment no longer applies.

#
# We don't want stdenv overrides in the case of cross-building, or
# otherwise the basic overridden packages will not be built with the
# crossStdenv adapter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't this comment apply any more?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In commit message, basically the cross stdenv cleans up after itself rather than leaving stage.nix to do it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@shlevy shlevy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of "linux stdenv: Utilize overrides and prevStage better":

Why does this change gcc.cc to gcc-unwrapped?

Copy link
Member

@shlevy shlevy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of "linux stdenv: Remove stray use of stage0 to bootstrap more elegantly"

Can you explain the role of ccWrapperStdenv in this commit?

Copy link
Member

@shlevy shlevy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of "linux stdenv: Inline stage funs to conform to new convention"

Diff is too hard to verify, but if all this is is code shuffling to meet the new standard then 👍

@Ericson2314
Copy link
Member Author

Ericson2314 commented Jan 13, 2017

Thanks!! Will get to work on these right away

@Ericson2314
Copy link
Member Author

I'm going to make those changes, make extendStages actually ++ with @nbp's {} base case in other thread suggestion, and then merge!

@shlevy
Copy link
Member

shlevy commented Jan 13, 2017

Well I'd like to see the explanation for why this new abstraction is better first...

@Ericson2314
Copy link
Member Author

@shlevy Sure, I was including that in this list of things to do, but yeah that deserves a re-review.

Document breaking change in 17.03 release notes
@Ericson2314 Ericson2314 force-pushed the normalize-boot branch 2 times, most recently from 3f71837 to af101e1 Compare January 13, 2017 17:26
@Ericson2314
Copy link
Member Author

Ericson2314 commented Jan 13, 2017

@shlevy should be all done. I can't figure out what the hell is causing the travis error. There is no freebsd variable on the line given in my branch or master.

EDIT: nevermind, a different PR (#21858) since I last fetched. Other PR is causing the problem all by itself. let me deal with that.

@Ericson2314
Copy link
Member Author

As a bonus, the big inline commit is now less indented causing less churn.

@Ericson2314
Copy link
Member Author

Copy link
Member

@shlevy shlevy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the one indexing issue but overall looks good!

# isn't already set.
withAllowCustomOverrides = lib.lists.imap
(index: stageFun: prevStage:
{ allowCustomOverrides = index == 1; } # first element, 1-indexed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong still...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the reverse below?, and then foldr not foldl?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Not a big deal, but maybe change the comment on this line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

inherit (args) stdenv;
in
if args.__raw or false
then args
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should maybe document somewhere that this function doesn't add __bootPackages when __raw == true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh whoops, that's not intentional. Not supposed to be that raw :).

crossSystem = null;
# Ignore custom stdenvs when cross compiling for compatability
# Remove config.replaceStdenv to ensure termination.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change this, but can you explain the termination issue when replaceStdenv is there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, old comment should still be there, bad copy paste from custom/default.nix

stdenvFunc ? import ../stdenv
, # A function booting the final package set for a specific standard
# environment. See below for the arguments given to that function,
# the the type of list it returns.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the the"?

#
# We don't want stdenv overrides in the case of cross-building, or
# otherwise the basic overridden packages will not be built with the
# crossStdenv adapter.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Ericson2314 and others added 6 commits January 13, 2017 13:23
Introduce new abstraction, `stdenv/booter.nix` for composing bootstraping
stages, and use it everywhere for consistency. See that file for more doc.

Stdenvs besides Linux and Darwin are completely refactored to utilize this.
Those two, due to their size and complexity, are minimally edited for
easier reviewing.

No hashes should be changed.
Instead, the cross stdenv will patch up the override field -- the complexity
is now confined to the one place it matters.
…ges.nix

These are not packages, and so its more elegant to do this outside of
all-packages.nix.
`gcc-unwrapped` basically replaces `gccPlain`. It may seem like an ugly
polution to stick it in all-packages, but a future PR will enshrine this
`*-unwrapped` pattern. In any event, the long term goal is stdenvs might
need to tweak how compilers are booted and wrapped, but the code to build
the unwrapped compilers themselves should be generic.
@Ericson2314
Copy link
Member Author

Linux tests passed (which do eval darwin), darwin job seems to have a backlog, I'm merging 😀!

@Ericson2314 Ericson2314 merged commit 0b8e389 into NixOS:master Jan 13, 2017
@Ericson2314 Ericson2314 deleted the normalize-boot branch January 13, 2017 21:10
@dmmarkov dmmarkov mentioned this pull request Jan 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement 6.topic: cross-compilation Building packages on a different sort platform than than they will be run on 8.has: clean-up 9.needs: community feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants