Skip to content

Commit

Permalink
GH-45225: [C++] Upgrade ORC to 2.1.0 (#45226)
Browse files Browse the repository at this point in the history
### Rationale for this change

Apache ORC has just released 2.1.0: https://orc.apache.org/news/2025/01/09/ORC-2.1.0/

We need to upgrade it to avoid occasional download failures of orc-format.

### What changes are included in this PR?

Bump Apache ORC to its latest version 2.1.0.

### Are these changes tested?

Pass CIs.

### Are there any user-facing changes?

No.
* GitHub Issue: #45225

Lead-authored-by: Gang Wu <[email protected]>
Co-authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Gang Wu <[email protected]>
  • Loading branch information
wgtmac and kou authored Jan 14, 2025
1 parent 0758845 commit 7fc8222
Show file tree
Hide file tree
Showing 9 changed files with 319 additions and 23 deletions.
1 change: 1 addition & 0 deletions ci/docker/debian-12-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ RUN apt-get update -y -q && \
ninja-build \
nlohmann-json3-dev \
npm \
patch \
pkg-config \
protobuf-compiler-grpc \
python3-dev \
Expand Down
1 change: 1 addition & 0 deletions ci/docker/ubuntu-20.04-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ RUN apt-get update -y -q && \
ninja-build \
nlohmann-json3-dev \
npm \
patch \
pkg-config \
protobuf-compiler \
python3-dev \
Expand Down
1 change: 1 addition & 0 deletions ci/docker/ubuntu-22.04-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ RUN apt-get update -y -q && \
ninja-build \
nlohmann-json3-dev \
npm \
patch \
pkg-config \
protobuf-compiler \
protobuf-compiler-grpc \
Expand Down
1 change: 1 addition & 0 deletions ci/docker/ubuntu-24.04-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ RUN apt-get update -y -q && \
ninja-build \
nlohmann-json3-dev \
npm \
patch \
pkg-config \
protobuf-compiler \
protobuf-compiler-grpc \
Expand Down
29 changes: 16 additions & 13 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4573,11 +4573,16 @@ target_include_directories(arrow::hadoop INTERFACE "${HADOOP_HOME}/include")
function(build_orc)
message(STATUS "Building Apache ORC from source")

# Remove this and "patch" in "ci/docker/{debian,ubuntu}-*.dockerfile" once we have a patch for ORC 2.1.1
find_program(PATCH patch REQUIRED)
set(ORC_PATCH_COMMAND ${PATCH} -p1 -i ${CMAKE_CURRENT_LIST_DIR}/orc.diff)

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.29)
fetchcontent_declare(orc
${FC_DECLARE_COMMON_OPTIONS}
URL ${ORC_SOURCE_URL}
URL_HASH "SHA256=${ARROW_ORC_BUILD_SHA256_CHECKSUM}")
URL_HASH "SHA256=${ARROW_ORC_BUILD_SHA256_CHECKSUM}"
PATCH_COMMAND ${ORC_PATCH_COMMAND})
prepare_fetchcontent()

set(CMAKE_UNITY_BUILD FALSE)
Expand Down Expand Up @@ -4667,16 +4672,10 @@ function(build_orc)
OFF
CACHE BOOL "" FORCE)

# We can remove this with ORC 2.0.2 or later.
list(PREPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_BINARY_DIR}/_deps/orc-src/cmake_modules)

fetchcontent_makeavailable(orc)

add_library(orc::orc INTERFACE IMPORTED)
target_link_libraries(orc::orc INTERFACE orc)
target_include_directories(orc::orc INTERFACE "${orc_BINARY_DIR}/c++/include"
"${orc_SOURCE_DIR}/c++/include")

list(APPEND ARROW_BUNDLED_STATIC_LIBS orc)
else()
Expand All @@ -4701,6 +4700,9 @@ function(build_orc)
get_target_property(ORC_ZSTD_ROOT ${ARROW_ZSTD_LIBZSTD} INTERFACE_INCLUDE_DIRECTORIES)
get_filename_component(ORC_ZSTD_ROOT "${ORC_ZSTD_ROOT}" DIRECTORY)

get_target_property(ORC_ZLIB_ROOT ZLIB::ZLIB INTERFACE_INCLUDE_DIRECTORIES)
get_filename_component(ORC_ZLIB_ROOT "${ORC_ZLIB_ROOT}" DIRECTORY)

set(ORC_CMAKE_ARGS
${EP_COMMON_CMAKE_ARGS}
"-DCMAKE_INSTALL_PREFIX=${ORC_PREFIX}"
Expand All @@ -4710,24 +4712,24 @@ function(build_orc)
-DBUILD_TOOLS=OFF
-DBUILD_CPP_TESTS=OFF
-DINSTALL_VENDORED_LIBS=OFF
"-DLZ4_HOME=${ORC_LZ4_ROOT}"
"-DPROTOBUF_EXECUTABLE=$<TARGET_FILE:${ARROW_PROTOBUF_PROTOC}>"
"-DPROTOBUF_HOME=${ORC_PROTOBUF_ROOT}"
"-DPROTOBUF_INCLUDE_DIR=$<TARGET_PROPERTY:${ARROW_PROTOBUF_LIBPROTOBUF},INTERFACE_INCLUDE_DIRECTORIES>"
"-DPROTOBUF_LIBRARY=$<TARGET_FILE:${ARROW_PROTOBUF_LIBPROTOBUF}>"
"-DPROTOC_LIBRARY=$<TARGET_FILE:${ARROW_PROTOBUF_LIBPROTOC}>"
"-DSNAPPY_HOME=${ORC_SNAPPY_ROOT}"
"-DSNAPPY_LIBRARY=$<TARGET_FILE:${Snappy_TARGET}>"
"-DLZ4_HOME=${ORC_LZ4_ROOT}"
"-DLZ4_LIBRARY=$<TARGET_FILE:LZ4::lz4>"
"-DLZ4_STATIC_LIB=$<TARGET_FILE:LZ4::lz4>"
"-DLZ4_INCLUDE_DIR=${ORC_LZ4_ROOT}/include"
"-DSNAPPY_INCLUDE_DIR=${ORC_SNAPPY_INCLUDE_DIR}"
"-DZSTD_HOME=${ORC_ZSTD_ROOT}"
"-DZSTD_INCLUDE_DIR=$<TARGET_PROPERTY:${ARROW_ZSTD_LIBZSTD},INTERFACE_INCLUDE_DIRECTORIES>"
"-DZSTD_LIBRARY=$<TARGET_FILE:${ARROW_ZSTD_LIBZSTD}>")
if(ZLIB_ROOT)
set(ORC_CMAKE_ARGS ${ORC_CMAKE_ARGS} "-DZLIB_HOME=${ZLIB_ROOT}")
endif()
"-DZSTD_LIBRARY=$<TARGET_FILE:${ARROW_ZSTD_LIBZSTD}>"
"-DZLIB_HOME=${ORC_ZLIB_ROOT}"
"-DZLIB_INCLUDE_DIR=$<TARGET_PROPERTY:ZLIB::ZLIB,INTERFACE_INCLUDE_DIRECTORIES>"
"-DZLIB_LIBRARY=$<TARGET_FILE:ZLIB::ZLIB>")

# Work around CMake bug
file(MAKE_DIRECTORY ${ORC_INCLUDE_DIR})
Expand All @@ -4743,7 +4745,8 @@ function(build_orc)
${ARROW_ZSTD_LIBZSTD}
${Snappy_TARGET}
LZ4::lz4
ZLIB::ZLIB)
ZLIB::ZLIB
PATCH_COMMAND ${ORC_PATCH_COMMAND})
add_library(orc::orc STATIC IMPORTED)
set_target_properties(orc::orc PROPERTIES IMPORTED_LOCATION "${ORC_STATIC_LIB}")
target_include_directories(orc::orc BEFORE INTERFACE "${ORC_INCLUDE_DIR}")
Expand Down
Loading

0 comments on commit 7fc8222

Please sign in to comment.