Skip to content

Commit

Permalink
apacheGH-35018: [CI][Java][C++] Use ARROW_ZSTD_USE_SHARED=OFF for LLVM (
Browse files Browse the repository at this point in the history
apache#35023)

### Rationale for this change

LLVM may use Zstandard. For example `llvm@ 15` in Homebrew uses Zstandard. LLVM finds
Zstandared by itself. So libzstd.dylib may be used even when `ARROW_ZSTD_USE_SHARED` is `OFF`.

### What changes are included in this PR?

This change adjusts Zstandared used by LLVM to reflect `ARROW_ZSTD_USE_SHARED`.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

Yes.
* Closes: apache#35018

Authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
kou authored and rtpsw committed May 16, 2023
1 parent a334a06 commit 8737445
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cpp/cmake_modules/FindLLVMAlt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ if(LLVM_FOUND)
add_library(LLVM::LLVM_LIBS INTERFACE IMPORTED)
set_target_properties(LLVM::LLVM_LIBS PROPERTIES INTERFACE_LINK_LIBRARIES
"${LLVM_LIBS}")

if(TARGET LLVMSupport AND NOT ARROW_ZSTD_USE_SHARED)
get_target_property(LLVM_SUPPORT_INTERFACE_LINK_LIBRARIES LLVMSupport
INTERFACE_LINK_LIBRARIES)
list(FIND LLVM_SUPPORT_INTERFACE_LINK_LIBRARIES zstd::libzstd_shared
LLVM_SUPPORT_LIBZSTD_INDEX)
if(NOT LLVM_SUPPORT_LIBZSTD_INDEX EQUAL -1)
list(REMOVE_AT LLVM_SUPPORT_INTERFACE_LINK_LIBRARIES ${LLVM_SUPPORT_LIBZSTD_INDEX})
list(INSERT LLVM_SUPPORT_INTERFACE_LINK_LIBRARIES ${LLVM_SUPPORT_LIBZSTD_INDEX}
zstd::libzstd_static)
endif()
set_target_properties(LLVMSupport
PROPERTIES INTERFACE_LINK_LIBRARIES
"${LLVM_SUPPORT_INTERFACE_LINK_LIBRARIES}")
endif()
endif()

mark_as_advanced(CLANG_EXECUTABLE LLVM_LINK_EXECUTABLE)
Expand Down
3 changes: 3 additions & 0 deletions cpp/src/gandiva/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ add_dependencies(gandiva-all gandiva gandiva-tests gandiva-benchmarks)

find_package(LLVMAlt REQUIRED)
provide_find_module(LLVMAlt "Gandiva")
if(ARROW_WITH_ZSTD)
provide_find_module(zstdAlt "Gandiva")
endif()

add_definitions(-DGANDIVA_LLVM_VERSION=${LLVM_VERSION_MAJOR})

Expand Down
3 changes: 3 additions & 0 deletions cpp/src/gandiva/GandivaConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ else()
unset(GANDIVA_CMAKE_MODULE_PATH_OLD)
endif()
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
if(ARROW_WITH_ZSTD)
find_dependency(zstdAlt)
endif()
find_dependency(LLVMAlt)
if(DEFINED GANDIVA_CMAKE_MODULE_PATH_OLD)
set(CMAKE_MODULE_PATH ${GANDIVA_CMAKE_MODULE_PATH_OLD})
Expand Down

0 comments on commit 8737445

Please sign in to comment.