mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 19:55:41 +03:00
buildRustCrate: make codegen-units configurable
This parameter is being set to `$NIX_BUILD_CORES` by default. This is a standard practice but there's a suspicion that this can produce broken builds. For some details see https://github.com/cargo2nix/cargo2nix/issues/184 . As a work-around/test, it'd be good if codegen-units can be set to something constant, such as `1`. This PR allows it. Note that the default of `$NIX_BUILD_CORES` is preserved so this MR causes no change in default behaviour and no rebuilds.
This commit is contained in:
parent
b455605c2d
commit
f6897d23f4
3 changed files with 9 additions and 5 deletions
|
@ -4,14 +4,15 @@
|
|||
crateFeatures, crateRenames, libName, release, libPath,
|
||||
crateType, metadata, crateBin, hasCrateBin,
|
||||
extraRustcOpts, verbose, colors,
|
||||
buildTests
|
||||
buildTests,
|
||||
codegenUnits
|
||||
}:
|
||||
|
||||
let
|
||||
baseRustcOpts =
|
||||
[
|
||||
(if release then "-C opt-level=3" else "-C debuginfo=2")
|
||||
"-C codegen-units=$NIX_BUILD_CORES"
|
||||
"-C codegen-units=${codegenUnits}"
|
||||
"--remap-path-prefix=$NIX_BUILD_TOP=/"
|
||||
(mkRustcDepArgs dependencies crateRenames)
|
||||
(mkRustcFeatureArgs crateFeatures)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
{
|
||||
build
|
||||
, buildDependencies
|
||||
, codegenUnits
|
||||
, colors
|
||||
, completeBuildDeps
|
||||
, completeDeps
|
||||
|
@ -24,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=$NIX_BUILD_CORES"] ++ extraRustcOptsForBuildRs);
|
||||
(["-C codegen-units=${codegenUnits}"] ++ extraRustcOptsForBuildRs);
|
||||
buildDeps = mkRustcDepArgs buildDependencies crateRenames;
|
||||
authors = lib.concatStringsSep ":" crateAuthors;
|
||||
optLevel = if release then 3 else 0;
|
||||
|
|
|
@ -228,6 +228,7 @@ crate_: lib.makeOverridable
|
|||
"colors"
|
||||
"edition"
|
||||
"buildTests"
|
||||
"codegenUnits"
|
||||
];
|
||||
extraDerivationAttrs = builtins.removeAttrs crate processedAttrs;
|
||||
nativeBuildInputs_ = nativeBuildInputs;
|
||||
|
@ -315,6 +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";
|
||||
extraRustcOpts =
|
||||
lib.optionals (crate ? extraRustcOpts) crate.extraRustcOpts
|
||||
++ extraRustcOpts_
|
||||
|
@ -329,13 +331,13 @@ crate_: lib.makeOverridable
|
|||
inherit crateName buildDependencies completeDeps completeBuildDeps crateDescription
|
||||
crateFeatures crateRenames libName build workspace_member release libPath crateVersion
|
||||
extraLinkFlags extraRustcOptsForBuildRs
|
||||
crateAuthors crateHomepage verbose colors;
|
||||
crateAuthors crateHomepage verbose colors codegenUnits;
|
||||
};
|
||||
buildPhase = buildCrate {
|
||||
inherit crateName dependencies
|
||||
crateFeatures crateRenames libName release libPath crateType
|
||||
metadata hasCrateBin crateBin verbose colors
|
||||
extraRustcOpts buildTests;
|
||||
extraRustcOpts buildTests codegenUnits;
|
||||
};
|
||||
installPhase = installCrate crateName metadata buildTests;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue