gallivm: support LLVM 21
Some checks are pending
macOS-CI / macOS-CI (dri) (push) Waiting to run
macOS-CI / macOS-CI (xlib) (push) Waiting to run

LLVM PR#146819 changed the signature of `setObjectLinkingLayerCreator`,
dropping the Triple argument. The PR was first included in the LLVM 21
series, and the new signature is gated behind a version check for that.

`LLVMOrcThreadSafeContextGetContext` was removed in LLVM commit b18e5b6,
and the ORC examples in the LLVM tree seem to just create a context
instead, which we replicate here.

With this commit, mesa successfully builds the llvmpipe gallium driver
on riscv64 with LLVM 21.1.0.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13785
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13852

Reviewed-by: David Heidelberg <david@ixit.cz>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37027>
This commit is contained in:
no92 2025-08-27 16:02:31 +02:00 committed by Marge Bot
parent dea20be1b3
commit cd129dbf8a

View file

@ -339,7 +339,12 @@ LPJit::LPJit() :jit_dylib_count(0) {
.setJITTargetMachineBuilder(std::move(JTMB)) .setJITTargetMachineBuilder(std::move(JTMB))
#ifdef USE_JITLINK #ifdef USE_JITLINK
.setObjectLinkingLayerCreator( .setObjectLinkingLayerCreator(
#if LLVM_VERSION_MAJOR >= 21
/* LLVM 21 removed the Triple argument */
[&](ExecutionSession &ES) {
#else
[&](ExecutionSession &ES, const llvm::Triple &TT) { [&](ExecutionSession &ES, const llvm::Triple &TT) {
#endif
return std::make_unique<ObjectLinkingLayer>( return std::make_unique<ObjectLinkingLayer>(
ES, ExitOnErr(llvm::jitlink::InProcessMemoryManager::Create())); ES, ExitOnErr(llvm::jitlink::InProcessMemoryManager::Create()));
}) })
@ -551,7 +556,7 @@ init_gallivm_state(struct gallivm_state *gallivm, const char *name,
gallivm->cache = cache; gallivm->cache = cache;
gallivm->_ts_context = context->ref; gallivm->_ts_context = context->ref;
gallivm->context = LLVMOrcThreadSafeContextGetContext(context->ref); gallivm->context = LLVMContextCreate();
gallivm->module_name = LPJit::get_unique_name(name); gallivm->module_name = LPJit::get_unique_name(name);
gallivm->module = LLVMModuleCreateWithNameInContext(gallivm->module_name, gallivm->module = LLVMModuleCreateWithNameInContext(gallivm->module_name,