Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
''

Expand Down Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions pkgs/development/compilers/swift/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down