This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 57b4b4b77d GH-47469: [C++][Gandiva] Add support for LLVM 21.1.0
(#47473)
57b4b4b77d is described below
commit 57b4b4b77df5ae77910a91b171fa924d4ce78247
Author: Raúl Cumplido <[email protected]>
AuthorDate: Tue Sep 2 22:31:16 2025 +0200
GH-47469: [C++][Gandiva] Add support for LLVM 21.1.0 (#47473)
### Rationale for this change
LLVM 21.1 was released and some of our CI jobs are failing.
### What changes are included in this PR?
* Accept LLVM 21.1
* Don't use deprecated API
Two of the related commits that changed APIs on LLVM are:
-
https://github.com/llvm/llvm-project/commit/034f2b380bd2d84e8cfbcb647b50602711d170c7
-
https://github.com/llvm/llvm-project/commit/b18e5b6a36399f11ba1152875b6892900c5afdaf
### Are these changes tested?
Yes on CI
### Are there any user-facing changes?
No
* GitHub Issue: #47469
Authored-by: Raúl Cumplido <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
cpp/CMakeLists.txt | 1 +
cpp/src/gandiva/engine.cc | 6 ++++++
cpp/src/gandiva/llvm_types.h | 4 ++++
3 files changed, 11 insertions(+)
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 18841ac874..5d3d58cb12 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -177,6 +177,7 @@ set(ARROW_DOC_DIR "share/doc/${PROJECT_NAME}")
set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/build-support")
set(ARROW_LLVM_VERSIONS
+ "21.1"
"20.1"
"19.1"
"18.1"
diff --git a/cpp/src/gandiva/engine.cc b/cpp/src/gandiva/engine.cc
index 6148cfab74..8457e5c425 100644
--- a/cpp/src/gandiva/engine.cc
+++ b/cpp/src/gandiva/engine.cc
@@ -202,10 +202,16 @@ Status UseJITLinkIfEnabled(llvm::orc::LLJITBuilder&
jit_builder) {
static auto maybe_use_jit_link =
::arrow::internal::GetEnvVar("GANDIVA_USE_JIT_LINK");
if (maybe_use_jit_link.ok()) {
ARROW_ASSIGN_OR_RAISE(static auto memory_manager, CreateMemmoryManager());
+# if LLVM_VERSION_MAJOR >= 21
+ jit_builder.setObjectLinkingLayerCreator([&](llvm::orc::ExecutionSession&
ES) {
+ return std::make_unique<llvm::orc::ObjectLinkingLayer>(ES,
*memory_manager);
+ });
+# else
jit_builder.setObjectLinkingLayerCreator(
[&](llvm::orc::ExecutionSession& ES, const llvm::Triple& TT) {
return std::make_unique<llvm::orc::ObjectLinkingLayer>(ES,
*memory_manager);
});
+# endif
}
return Status::OK();
}
diff --git a/cpp/src/gandiva/llvm_types.h b/cpp/src/gandiva/llvm_types.h
index 3541e5e404..04715391ff 100644
--- a/cpp/src/gandiva/llvm_types.h
+++ b/cpp/src/gandiva/llvm_types.h
@@ -56,7 +56,11 @@ class GANDIVA_EXPORT LLVMTypes {
llvm::Type* double_type() { return llvm::Type::getDoubleTy(context_); }
llvm::PointerType* ptr_type(llvm::Type* type) {
+#if LLVM_VERSION_MAJOR >= 21
+ return llvm::PointerType::get(context_, 0);
+#else
return llvm::PointerType::get(type, 0);
+#endif
}
llvm::PointerType* i8_ptr_type() { return ptr_type(i8_type()); }