Fix determinism by defaulting codegenUnits to 1, not NIX_BUILD_CORES

This commit is contained in:
David Scherer 2022-04-29 22:05:17 -04:00 committed by Yt
parent f6897d23f4
commit 13a9006ec3
3 changed files with 3 additions and 3 deletions

View file

@ -12,7 +12,7 @@
baseRustcOpts =
[
(if release then "-C opt-level=3" else "-C debuginfo=2")
"-C codegen-units=${codegenUnits}"
"-C codegen-units=${toString codegenUnits}"
"--remap-path-prefix=$NIX_BUILD_TOP=/"
(mkRustcDepArgs dependencies crateRenames)
(mkRustcFeatureArgs crateFeatures)

View file

@ -25,7 +25,7 @@ let version_ = lib.splitString "-" crateVersion;
version = lib.splitVersion (lib.head version_);
rustcOpts = lib.foldl' (opts: opt: opts + " " + opt)
(if release then "-C opt-level=3" else "-C debuginfo=2")
(["-C codegen-units=${codegenUnits}"] ++ extraRustcOptsForBuildRs);
(["-C codegen-units=${toString codegenUnits}"] ++ extraRustcOptsForBuildRs);
buildDeps = mkRustcDepArgs buildDependencies crateRenames;
authors = lib.concatStringsSep ":" crateAuthors;
optLevel = if release then 3 else 0;

View file

@ -316,7 +316,7 @@ crate_: lib.makeOverridable
colors = lib.attrByPath [ "colors" ] "always" crate;
extraLinkFlags = lib.concatStringsSep " " (crate.extraLinkFlags or [ ]);
edition = crate.edition or null;
codegenUnits = if crate ? codegenUnits then crate.codegenUnits else "$NIX_BUILD_CORES";
codegenUnits = if crate ? codegenUnits then crate.codegenUnits else 1;
extraRustcOpts =
lib.optionals (crate ? extraRustcOpts) crate.extraRustcOpts
++ extraRustcOpts_