swift.swift: fix linux build

This commit is contained in:
David McFarland
2026-02-10 23:26:07 -04:00
parent 413a3b119a
commit 0650c7b316
4 changed files with 54 additions and 3 deletions
@@ -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
@@ -0,0 +1,34 @@
From f03ab75680385b1ea62af3ab15c423a3bc0f3588 Mon Sep 17 00:00:00 2001
From: Stephan Hageboeck <stephan.hageboeck@cern.ch>
Date: Mon, 20 Jan 2025 17:52:47 +0100
Subject: [PATCH] Add missing include to X86MCTargetDesc.h (#123320)
In gcc-15, explicit includes of `<cstdint>` 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 <cstdint>
#include <memory>
#include <string>
--
2.52.0
@@ -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);
@@ -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}")
;;