From 0650c7b316904fea07de0ec5f08274e9a465fe18 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Fri, 30 Jan 2026 11:51:54 -0400 Subject: [PATCH] swift.swift: fix linux build --- .../compilers/swift/compiler/default.nix | 17 ++++++++++ ...vm-fix-X86MCTargetDesc-compile-error.patch | 34 +++++++++++++++++++ .../patches/swift-linux-fix-libc-paths.patch | 4 +-- .../compilers/swift/wrapper/wrapper.sh | 2 +- 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/compilers/swift/compiler/patches/llvm-fix-X86MCTargetDesc-compile-error.patch diff --git a/pkgs/development/compilers/swift/compiler/default.nix b/pkgs/development/compilers/swift/compiler/default.nix index 8c1437f80a28..2f6fa2a9450f 100644 --- a/pkgs/development/compilers/swift/compiler/default.nix +++ b/pkgs/development/compilers/swift/compiler/default.nix @@ -348,6 +348,17 @@ stdenv.mkDerivation { patch -p1 -d swift -i $TMPDIR/swift-separate-lib.patch patch -p1 -d llvm-project/llvm -i ${./patches/llvm-module-cache.patch} + for root in llvm-project/llvm swift/stdlib; do + patch -p1 -d $root -i ${ + (fetchpatch { + name = "fix-SmallVector-compile-error.patch"; + url = "https://github.com/llvm/llvm-project/commit/7e44305041d96b064c197216b931ae3917a34ac1.patch"; + stripLen = 1; + hash = "sha256-1htuzsaPHbYgravGc1vrR8sqpQ/NSQ8PUZeAU8ucCFk="; + }) + } + done + patch -p2 -d llvm-project/llvm -i ${./patches/llvm-fix-X86MCTargetDesc-compile-error.patch} for lldbPatch in ${ lib.escapeShellArgs [ @@ -363,6 +374,12 @@ stdenv.mkDerivation { stripLen = 1; hash = "sha256-QCGhsL/mi7610ZNb5SqxjRGjwJeK2rwtsFVGeG3PUGc="; }) + (fetchpatch { + name = "LLDB-Add-cstdint-to-AddressableBits-102110.patch"; + url = "https://github.com/llvm/llvm-project/commit/bb59f04e7e75dcbe39f1bf952304a157f0035314.patch"; + stripLen = 1; + hash = "sha256-+CcmZRxCaozFe1Kuf2HX+kGKuh/PDuoFBEFA/t7tL9A="; + }) ] }; do patch -p1 -d llvm-project/lldb -i $lldbPatch diff --git a/pkgs/development/compilers/swift/compiler/patches/llvm-fix-X86MCTargetDesc-compile-error.patch b/pkgs/development/compilers/swift/compiler/patches/llvm-fix-X86MCTargetDesc-compile-error.patch new file mode 100644 index 000000000000..3ced4d2c32b8 --- /dev/null +++ b/pkgs/development/compilers/swift/compiler/patches/llvm-fix-X86MCTargetDesc-compile-error.patch @@ -0,0 +1,34 @@ +From f03ab75680385b1ea62af3ab15c423a3bc0f3588 Mon Sep 17 00:00:00 2001 +From: Stephan Hageboeck +Date: Mon, 20 Jan 2025 17:52:47 +0100 +Subject: [PATCH] Add missing include to X86MCTargetDesc.h (#123320) + +In gcc-15, explicit includes of `` are required when fixed-size +integers are used. In this file, this include only happened as a side +effect of including SmallVector.h + +Although llvm compiles fine, the root-project would benefit from +explicitly including it here, so we can backport the patch. + +Maybe interesting for @hahnjo and @vgvassilev + +(cherry picked from commit 7abf44069aec61eee147ca67a6333fc34583b524) +--- + llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h +index d0530bd4d650..10b59462aebe 100644 +--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h ++++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h +@@ -13,6 +13,7 @@ + #ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H + #define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H + ++#include + #include + #include + +-- +2.52.0 + diff --git a/pkgs/development/compilers/swift/compiler/patches/swift-linux-fix-libc-paths.patch b/pkgs/development/compilers/swift/compiler/patches/swift-linux-fix-libc-paths.patch index a2e84a193dd4..61915c66f503 100644 --- a/pkgs/development/compilers/swift/compiler/patches/swift-linux-fix-libc-paths.patch +++ b/pkgs/development/compilers/swift/compiler/patches/swift-linux-fix-libc-paths.patch @@ -21,10 +21,10 @@ patch it to also consider `-idirafter` and `-isystem` as added by cc-wrapper. + llvm::append_range(includeDirs, + DriverArgs.getAllArgValues( + clang::driver::options::OPT_idirafter)); -+ // Nix adds the C++ stdlib include path using `-isystem`. ++ // Nix adds the C++ stdlib include path using `-cxx-isystem`. + llvm::append_range(includeDirs, + DriverArgs.getAllArgValues( -+ clang::driver::options::OPT_isystem)); ++ clang::driver::options::OPT_cxx_isystem)); for (const auto &includeDir : includeDirs) { Path dir(includeDir); diff --git a/pkgs/development/compilers/swift/wrapper/wrapper.sh b/pkgs/development/compilers/swift/wrapper/wrapper.sh index 2017f580cef2..77f7c31d6812 100644 --- a/pkgs/development/compilers/swift/wrapper/wrapper.sh +++ b/pkgs/development/compilers/swift/wrapper/wrapper.sh @@ -188,7 +188,7 @@ addCFlagsToList() { # Pass through using -Xcc, but also convert to Swift -I. # These have slightly different meaning for Clang, but Swift # doesn't have exact equivalents. - -isystem | -idirafter) + -isystem | -cxx-isystem | -idirafter) i=$((i + 1)) list+=("-Xcc" "$val" "-Xcc" "${!i}" "-I" "${!i}") ;;