Skip to content

Commit 039dd17

Browse files
committed
build: fix LLVM 18 build on GCC 15
See also: referenced LLVM pull requests in patch files.
1 parent 3f4145e commit 039dd17

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

build-scripts/build_llvm.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ def clone_llvm(dst_dir, llvm_repo, llvm_branch):
2323

2424
if not llvm_dir.exists():
2525
GIT_CLONE_CMD = f"git clone --depth 1 --branch {llvm_branch} {llvm_repo} llvm"
26-
print(GIT_CLONE_CMD)
26+
print(f"cd {dst_dir} && {GIT_CLONE_CMD}")
2727
subprocess.check_output(shlex.split(GIT_CLONE_CMD), cwd=dst_dir)
2828

29+
patch_dir = pathlib.Path(__file__).parent.joinpath("llvm-patches").resolve()
30+
for patch_file in patch_dir.glob("*.patch"):
31+
cmd = f"git apply {patch_file}"
32+
print(f"cd {llvm_dir} && {cmd}")
33+
subprocess.check_output(shlex.split(cmd), cwd=llvm_dir)
34+
2935
return llvm_dir
3036

3137

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From aa01bd3a71399edb05fa9b0ab8e0bd35585aa1c5 Mon Sep 17 00:00:00 2001
2+
From: Sam James <[email protected]>
3+
Date: Fri, 2 Aug 2024 23:07:21 +0100
4+
Subject: [PATCH 1/2] Add `<cstdint>` to SmallVector (#101761)
5+
6+
SmallVector uses `uint32_t`, `uint64_t` without including `<cstdint>`
7+
which fails to build w/ GCC 15 after a change in libstdc++ [0]
8+
9+
[0] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=3a817a4a5a6d94da9127af3be9f84a74e3076ee2
10+
---
11+
llvm/include/llvm/ADT/SmallVector.h | 1 +
12+
1 file changed, 1 insertion(+)
13+
14+
diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h
15+
index e34702bdb..1c0f3465b 100644
16+
--- a/llvm/include/llvm/ADT/SmallVector.h
17+
+++ b/llvm/include/llvm/ADT/SmallVector.h
18+
@@ -19,6 +19,7 @@
19+
#include <algorithm>
20+
#include <cassert>
21+
#include <cstddef>
22+
+#include <cstdint>
23+
#include <cstdlib>
24+
#include <cstring>
25+
#include <functional>
26+
--
27+
2.51.0
28+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
From 3ba14e5ea319e138f8d0f5c06fd2f76d425e4093 Mon Sep 17 00:00:00 2001
2+
From: Stephan Hageboeck <[email protected]>
3+
Date: Mon, 20 Jan 2025 17:52:47 +0100
4+
Subject: [PATCH 2/2] Add missing include to X86MCTargetDesc.h (#123320)
5+
6+
In gcc-15, explicit includes of `<cstdint>` are required when fixed-size
7+
integers are used. In this file, this include only happened as a side
8+
effect of including SmallVector.h
9+
10+
Although llvm compiles fine, the root-project would benefit from
11+
explicitly including it here, so we can backport the patch.
12+
13+
Maybe interesting for @hahnjo and @vgvassilev
14+
---
15+
llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h | 1 +
16+
1 file changed, 1 insertion(+)
17+
18+
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
19+
index d0530bd4d..10b59462a 100644
20+
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
21+
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
22+
@@ -13,6 +13,7 @@
23+
#ifndef LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
24+
#define LLVM_LIB_TARGET_X86_MCTARGETDESC_X86MCTARGETDESC_H
25+
26+
+#include <cstdint>
27+
#include <memory>
28+
#include <string>
29+
30+
--
31+
2.51.0
32+

0 commit comments

Comments
 (0)