mesa: fix build with llvm 21 on exotic platforms (#447955)

authored by K900 and committed by GitHub 052687bd ac63607b

Changed files
+55
pkgs
development
+2
pkgs/development/libraries/mesa/default.nix
··· 144 144 145 145 patches = [ 146 146 ./opencl.patch 147 + # https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37027 148 + ./gallivm-llvm-21.patch 147 149 ]; 148 150 149 151 postPatch = ''
+53
pkgs/development/libraries/mesa/gallivm-llvm-21.patch
··· 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 5 + 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. 9 + 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. 13 + 14 + With this commit, mesa successfully builds the llvmpipe gallium driver 15 + on riscv64 with LLVM 21.1.0. 16 + 17 + Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13785 18 + Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13852 19 + 20 + Reviewed-by: David Heidelberg <david@ixit.cz> 21 + --- 22 + src/gallium/auxiliary/gallivm/lp_bld_init_orc.cpp | 7 ++++++- 23 + 1 file changed, 6 insertions(+), 1 deletion(-) 24 + 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)) 31 + #ifdef USE_JITLINK 32 + .setObjectLinkingLayerCreator( 33 + +#if LLVM_VERSION_MAJOR >= 21 34 + + /* LLVM 21 removed the Triple argument */ 35 + + [&](ExecutionSession &ES) { 36 + +#else 37 + [&](ExecutionSession &ES, const llvm::Triple &TT) { 38 + +#endif 39 + return std::make_unique<ObjectLinkingLayer>( 40 + ES, ExitOnErr(llvm::jitlink::InProcessMemoryManager::Create())); 41 + }) 42 + @@ -552,7 +557,7 @@ init_gallivm_state(struct gallivm_state *gallivm, const char *name, 43 + gallivm->cache = cache; 44 + 45 + gallivm->_ts_context = context->ref; 46 + - gallivm->context = LLVMOrcThreadSafeContextGetContext(context->ref); 47 + + gallivm->context = LLVMContextCreate(); 48 + 49 + gallivm->module_name = LPJit::get_unique_name(name); 50 + gallivm->module = LLVMModuleCreateWithNameInContext(gallivm->module_name, 51 + -- 52 + GitLab 53 +