Revert "swift: don't pass -march to swiftc"

This reverts commit 8a7841ceef.
This commit is contained in:
Sam 2024-04-02 19:21:49 -07:00
parent 9fd2efac08
commit f86158cd9a
No known key found for this signature in database
GPG Key ID: 07C4B9795517E3B4
2 changed files with 5 additions and 13 deletions

View File

@ -53,10 +53,6 @@
, 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
}: }:
assert nativeTools -> !propagateDoc && nativePrefix != ""; assert nativeTools -> !propagateDoc && nativePrefix != "";
@ -633,7 +629,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 && !disableMarch) '' isGccArchSupported targetPlatform.gcc.arch) ''
echo "-march=${targetPlatform.gcc.arch}" >> $out/nix-support/cc-cflags-before echo "-march=${targetPlatform.gcc.arch}" >> $out/nix-support/cc-cflags-before
'' ''
@ -729,7 +725,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=${escapeShellArg export march=${escapeShellArg
(optionalString (targetPlatform ? gcc.arch && !disableMarch) (optionalString (targetPlatform ? gcc.arch)
(escapeShellArg "-march=${targetPlatform.gcc.arch}"))} (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

View File

@ -25,13 +25,9 @@ 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 = let clang = if pkgs.stdenv.isDarwin
# https://github.com/NixOS/nixpkgs/issues/295322
clangNoMarch = swiftLlvmPackages.clang.override { disableMarch = true; };
in
if pkgs.stdenv.isDarwin
then then
clangNoMarch.override rec { swiftLlvmPackages.clang.override rec {
libc = apple_sdk.Libsystem; libc = apple_sdk.Libsystem;
bintools = pkgs.bintools.override { inherit libc; }; bintools = pkgs.bintools.override { inherit libc; };
# Ensure that Swifts internal clang uses the same libc++ and libc++abi as the # Ensure that Swifts internal clang uses the same libc++ and libc++abi as the
@ -41,7 +37,7 @@ let
inherit (llvmPackages) libcxx; inherit (llvmPackages) libcxx;
} }
else else
clangNoMarch; swiftLlvmPackages.clang;
# 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