-
-
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 setup: Process dependencies before dependents #31414
Conversation
This seems sensible in principle, but can we get a Hydra job showing what the implications might be? Subtly changing behavior (that arguably nobody should rely on the order of, but people probably do) makes me very uncomfortable even if it does make sense. |
@nixborg build |
Jobset created at https://hydra.mayflower.de/jobset/nixos/pr-31414 |
pkgs/stdenv/generic/setup.sh
Outdated
} | ||
|
||
# Add package to the future PATH and run setup hooks | ||
activatePackage() { |
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.
Who calls this function?
pkgs/stdenv/generic/setup.sh
Outdated
@@ -359,15 +389,22 @@ if [ -z "${crossConfig:-}" ]; then | |||
${propagatedNativeBuildInputs:-} ${propagatedBuildInputs:-}; do | |||
findInputs "$i" nativePkgs propagated-native-build-inputs | |||
done | |||
for i in "${nativePkgs[@]}"; do | |||
activatePackage "$i" |
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.
@orivej here
pkgs/stdenv/generic/setup.sh
Outdated
for i in ${nativeBuildInputs:-} ${defaultNativeBuildInputs:-} ${propagatedNativeBuildInputs:-}; do | ||
findInputs "$i" nativePkgs propagated-native-build-inputs | ||
done | ||
for i in "${nativePkgs[@]}"; do | ||
activatePackage "$i" |
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.
@orivej And here
@globin is there any good known-good jobsest to compare the nixborg one to? |
Oh hmm, this breaks down when different dependencies are in fact the same derivation. I'm going to have to think about that. |
Could you give an example in nixpkgs? |
869bacc
to
714b5f2
Compare
@orivej Nevermind. The already-visited logic is based on actual paths, I just mistakenly changed the iteration order. [I did have to make There's still a theoretical issue where "unrelated" deps could clobber each other on the PATH in different ways based on different topological sorts, and our depth-first one might not have the most intuitive behavior in that regard, but I won't worry about this unless it shows up in practice. I added a |
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.
Looks good. https://hydra.mayflower.de/jobset/nixos/pr-31414 did not pick your changes yet… And since AFAIK it does not contribute to the nixos cache, shouldn't this PR go to staging first?
@nixborg build |
Jobset created at https://hydra.mayflower.de/jobset/nixos/pr-31414 |
714b5f2
to
57e9312
Compare
This will be very useful for bootstrapping, eventually.
…d of strings This is generally cleaner: less eval, less worrying about separators, and probably also faster. I got the idea from that python wrapper script.
I like the motivation behind this change but because nothing is happening I am closing this. |
This issue is mentioned in nixpkgs stdenv: https://github.com/nixos/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L1167 |
Yes maybe a GitHub issue rather than open PR canbe made for that. |
Reopning and marking as draft because I ought to finish it at some point. |
Should be possible to finish after #132340 is the default and cc-wrapper is simplified. |
I marked this as stale due to inactivity. → More info |
Motivation for this change
This is intended to be reviewed commit-by-commit.
This does 2 things
Change the dependency order. Before, we did the current node before children, now we do the children before current node. Were dependencies forming a tree, this would simply be the inverse traversal, but since they in fact form a DAG, it's a bit more subtle. The opposite of the new invariant "dependencies before dependents" wasn't true: dependents weren't always processed first because it was possible that a dependency was already visited via another dependent.
This is an observable change because the processing we are doing does not commute: arbitrary bash setup hooks certainly don't, and
PATH
concatenation doesn't either. I do think having this invariant is valuable, though, and rely on it to simplify cc-wrapper's setup hook.Cyclic dependencies are now an error. Yes, they are only possible in absurd cases, but possible nonetheless:
(
foo
andbar
are cyclic). The old algo would silently work with this; the new one would naively diverge, so I made it error out instead as such a thing should never be intended. But if we agree this shouldn't happen in practice so infinite recursion is a good enough error, I can simplify thingsThings done
Hoping to merge this Monday 2017-11-13 at the latest :). Thanks!build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)CC @bgamari