diff --git a/build-scripts/build_llvm.py b/build-scripts/build_llvm.py index 3d241355b4..94e216ce39 100755 --- a/build-scripts/build_llvm.py +++ b/build-scripts/build_llvm.py @@ -23,9 +23,15 @@ def clone_llvm(dst_dir, llvm_repo, llvm_branch): if not llvm_dir.exists(): GIT_CLONE_CMD = f"git clone --depth 1 --branch {llvm_branch} {llvm_repo} llvm" - print(GIT_CLONE_CMD) + print(f"cd {dst_dir} && {GIT_CLONE_CMD}") subprocess.check_output(shlex.split(GIT_CLONE_CMD), cwd=dst_dir) + patch_dir = pathlib.Path(__file__).parent.joinpath("llvm-patches").resolve() + for patch_file in patch_dir.glob("*.patch"): + cmd = f"git apply {patch_file}" + print(f"cd {llvm_dir} && {cmd}") + subprocess.check_output(shlex.split(cmd), cwd=llvm_dir) + return llvm_dir diff --git a/build-scripts/llvm-patches/0001_Add_cstdint_to_SmallVector_101761.patch b/build-scripts/llvm-patches/0001_Add_cstdint_to_SmallVector_101761.patch new file mode 100644 index 0000000000..c7ed0e1658 --- /dev/null +++ b/build-scripts/llvm-patches/0001_Add_cstdint_to_SmallVector_101761.patch @@ -0,0 +1,28 @@ +From aa01bd3a71399edb05fa9b0ab8e0bd35585aa1c5 Mon Sep 17 00:00:00 2001 +From: Sam James +Date: Fri, 2 Aug 2024 23:07:21 +0100 +Subject: [PATCH 1/2] Add `` to SmallVector (#101761) + +SmallVector uses `uint32_t`, `uint64_t` without including `` +which fails to build w/ GCC 15 after a change in libstdc++ [0] + +[0] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=3a817a4a5a6d94da9127af3be9f84a74e3076ee2 +--- + llvm/include/llvm/ADT/SmallVector.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h +index e34702bdb..1c0f3465b 100644 +--- a/llvm/include/llvm/ADT/SmallVector.h ++++ b/llvm/include/llvm/ADT/SmallVector.h +@@ -19,6 +19,7 @@ + #include + #include + #include ++#include + #include + #include + #include +-- +2.51.0 + diff --git a/build-scripts/llvm-patches/0002_Add_missing_include_to_X86MCTargetDesc.h_123320.patch b/build-scripts/llvm-patches/0002_Add_missing_include_to_X86MCTargetDesc.h_123320.patch new file mode 100644 index 0000000000..29c640cd8d --- /dev/null +++ b/build-scripts/llvm-patches/0002_Add_missing_include_to_X86MCTargetDesc.h_123320.patch @@ -0,0 +1,32 @@ +From 3ba14e5ea319e138f8d0f5c06fd2f76d425e4093 Mon Sep 17 00:00:00 2001 +From: Stephan Hageboeck +Date: Mon, 20 Jan 2025 17:52:47 +0100 +Subject: [PATCH 2/2] 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 +--- + 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 d0530bd4d..10b59462a 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.51.0 +