-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
[staging] stdenv: trim random seed to avoid reference cycles #106954
Conversation
cc @andir would appreciate your thoughts on this - hoping to get this fixed soon since it is breaking a good number of cross packages |
@@ -1,4 +1,7 @@ | |||
# Use the last part of the out path as hash input for the build. | |||
# This should ensure that it is deterministic across rebuilds of the same | |||
# derivation and not easily collide with other builds. | |||
export NIX_CFLAGS_COMPILE+=" -frandom-seed=${out##*/}" | |||
# We also truncate the hash so that it cannot cause reference cycles. | |||
local outbase="${out##*/}" |
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.
Does local really just span this file? Setup hooks are sourced via stdenv, right?
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.
Ah I think you are right. How about putting this in a getRandomSeed
function? I can't just inline the basename + trimming because bash won't do the nested expansion
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.
Ok, I ended up using a command substitution. Looks a little odd but avoids any namespace pollution
On 13:24 23.12.20, r-burns wrote:
@r-burns commented on this pull request.
> @@ -1,4 +1,7 @@
# Use the last part of the out path as hash input for the build.
# This should ensure that it is deterministic across rebuilds of the same
# derivation and not easily collide with other builds.
-export NIX_CFLAGS_COMPILE+=" -frandom-seed=${out##*/}"
+# We also truncate the hash so that it cannot cause reference cycles.
+local outbase="${out##*/}"
+local randomseed="${outbase:0:10}"
I was a little concerned that the seed is the same for all files, but gcc recommends each file has a unique seed. Is it important for the seed to differ for each build too?
Our initial assesment was that it is enough if it differs per build and
that is exactly what the drv hash gives us.
|
Using the full store hash as the random seed occasionally caused reference cycles when the invocation was stored in output artifacts. For example, cross-compiled gcc was failing due to this: https://hydra.nixos.org/eval/1631713#tabs-now-fail Simply truncating the hash is sufficient to avoid this.
cc @dezgeg as you are the maintainer for release-cross.nix bootstrapTools |
Using the full store hash as the random seed occasionally caused
reference cycles when the compiler invocation was stored in output artifacts.
For example, cross-compiled gcc was failing due to this:
https://hydra.nixos.org/eval/1631713#tabs-now-fail
Simply truncating the hash is sufficient to avoid this.
cc @symphorien: #102251 (comment)
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)