Merge pull request #171083 from ehmry/wrapCCWith-nixSuport

wrapCCWith: structured argument for wrapper flags
main
7c6f434c 2 years ago committed by GitHub
commit cd6eea51c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      pkgs/build-support/cc-wrapper/default.nix
  2. 46
      pkgs/development/compilers/llvm/14/default.nix
  3. 3
      pkgs/top-level/all-packages.nix

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

@ -158,16 +158,17 @@ let
] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [ ] ++ lib.optionals (!stdenv.targetPlatform.isWasm) [
targetLlvmLibraries.libunwind targetLlvmLibraries.libunwind
]; ];
extraBuildCommands = '' extraBuildCommands = mkExtraBuildCommands cc;
echo "-rtlib=compiler-rt -Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags nixSupport.cc-cflags =
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags [ "-rtlib=compiler-rt"
'' + lib.optionalString (!stdenv.targetPlatform.isWasm) '' "-Wno-unused-command-line-argument"
echo "--unwindlib=libunwind" >> $out/nix-support/cc-cflags "-B${targetLlvmLibraries.compiler-rt}/lib"
'' + lib.optionalString (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false) '' ]
echo "-lunwind" >> $out/nix-support/cc-ldflags ++ lib.optional (!stdenv.targetPlatform.isWasm) "--unwindlib=libunwind"
'' + lib.optionalString stdenv.targetPlatform.isWasm '' ++ lib.optional
echo "-fno-exceptions" >> $out/nix-support/cc-cflags (!stdenv.targetPlatform.isWasm && stdenv.targetPlatform.useLLVM or false)
'' + mkExtraBuildCommands cc; "-lunwind"
++ lib.optional stdenv.targetPlatform.isWasm "-fno-exceptions";
}; };
clangNoLibcxx = wrapCCWith rec { clangNoLibcxx = wrapCCWith rec {
@ -177,11 +178,12 @@ let
extraPackages = [ extraPackages = [
targetLlvmLibraries.compiler-rt targetLlvmLibraries.compiler-rt
]; ];
extraBuildCommands = '' extraBuildCommands = mkExtraBuildCommands cc;
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags nixSupport.cc-cflags = [
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags "-rtlib=compiler-rt"
echo "-nostdlib++" >> $out/nix-support/cc-cflags "-B${targetLlvmLibraries.compiler-rt}/lib"
'' + mkExtraBuildCommands cc; "-nostdlib++"
];
}; };
clangNoLibc = wrapCCWith rec { clangNoLibc = wrapCCWith rec {
@ -191,10 +193,11 @@ let
extraPackages = [ extraPackages = [
targetLlvmLibraries.compiler-rt targetLlvmLibraries.compiler-rt
]; ];
extraBuildCommands = '' extraBuildCommands = mkExtraBuildCommands cc;
echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags nixSupport.cc-cflags = [
echo "-B${targetLlvmLibraries.compiler-rt}/lib" >> $out/nix-support/cc-cflags "-rtlib=compiler-rt"
'' + mkExtraBuildCommands cc; "-B${targetLlvmLibraries.compiler-rt}/lib"
];
}; };
clangNoCompilerRt = wrapCCWith rec { clangNoCompilerRt = wrapCCWith rec {
@ -202,9 +205,8 @@ let
libcxx = null; libcxx = null;
bintools = bintoolsNoLibc'; bintools = bintoolsNoLibc';
extraPackages = [ ]; extraPackages = [ ];
extraBuildCommands = '' extraBuildCommands = mkExtraBuildCommands0 cc;
echo "-nostartfiles" >> $out/nix-support/cc-cflags nixSupport.cc-cflags = [ "-nostartfiles" ];
'' + mkExtraBuildCommands0 cc;
}; };
clangNoCompilerRtWithLibc = wrapCCWith rec { clangNoCompilerRtWithLibc = wrapCCWith rec {

@ -14037,6 +14037,7 @@ with pkgs;
# default. # default.
libcxx ? null libcxx ? null
, extraPackages ? lib.optional (cc.isGNU or false && stdenv.targetPlatform.isMinGW) threadsCross , extraPackages ? lib.optional (cc.isGNU or false && stdenv.targetPlatform.isMinGW) threadsCross
, nixSupport ? {}
, ... , ...
} @ extraArgs: } @ extraArgs:
callPackage ../build-support/cc-wrapper (let self = { callPackage ../build-support/cc-wrapper (let self = {
@ -14048,7 +14049,7 @@ with pkgs;
isGNU = cc.isGNU or false; isGNU = cc.isGNU or false;
isClang = cc.isClang 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); } // extraArgs; in self);
wrapCC = cc: wrapCCWith { wrapCC = cc: wrapCCWith {

Loading…
Cancel
Save