···
1
+
From eca19331d94005485de5246cfa87a21621486cd8 Mon Sep 17 00:00:00 2001
2
+
From: no92 <no92.mail@gmail.com>
3
+
Date: Wed, 27 Aug 2025 16:02:31 +0200
4
+
Subject: [PATCH] gallivm: support LLVM 21
6
+
LLVM PR#146819 changed the signature of `setObjectLinkingLayerCreator`,
7
+
dropping the Triple argument. The PR was first included in the LLVM 21
8
+
series, and the new signature is gated behind a version check for that.
10
+
`LLVMOrcThreadSafeContextGetContext` was removed in LLVM commit b18e5b6,
11
+
and the ORC examples in the LLVM tree seem to just create a context
12
+
instead, which we replicate here.
14
+
With this commit, mesa successfully builds the llvmpipe gallium driver
15
+
on riscv64 with LLVM 21.1.0.
17
+
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13785
18
+
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13852
20
+
Reviewed-by: David Heidelberg <david@ixit.cz>
22
+
src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp | 7 ++++++-
23
+
1 file changed, 6 insertions(+), 1 deletion(-)
25
+
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp
26
+
index 3d2b8cf81bc0c..0be69b02b6eef 100644
27
+
--- a/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp
28
+
+++ b/src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp
29
+
@@ -340,7 +340,12 @@ LPJit::LPJit() :jit_dylib_count(0) {
30
+
.setJITTargetMachineBuilder(std::move(JTMB))
32
+
.setObjectLinkingLayerCreator(
33
+
+#if LLVM_VERSION_MAJOR >= 21
34
+
+ /* LLVM 21 removed the Triple argument */
35
+
+ [&](ExecutionSession &ES) {
37
+
[&](ExecutionSession &ES, const llvm::Triple &TT) {
39
+
return std::make_unique<ObjectLinkingLayer>(
40
+
ES, ExitOnErr(llvm::jitlink::InProcessMemoryManager::Create()));
42
+
@@ -552,7 +557,7 @@ init_gallivm_state(struct gallivm_state *gallivm, const char *name,
43
+
gallivm->cache = cache;
45
+
gallivm->_ts_context = context->ref;
46
+
- gallivm->context = LLVMOrcThreadSafeContextGetContext(context->ref);
47
+
+ gallivm->context = LLVMContextCreate();
49
+
gallivm->module_name = LPJit::get_unique_name(name);
50
+
gallivm->module = LLVMModuleCreateWithNameInContext(gallivm->module_name,