about summary refs log tree commit diff
path: root/pkgs/build-support/cc-wrapper/default.nix
diff options
context:
space:
mode:
authorannalee <150648636+a-n-n-a-l-e-e@users.noreply.github.com>2024-03-15 06:06:13 +0000
committerannalee <150648636+a-n-n-a-l-e-e@users.noreply.github.com>2024-03-16 11:02:44 +0000
commit8a7841ceef0a7c7794174178de786ae76cc27457 (patch)
tree52cacd9b438597017271c21b7ac5ee74ed396595 /pkgs/build-support/cc-wrapper/default.nix
parente6aefe20a154a8ba187d6c0bad26eddbcba0d259 (diff)
swift: don't pass -march to swiftc
swiftc uses cc-wrapper which sets the -march flag on some systems which
breaks the build. This change adds a flag, disableMarch, to cc-wrapper
which disables using the -march flag.
https://github.com/NixOS/nixpkgs/issues/295322
Diffstat (limited to 'pkgs/build-support/cc-wrapper/default.nix')
-rw-r--r--pkgs/build-support/cc-wrapper/default.nix8
1 files changed, 6 insertions, 2 deletions
diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix
index d788076dda510..c6c70e0d73eeb 100644
--- a/pkgs/build-support/cc-wrapper/default.nix
+++ b/pkgs/build-support/cc-wrapper/default.nix
@@ -53,6 +53,10 @@
 , gccForLibs ? if useCcForLibs then cc else null
 , fortify-headers ? null
 , includeFortifyHeaders ? null
+
+# https://github.com/NixOS/nixpkgs/issues/295322
+# should -march flag be used
+, disableMarch ? false
 }:
 
 with lib;
@@ -609,7 +613,7 @@ stdenv.mkDerivation {
 
     # TODO: aarch64-darwin has mcpu incompatible with gcc
     + optionalString ((targetPlatform ? gcc.arch) && !isClang && !(stdenv.isDarwin && stdenv.isAarch64) &&
-                      isGccArchSupported targetPlatform.gcc.arch) ''
+                      isGccArchSupported targetPlatform.gcc.arch && !disableMarch) ''
       echo "-march=${targetPlatform.gcc.arch}" >> $out/nix-support/cc-cflags-before
     ''
 
@@ -699,7 +703,7 @@ stdenv.mkDerivation {
     + optionalString isClang ''
       # Escape twice: once for this script, once for the one it gets substituted into.
       export march=${lib.escapeShellArg
-        (lib.optionalString (targetPlatform ? gcc.arch)
+        (lib.optionalString (targetPlatform ? gcc.arch && !disableMarch)
           (lib.escapeShellArg "-march=${targetPlatform.gcc.arch}"))}
       export defaultTarget=${targetPlatform.config}
       substituteAll ${./add-clang-cc-cflags-before.sh} $out/nix-support/add-local-cc-cflags-before.sh