mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-20 04:19:00 +02:00
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
This commit is contained in:
parent
e6aefe20a1
commit
8a7841ceef
|
@ -53,6 +53,10 @@
|
||||||
, gccForLibs ? if useCcForLibs then cc else null
|
, gccForLibs ? if useCcForLibs then cc else null
|
||||||
, fortify-headers ? null
|
, fortify-headers ? null
|
||||||
, includeFortifyHeaders ? null
|
, includeFortifyHeaders ? null
|
||||||
|
|
||||||
|
# https://github.com/NixOS/nixpkgs/issues/295322
|
||||||
|
# should -march flag be used
|
||||||
|
, disableMarch ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
@ -609,7 +613,7 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
# TODO: aarch64-darwin has mcpu incompatible with gcc
|
# TODO: aarch64-darwin has mcpu incompatible with gcc
|
||||||
+ optionalString ((targetPlatform ? gcc.arch) && !isClang && !(stdenv.isDarwin && stdenv.isAarch64) &&
|
+ 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
|
echo "-march=${targetPlatform.gcc.arch}" >> $out/nix-support/cc-cflags-before
|
||||||
''
|
''
|
||||||
|
|
||||||
|
@ -699,7 +703,7 @@ stdenv.mkDerivation {
|
||||||
+ optionalString isClang ''
|
+ optionalString isClang ''
|
||||||
# Escape twice: once for this script, once for the one it gets substituted into.
|
# Escape twice: once for this script, once for the one it gets substituted into.
|
||||||
export march=${lib.escapeShellArg
|
export march=${lib.escapeShellArg
|
||||||
(lib.optionalString (targetPlatform ? gcc.arch)
|
(lib.optionalString (targetPlatform ? gcc.arch && !disableMarch)
|
||||||
(lib.escapeShellArg "-march=${targetPlatform.gcc.arch}"))}
|
(lib.escapeShellArg "-march=${targetPlatform.gcc.arch}"))}
|
||||||
export defaultTarget=${targetPlatform.config}
|
export defaultTarget=${targetPlatform.config}
|
||||||
substituteAll ${./add-clang-cc-cflags-before.sh} $out/nix-support/add-local-cc-cflags-before.sh
|
substituteAll ${./add-clang-cc-cflags-before.sh} $out/nix-support/add-local-cc-cflags-before.sh
|
||||||
|
|
|
@ -25,9 +25,13 @@ let
|
||||||
#
|
#
|
||||||
# The following selects the correct Clang version, matching the version
|
# The following selects the correct Clang version, matching the version
|
||||||
# used in Swift, and applies the same libc overrides as `apple_sdk.stdenv`.
|
# used in Swift, and applies the same libc overrides as `apple_sdk.stdenv`.
|
||||||
clang = if pkgs.stdenv.isDarwin
|
clang = let
|
||||||
|
# https://github.com/NixOS/nixpkgs/issues/295322
|
||||||
|
clangNoMarch = swiftLlvmPackages.clang.override { disableMarch = true; };
|
||||||
|
in
|
||||||
|
if pkgs.stdenv.isDarwin
|
||||||
then
|
then
|
||||||
swiftLlvmPackages.clang.override rec {
|
clangNoMarch.override rec {
|
||||||
libc = apple_sdk.Libsystem;
|
libc = apple_sdk.Libsystem;
|
||||||
bintools = pkgs.bintools.override { inherit libc; };
|
bintools = pkgs.bintools.override { inherit libc; };
|
||||||
# Ensure that Swift’s internal clang uses the same libc++ and libc++abi as the
|
# Ensure that Swift’s internal clang uses the same libc++ and libc++abi as the
|
||||||
|
@ -45,7 +49,7 @@ let
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
swiftLlvmPackages.clang;
|
clangNoMarch;
|
||||||
|
|
||||||
# Overrides that create a useful environment for swift packages, allowing
|
# Overrides that create a useful environment for swift packages, allowing
|
||||||
# packaging with `swiftPackages.callPackage`. These are similar to
|
# packaging with `swiftPackages.callPackage`. These are similar to
|
||||||
|
|
Loading…
Reference in a new issue