Merge pull request #296082 from a-n-n-a-l-e-e/dont-pass-march-swift
swift: don't pass -march to swiftc
This commit is contained in:
commit
8c421f78b2
2 changed files with 13 additions and 5 deletions
|
@ -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
|
||||
''
|
||||
|
||||
|
@ -705,7 +709,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
|
||||
|
|
|
@ -25,9 +25,13 @@ let
|
|||
#
|
||||
# The following selects the correct Clang version, matching the version
|
||||
# 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
|
||||
swiftLlvmPackages.clang.override rec {
|
||||
clangNoMarch.override rec {
|
||||
libc = apple_sdk.Libsystem;
|
||||
bintools = pkgs.bintools.override { inherit libc; };
|
||||
# Ensure that Swift’s internal clang uses the same libc++ and libc++abi as the
|
||||
|
@ -45,7 +49,7 @@ let
|
|||
];
|
||||
}
|
||||
else
|
||||
swiftLlvmPackages.clang;
|
||||
clangNoMarch;
|
||||
|
||||
# Overrides that create a useful environment for swift packages, allowing
|
||||
# packaging with `swiftPackages.callPackage`. These are similar to
|
||||
|
|
Loading…
Reference in a new issue