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: 2 additions & 6 deletions pkgs/build-support/cc-wrapper/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@
, 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
}:

assert nativeTools -> !propagateDoc && nativePrefix != "";
Expand Down Expand Up @@ -633,7 +629,7 @@ stdenv.mkDerivation {

# TODO: aarch64-darwin has mcpu incompatible with gcc
+ 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
''

Expand Down Expand Up @@ -729,7 +725,7 @@ stdenv.mkDerivation {
+ optionalString isClang ''
# Escape twice: once for this script, once for the one it gets substituted into.
export march=${escapeShellArg
(optionalString (targetPlatform ? gcc.arch && !disableMarch)
(optionalString (targetPlatform ? gcc.arch)
(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: 3 additions & 7 deletions pkgs/development/compilers/swift/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ 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 = let
# https://github.com/NixOS/nixpkgs/issues/295322
clangNoMarch = swiftLlvmPackages.clang.override { disableMarch = true; };
in
if pkgs.stdenv.isDarwin
clang = if pkgs.stdenv.isDarwin
then
clangNoMarch.override rec {
swiftLlvmPackages.clang.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 @@ -41,7 +37,7 @@ let
inherit (llvmPackages) libcxx;
}
else
clangNoMarch;
swiftLlvmPackages.clang;

# Overrides that create a useful environment for swift packages, allowing
# packaging with `swiftPackages.callPackage`. These are similar to
Expand Down
19 changes: 14 additions & 5 deletions pkgs/development/compilers/swift/wrapper/wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,26 @@ if [[ -e $cc_wrapper/nix-support/add-local-cc-cflags-before.sh ]]; then
source $cc_wrapper/nix-support/add-local-cc-cflags-before.sh
fi

# May need to transform the triple injected by the above.
for ((i = 1; i < ${#extraBefore[@]}; i++)); do
if [[ "${extraBefore[i]}" = -target ]]; then
for ((i=0; i < ${#extraBefore[@]}; i++));do
case "${extraBefore[i]}" in
-target)
i=$((i + 1))
# On Darwin only, need to change 'aarch64' to 'arm64'.
extraBefore[i]="${extraBefore[i]/aarch64-apple-/arm64-apple-}"
# On Darwin, Swift requires the triple to be annotated with a version.
# TODO: Assumes macOS.
extraBefore[i]="${extraBefore[i]/-apple-darwin/-apple-macosx${MACOSX_DEPLOYMENT_TARGET:-11.0}}"
break
fi
;;
-march=*)
[[ i -gt 0 && ${extraBefore[i-1]} == -Xcc ]] && continue
extraBefore=(
"${extraBefore[@]:0:i}"
-Xcc
"${extraBefore[@]:i:${#extraBefore[@]}}"
)
i=$((i + 1))
;;
esac
done

# As a very special hack, if the arguments are just `-v', then don't
Expand Down