wrapCCWith: structured argument for wrapper flags

Take a "nixSupport" argument that is an attrset of lists to append
to "$out/nix-support/${name}" where name is the name of the
attribute. This attrset is available from the passthru of the
wrapped compiler.

This is an alternative to imperatively issuing flags with
extraBuildCommands and makes it possible to append or filter
flags with an override.
This commit is contained in:
Emery Hemingway 2022-04-29 21:54:03 -05:00
parent 28216de86b
commit 89a0dd2414
2 changed files with 10 additions and 2 deletions

View file

@ -14,6 +14,7 @@
, nativeTools, noLibc ? false, nativeLibc, nativePrefix ? ""
, propagateDoc ? cc != null && cc ? man
, extraTools ? [], extraPackages ? [], extraBuildCommands ? ""
, nixSupport ? {}
, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
, buildPackages ? {}
, libcxx ? null
@ -155,6 +156,8 @@ stdenv.mkDerivation {
(setenv "NIX_CFLAGS_COMPILE_${suffixSalt}" (concat (getenv "NIX_CFLAGS_COMPILE_${suffixSalt}") " -isystem " arg "/include"))))
'(${concatStringsSep " " (map (pkg: "\"${pkg}\"") pkgs)}))
'';
inherit nixSupport;
};
dontBuild = true;
@ -521,7 +524,11 @@ stdenv.mkDerivation {
##
## Extra custom steps
##
+ extraBuildCommands;
+ extraBuildCommands
+ lib.strings.concatStringsSep "; "
(lib.attrsets.mapAttrsToList
(name: value: "echo ${toString value} >> $out/nix-support/${name}")
nixSupport);
inherit expand-response-params;

View file

@ -13932,6 +13932,7 @@ with pkgs;
# default.
libcxx ? null
, extraPackages ? lib.optional (cc.isGNU or false && stdenv.targetPlatform.isMinGW) threadsCross
, nixSupport ? {}
, ...
} @ extraArgs:
callPackage ../build-support/cc-wrapper (let self = {
@ -13943,7 +13944,7 @@ with pkgs;
isGNU = cc.isGNU or false;
isClang = cc.isClang or false;
inherit cc bintools libc libcxx extraPackages zlib;
inherit cc bintools libc libcxx extraPackages nixSupport zlib;
} // extraArgs; in self);
wrapCC = cc: wrapCCWith {