From 13a9006ec344c911a9f952bb75b3edd16ecea410 Mon Sep 17 00:00:00 2001 From: David Scherer Date: Fri, 29 Apr 2022 22:05:17 -0400 Subject: [PATCH] Fix determinism by defaulting codegenUnits to 1, not NIX_BUILD_CORES --- pkgs/build-support/rust/build-rust-crate/build-crate.nix | 2 +- pkgs/build-support/rust/build-rust-crate/configure-crate.nix | 2 +- pkgs/build-support/rust/build-rust-crate/default.nix | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/rust/build-rust-crate/build-crate.nix b/pkgs/build-support/rust/build-rust-crate/build-crate.nix index bd7aa31d0a44..b5db1ffa7fb5 100644 --- a/pkgs/build-support/rust/build-rust-crate/build-crate.nix +++ b/pkgs/build-support/rust/build-rust-crate/build-crate.nix @@ -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) diff --git a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix index 67ff5212f158..5129777c9d51 100644 --- a/pkgs/build-support/rust/build-rust-crate/configure-crate.nix +++ b/pkgs/build-support/rust/build-rust-crate/configure-crate.nix @@ -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; diff --git a/pkgs/build-support/rust/build-rust-crate/default.nix b/pkgs/build-support/rust/build-rust-crate/default.nix index e068c4098f57..eea1e3baeeca 100644 --- a/pkgs/build-support/rust/build-rust-crate/default.nix +++ b/pkgs/build-support/rust/build-rust-crate/default.nix @@ -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_