From 59dfa022943eeb8f169d76bf45feb502f749b20f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 25 Nov 2025 12:03:16 +0100 Subject: [PATCH 01/24] GH-48248: [C++] Use FetchContent for bundled gRPC --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 475 ++++++-------------- cpp/examples/arrow/CMakeLists.txt | 16 + cpp/src/arrow/flight/CMakeLists.txt | 10 + 3 files changed, 167 insertions(+), 334 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 3f381649f5a..e8e55cea52e 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2852,10 +2852,6 @@ function(build_re2) set(RE2_VENDORED TRUE PARENT_SCOPE) - set(RE2_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/re2_fc-install") - set(RE2_PREFIX - "${RE2_PREFIX}" - PARENT_SCOPE) fetchcontent_declare(re2 URL ${RE2_SOURCE_URL} @@ -2866,39 +2862,6 @@ function(build_re2) set(CMAKE_UNITY_BUILD OFF) fetchcontent_makeavailable(re2) - # This custom target ensures re2 is built before we install - add_custom_target(re2_built DEPENDS re2::re2) - - add_custom_command(OUTPUT "${re2_BINARY_DIR}/cmake_install.cmake.saved" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${re2_BINARY_DIR}/cmake_install.cmake" - "${re2_BINARY_DIR}/cmake_install.cmake.saved" - COMMAND ${CMAKE_COMMAND} -E echo - "# RE2 install disabled to prevent double installation with Arrow" - > "${re2_BINARY_DIR}/cmake_install.cmake" - DEPENDS re2_built - COMMENT "Disabling RE2 install to prevent double installation" - VERBATIM) - - add_custom_target(re2_install_disabled ALL - DEPENDS "${re2_BINARY_DIR}/cmake_install.cmake.saved") - - # Install RE2 to RE2_PREFIX for gRPC to find - add_custom_command(OUTPUT "${RE2_PREFIX}/.re2_installed" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${re2_BINARY_DIR}/cmake_install.cmake.saved" - "${re2_BINARY_DIR}/cmake_install.cmake.tmp" - COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${RE2_PREFIX} - -DCMAKE_INSTALL_CONFIG_NAME=$ -P - "${re2_BINARY_DIR}/cmake_install.cmake.tmp" || - ${CMAKE_COMMAND} -E true - COMMAND ${CMAKE_COMMAND} -E touch "${RE2_PREFIX}/.re2_installed" - DEPENDS re2_install_disabled - COMMENT "Installing RE2 to ${RE2_PREFIX} for gRPC" - VERBATIM) - - add_custom_target(re2_fc DEPENDS "${RE2_PREFIX}/.re2_installed") - set(ARROW_BUNDLED_STATIC_LIBS ${ARROW_BUNDLED_STATIC_LIBS} re2::re2 PARENT_SCOPE) @@ -3030,10 +2993,6 @@ function(build_cares) set(CARES_VENDORED TRUE PARENT_SCOPE) - set(CARES_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/cares_fc-install") - set(CARES_PREFIX - "${CARES_PREFIX}" - PARENT_SCOPE) fetchcontent_declare(cares URL ${CARES_SOURCE_URL} @@ -3043,49 +3002,8 @@ function(build_cares) set(CARES_SHARED OFF) set(CARES_STATIC ON) - set(CARES_INSTALL ON) - set(CARES_BUILD_TOOLS OFF) - set(CARES_BUILD_TESTS OFF) fetchcontent_makeavailable(cares) - # gRPC requires c-ares to be installed to a known location. - # We have to do this in two steps to avoid double installation of c-ares - # when Arrow is installed. - # This custom target ensures c-ares is built before we install - add_custom_target(cares_built DEPENDS c-ares::cares) - - # Disable c-ares's install script after it's built to prevent double installation - add_custom_command(OUTPUT "${cares_BINARY_DIR}/cmake_install.cmake.saved" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${cares_BINARY_DIR}/cmake_install.cmake" - "${cares_BINARY_DIR}/cmake_install.cmake.saved" - COMMAND ${CMAKE_COMMAND} -E echo - "# c-ares install disabled to prevent double installation with Arrow" - > "${cares_BINARY_DIR}/cmake_install.cmake" - DEPENDS cares_built - COMMENT "Disabling c-ares install to prevent double installation" - VERBATIM) - - add_custom_target(cares_install_disabled ALL - DEPENDS "${cares_BINARY_DIR}/cmake_install.cmake.saved") - - # Install c-ares to CARES_PREFIX for gRPC to find - add_custom_command(OUTPUT "${CARES_PREFIX}/.cares_installed" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${cares_BINARY_DIR}/cmake_install.cmake.saved" - "${cares_BINARY_DIR}/cmake_install.cmake.tmp" - COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CARES_PREFIX} - -DCMAKE_INSTALL_CONFIG_NAME=$ -P - "${cares_BINARY_DIR}/cmake_install.cmake.tmp" || - ${CMAKE_COMMAND} -E true - COMMAND ${CMAKE_COMMAND} -E touch "${CARES_PREFIX}/.cares_installed" - DEPENDS cares_install_disabled - COMMENT "Installing c-ares to ${CARES_PREFIX} for gRPC" - VERBATIM) - - # Make cares_fc depend on the install completion marker - add_custom_target(cares_fc DEPENDS "${CARES_PREFIX}/.cares_installed") - if(APPLE) # libresolv must be linked from c-ares version 1.16.1 find_library(LIBRESOLV_LIBRARY NAMES resolv libresolv REQUIRED) @@ -3254,7 +3172,7 @@ function(build_absl) list(POP_BACK CMAKE_MESSAGE_INDENT) endfunction() -macro(build_grpc) +function(build_grpc) resolve_dependency(c-ares ARROW_CMAKE_PACKAGE_NAME ArrowFlight @@ -3265,289 +3183,176 @@ macro(build_grpc) PC_PACKAGE_NAMES libcares) - message(STATUS "Building gRPC from source") + list(APPEND CMAKE_MESSAGE_INDENT "GRPC: ") + message(STATUS "Building gRPC from source using FetchContent") + set(GRPC_VENDORED + TRUE + PARENT_SCOPE) - set(GRPC_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/grpc_ep-prefix/src/grpc_ep-build") - set(GRPC_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/grpc_ep-install") - set(GRPC_HOME "${GRPC_PREFIX}") - set(GRPC_INCLUDE_DIR "${GRPC_PREFIX}/include") + set(gRPC_ABSL_PROVIDER + "none" + CACHE STRING "" FORCE) - set(GRPC_STATIC_LIBRARY_GPR - "${GRPC_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gpr${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - set(GRPC_STATIC_LIBRARY_GRPC - "${GRPC_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}grpc${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - set(GRPC_STATIC_LIBRARY_GRPCPP - "${GRPC_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}grpc++${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - set(GRPC_STATIC_LIBRARY_ADDRESS_SORTING - "${GRPC_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}address_sorting${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - set(GRPC_STATIC_LIBRARY_GRPCPP_REFLECTION - "${GRPC_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}grpc++_reflection${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - set(GRPC_STATIC_LIBRARY_UPB - "${GRPC_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}upb${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - set(GRPC_CPP_PLUGIN "${GRPC_PREFIX}/bin/grpc_cpp_plugin${CMAKE_EXECUTABLE_SUFFIX}") + # Skip Protobuf provider and set required library variables directly. + set(gRPC_PROTOBUF_PROVIDER + "none" + CACHE STRING "" FORCE) - set(GRPC_CMAKE_PREFIX) + set(_gRPC_PROTOBUF_LIBRARIES + "protobuf::libprotobuf" + CACHE STRING "" FORCE) - add_custom_target(grpc_dependencies) + set(_gRPC_PROTOBUF_PROTOC_LIBRARIES + "protobuf::libprotoc" + CACHE STRING "" FORCE) - if(ABSL_VENDORED) - add_dependencies(grpc_dependencies absl_fc) - endif() - if(CARES_VENDORED) - add_dependencies(grpc_dependencies cares_fc) - endif() - if(PROTOBUF_VENDORED) - add_dependencies(grpc_dependencies protobuf_fc) - endif() + set(_gRPC_PROTOBUF_PROTOC + "protobuf::protoc" + CACHE STRING "" FORCE) - if(GFLAGS_VENDORED) - add_dependencies(grpc_dependencies gflags_ep) - endif() + set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE + "$" + CACHE STRING "" FORCE) - if(RE2_VENDORED) - add_dependencies(grpc_dependencies re2_fc) - endif() + # Get include directory from protobuf source (not the target property with generator expressions) + # gRPC needs this at configure time for add_custom_command, so we can't use generator expressions + # protobuf_SOURCE_DIR points to cmake/ subdirectory due to SOURCE_SUBDIR, so go up one level + get_filename_component(_protobuf_root_dir "${protobuf_SOURCE_DIR}" DIRECTORY) + set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR + "${_protobuf_root_dir}/src" + CACHE STRING "" FORCE) - add_dependencies(grpc_dependencies ${ARROW_PROTOBUF_LIBPROTOBUF} c-ares::cares - ZLIB::ZLIB) + # For c-ares and RE2, we've already built them via FetchContent and targets exist. + # Set provider to "none" to skip gRPC's dependency resolution, and set library variables directly. + set(gRPC_CARES_PROVIDER + "none" + CACHE STRING "" FORCE) + set(_gRPC_CARES_LIBRARIES + "c-ares::cares" + CACHE STRING "" FORCE) - # For FetchContent Protobuf, use the install prefix directly - if(PROTOBUF_VENDORED) - set(GRPC_PB_ROOT "${PROTOBUF_PREFIX}") - else() - get_target_property(GRPC_PROTOBUF_INCLUDE_DIR ${ARROW_PROTOBUF_LIBPROTOBUF} - INTERFACE_INCLUDE_DIRECTORIES) - get_filename_component(GRPC_PB_ROOT "${GRPC_PROTOBUF_INCLUDE_DIR}" DIRECTORY) - endif() + set(gRPC_RE2_PROVIDER + "none" + CACHE STRING "" FORCE) + set(_gRPC_RE2_LIBRARIES + "re2::re2" + CACHE STRING "" FORCE) - get_target_property(GRPC_Protobuf_PROTOC_LIBRARY ${ARROW_PROTOBUF_LIBPROTOC} - IMPORTED_LOCATION) + set(gRPC_SSL_PROVIDER + "package" + CACHE STRING "" FORCE) - # For FetchContent c-ares, use the install prefix directly - if(CARES_VENDORED) - set(GRPC_CARES_ROOT "${CARES_PREFIX}") - else() - get_target_property(GRPC_CARES_INCLUDE_DIR c-ares::cares - INTERFACE_INCLUDE_DIRECTORIES) - get_filename_component(GRPC_CARES_ROOT "${GRPC_CARES_INCLUDE_DIR}" DIRECTORY) - endif() + set(gRPC_ZLIB_PROVIDER + "package" + CACHE STRING "" FORCE) - # For FetchContent RE2, use the install prefix directly - if(RE2_VENDORED) - set(GRPC_RE2_ROOT "${RE2_PREFIX}") - else() - get_target_property(GRPC_RE2_INCLUDE_DIR re2::re2 INTERFACE_INCLUDE_DIRECTORIES) - get_filename_component(GRPC_RE2_ROOT "${GRPC_RE2_INCLUDE_DIR}" DIRECTORY) + set(gRPC_INSTALL + OFF + CACHE BOOL "" FORCE) + + set(gRPC_BUILD_TESTS + OFF + CACHE BOOL "" FORCE) + + set(gRPC_BUILD_GRPC_CSHARP_PLUGIN + OFF + CACHE BOOL "" FORCE) + + set(gRPC_BUILD_GRPC_NODE_PLUGIN + OFF + CACHE BOOL "" FORCE) + + set(gRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN + OFF + CACHE BOOL "" FORCE) + + set(gRPC_BUILD_GRPC_PHP_PLUGIN + OFF + CACHE BOOL "" FORCE) + + set(gRPC_BUILD_GRPC_PYTHON_PLUGIN + OFF + CACHE BOOL "" FORCE) + + set(gRPC_BUILD_GRPC_RUBY_PLUGIN + OFF + CACHE BOOL "" FORCE) + + set(gRPC_BUILD_CSHARP_EXT + OFF + CACHE BOOL "" FORCE) + + # Add warning suppression flags for gRPC build + + if(NOT MSVC) + string(APPEND CMAKE_C_FLAGS + " -Wno-attributes -Wno-format-security -Wno-unknown-warning-option") + string(APPEND CMAKE_CXX_FLAGS + " -Wno-attributes -Wno-format-security -Wno-unknown-warning-option") endif() + fetchcontent_declare(grpc + URL ${GRPC_SOURCE_URL} + URL_HASH "SHA256=${ARROW_GRPC_BUILD_SHA256_CHECKSUM}") - # Put Abseil, etc. first so that local directories are searched - # before (what are likely) system directories - set(GRPC_CMAKE_PREFIX "${GRPC_CMAKE_PREFIX};${ABSL_PREFIX}") - set(GRPC_CMAKE_PREFIX "${GRPC_CMAKE_PREFIX};${GRPC_PB_ROOT}") - set(GRPC_CMAKE_PREFIX "${GRPC_CMAKE_PREFIX};${GRPC_CARES_ROOT}") - set(GRPC_CMAKE_PREFIX "${GRPC_CMAKE_PREFIX};${GRPC_RE2_ROOT}") + prepare_fetchcontent() + fetchcontent_makeavailable(grpc) - # ZLIB is never vendored - set(GRPC_CMAKE_PREFIX "${GRPC_CMAKE_PREFIX};${ZLIB_ROOT}") + # Create namespace aliases for gRPC targets (these are not created automatically with add_subdirectory) + # Is there a way to iterate over all those created targets instead of listing them manually? + if(NOT TARGET gRPC::address_sorting) + add_library(gRPC::address_sorting ALIAS address_sorting) + endif() - if(RAPIDJSON_VENDORED) - add_dependencies(grpc_dependencies rapidjson_ep) + if(NOT TARGET gRPC::gpr) + add_library(gRPC::gpr ALIAS gpr) endif() - # Yuck, see https://stackoverflow.com/a/45433229/776560 - string(REPLACE ";" ${EP_LIST_SEPARATOR} GRPC_PREFIX_PATH_ALT_SEP "${GRPC_CMAKE_PREFIX}") + if(NOT TARGET gRPC::grpc) + add_library(gRPC::grpc ALIAS grpc) + endif() - set(GRPC_C_FLAGS "${EP_C_FLAGS}") - set(GRPC_CXX_FLAGS "${EP_CXX_FLAGS}") - if(NOT MSVC) - # Negate warnings that gRPC cannot build under - # See https://github.com/grpc/grpc/issues/29417 - string(APPEND - GRPC_C_FLAGS - " -Wno-attributes" - " -Wno-format-security" - " -Wno-unknown-warning-option") - string(APPEND - GRPC_CXX_FLAGS - " -Wno-attributes" - " -Wno-format-security" - " -Wno-unknown-warning-option") - endif() - - set(GRPC_CMAKE_ARGS - "${EP_COMMON_CMAKE_ARGS}" - "-DCMAKE_C_FLAGS=${GRPC_C_FLAGS}" - "-DCMAKE_CXX_FLAGS=${GRPC_CXX_FLAGS}" - -DCMAKE_INSTALL_PREFIX=${GRPC_PREFIX} - -DCMAKE_PREFIX_PATH='${GRPC_PREFIX_PATH_ALT_SEP}' - -DOPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY} - -DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR} - -DOPENSSL_SSL_LIBRARY=${OPENSSL_SSL_LIBRARY} - -DgRPC_ABSL_PROVIDER=package - -DgRPC_BUILD_CSHARP_EXT=OFF - -DgRPC_BUILD_GRPC_CSHARP_PLUGIN=OFF - -DgRPC_BUILD_GRPC_NODE_PLUGIN=OFF - -DgRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN=OFF - -DgRPC_BUILD_GRPC_PHP_PLUGIN=OFF - -DgRPC_BUILD_GRPC_PYTHON_PLUGIN=OFF - -DgRPC_BUILD_GRPC_RUBY_PLUGIN=OFF - -DgRPC_BUILD_TESTS=OFF - -DgRPC_CARES_PROVIDER=package - -DgRPC_MSVC_STATIC_RUNTIME=${ARROW_USE_STATIC_CRT} - -DgRPC_PROTOBUF_PROVIDER=package - -DgRPC_RE2_PROVIDER=package - -DgRPC_SSL_PROVIDER=package - -DgRPC_ZLIB_PROVIDER=package) - if(PROTOBUF_VENDORED) - list(APPEND GRPC_CMAKE_ARGS -DgRPC_PROTOBUF_PACKAGE_TYPE=CONFIG) + if(NOT TARGET gRPC::grpc++) + add_library(gRPC::grpc++ ALIAS grpc++) endif() - # XXX the gRPC git checkout is huge and takes a long time - # Ideally, we should be able to use the tarballs, but they don't contain - # vendored dependencies such as c-ares... - externalproject_add(grpc_ep - ${EP_COMMON_OPTIONS} - URL ${GRPC_SOURCE_URL} - URL_HASH "SHA256=${ARROW_GRPC_BUILD_SHA256_CHECKSUM}" - BUILD_BYPRODUCTS ${GRPC_STATIC_LIBRARY_GPR} - ${GRPC_STATIC_LIBRARY_GRPC} - ${GRPC_STATIC_LIBRARY_GRPCPP} - ${GRPC_STATIC_LIBRARY_ADDRESS_SORTING} - ${GRPC_STATIC_LIBRARY_GRPCPP_REFLECTION} - ${GRPC_STATIC_LIBRARY_UPB} - ${GRPC_CPP_PLUGIN} - CMAKE_ARGS ${GRPC_CMAKE_ARGS} - DEPENDS ${grpc_dependencies}) + if(NOT TARGET gRPC::grpc++_alts) + add_library(gRPC::grpc++_alts ALIAS grpc++_alts) + endif() - # Work around https://gitlab.kitware.com/cmake/cmake/issues/15052 - file(MAKE_DIRECTORY ${GRPC_INCLUDE_DIR}) - - add_library(gRPC::upb STATIC IMPORTED) - set_target_properties(gRPC::upb PROPERTIES IMPORTED_LOCATION - "${GRPC_STATIC_LIBRARY_UPB}") - target_include_directories(gRPC::upb BEFORE INTERFACE "${GRPC_INCLUDE_DIR}") - - set(GRPC_GPR_ABSL_LIBRARIES - # We need a flattened list of Abseil libraries for the static linking case, - # because our method for creating arrow_bundled_dependencies.a doesn't walk - # the dependency tree of targets. - # - # This list should be updated when we change Abseil / gRPC versions. It can - # be generated with: - # pkg-config --libs --static grpc \ - # | tr " " "\n" \ - # | grep ^-labsl_ \ - # | sed 's/^-labsl_/absl::/' - absl::raw_hash_set - absl::hashtablez_sampler - absl::hash - absl::city - absl::low_level_hash - absl::random_distributions - absl::random_seed_sequences - absl::random_internal_pool_urbg - absl::random_internal_randen - absl::random_internal_randen_hwaes - absl::random_internal_randen_hwaes_impl - absl::random_internal_randen_slow - absl::random_internal_platform - absl::random_internal_seed_material - absl::random_seed_gen_exception - absl::statusor - absl::status - absl::cord - absl::cordz_info - absl::cord_internal - absl::cordz_functions - absl::exponential_biased - absl::cordz_handle - absl::bad_optional_access - absl::str_format_internal - absl::synchronization - absl::graphcycles_internal - absl::stacktrace - absl::symbolize - absl::debugging_internal - absl::demangle_internal - absl::malloc_internal - absl::time - absl::civil_time - absl::strings - absl::strings_internal - absl::base - absl::spinlock_wait - absl::int128 - absl::throw_delegate - absl::time_zone - absl::bad_variant_access - absl::raw_logging_internal - absl::log_severity) - - add_library(gRPC::gpr STATIC IMPORTED) - set_target_properties(gRPC::gpr PROPERTIES IMPORTED_LOCATION - "${GRPC_STATIC_LIBRARY_GPR}") - target_link_libraries(gRPC::gpr INTERFACE ${GRPC_GPR_ABSL_LIBRARIES}) - target_include_directories(gRPC::gpr BEFORE INTERFACE "${GRPC_INCLUDE_DIR}") - - add_library(gRPC::address_sorting STATIC IMPORTED) - set_target_properties(gRPC::address_sorting - PROPERTIES IMPORTED_LOCATION - "${GRPC_STATIC_LIBRARY_ADDRESS_SORTING}") - target_include_directories(gRPC::address_sorting BEFORE INTERFACE "${GRPC_INCLUDE_DIR}") + if(NOT TARGET gRPC::grpc++_error_details) + add_library(gRPC::grpc++_error_details ALIAS grpc++_error_details) + endif() - add_library(gRPC::grpc++_reflection STATIC IMPORTED) - set_target_properties(gRPC::grpc++_reflection - PROPERTIES IMPORTED_LOCATION - "${GRPC_STATIC_LIBRARY_GRPCPP_REFLECTION}") - target_include_directories(gRPC::grpc++_reflection BEFORE - INTERFACE "${GRPC_INCLUDE_DIR}") - - add_library(gRPC::grpc STATIC IMPORTED) - set_target_properties(gRPC::grpc PROPERTIES IMPORTED_LOCATION - "${GRPC_STATIC_LIBRARY_GRPC}") - target_link_libraries(gRPC::grpc - INTERFACE gRPC::gpr - gRPC::upb - gRPC::address_sorting - re2::re2 - c-ares::cares - ZLIB::ZLIB - OpenSSL::SSL - Threads::Threads) - target_include_directories(gRPC::grpc BEFORE INTERFACE "${GRPC_INCLUDE_DIR}") + if(NOT TARGET gRPC::grpc++_reflection) + add_library(gRPC::grpc++_reflection ALIAS grpc++_reflection) + endif() + + if(NOT TARGET gRPC::grpc++_unsecure) + add_library(gRPC::grpc++_unsecure ALIAS grpc++_unsecure) + endif() - add_library(gRPC::grpc++ STATIC IMPORTED) - set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_LOCATION - "${GRPC_STATIC_LIBRARY_GRPCPP}") - target_link_libraries(gRPC::grpc++ INTERFACE gRPC::grpc ${ARROW_PROTOBUF_LIBPROTOBUF}) - target_include_directories(gRPC::grpc++ BEFORE INTERFACE "${GRPC_INCLUDE_DIR}") + if(NOT TARGET gRPC::grpc_unsecure) + add_library(gRPC::grpc_unsecure ALIAS grpc_unsecure) + endif() - add_executable(gRPC::grpc_cpp_plugin IMPORTED) - set_target_properties(gRPC::grpc_cpp_plugin PROPERTIES IMPORTED_LOCATION - ${GRPC_CPP_PLUGIN}) + if(NOT TARGET gRPC::grpc_cpp_plugin AND TARGET grpc_cpp_plugin) + add_executable(gRPC::grpc_cpp_plugin ALIAS grpc_cpp_plugin) + endif() - add_dependencies(grpc_ep grpc_dependencies) - add_dependencies(gRPC::grpc++ grpc_ep) - add_dependencies(gRPC::grpc_cpp_plugin grpc_ep) - set(GRPC_VENDORED TRUE) + if(NOT TARGET gRPC::upb) + add_library(gRPC::upb ALIAS upb) + endif() # ar -M rejects with the "libgrpc++.a" filename because "+" is a line # continuation character in these scripts, so we have to create a copy of the # static lib that we will bundle later - set(GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}grpcpp${CMAKE_STATIC_LIBRARY_SUFFIX}" ) add_custom_command(OUTPUT ${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR} COMMAND ${CMAKE_COMMAND} -E copy $ ${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR} - DEPENDS grpc_ep) + DEPENDS gRPC::grpc++) add_library(gRPC::grpcpp_for_bundling STATIC IMPORTED) set_target_properties(gRPC::grpcpp_for_bundling PROPERTIES IMPORTED_LOCATION @@ -3558,6 +3363,7 @@ macro(build_grpc) add_custom_target(grpc_copy_grpc++ ALL DEPENDS "${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}") add_dependencies(gRPC::grpcpp_for_bundling grpc_copy_grpc++) + # Add gRPC libraries to bundled static libs. list(APPEND ARROW_BUNDLED_STATIC_LIBS gRPC::address_sorting @@ -3565,10 +3371,11 @@ macro(build_grpc) gRPC::grpc gRPC::grpcpp_for_bundling gRPC::upb) - if(ABSL_VENDORED) - list(APPEND ARROW_BUNDLED_STATIC_LIBS ${GRPC_GPR_ABSL_LIBRARIES}) - endif() -endmacro() + set(ARROW_BUNDLED_STATIC_LIBS + "${ARROW_BUNDLED_STATIC_LIBS}" + PARENT_SCOPE) + list(POP_BACK CMAKE_MESSAGE_INDENT) +endfunction() if(ARROW_WITH_GOOGLE_CLOUD_CPP OR ARROW_WITH_GRPC) set(ARROW_ABSL_REQUIRED_VERSION 20211102) diff --git a/cpp/examples/arrow/CMakeLists.txt b/cpp/examples/arrow/CMakeLists.txt index 82c075c51df..440d507299c 100644 --- a/cpp/examples/arrow/CMakeLists.txt +++ b/cpp/examples/arrow/CMakeLists.txt @@ -127,6 +127,15 @@ if(ARROW_FLIGHT) "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.cc" "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.cc") + # gRPC headers use deprecated std::iterator (deprecated in C++17, removed in C++20). + # This causes compilation errors with GCC 15+ when using -Werror. + # This workaround can be removed once we upgrade to a newer gRPC version that doesn't + # use std::iterator (likely gRPC 1.60+). + # TODO: Can't we pass this to add_arrow_example() to apply it to the target directly? + if(NOT MSVC) + target_compile_options(flight-grpc-example PRIVATE -Wno-error=deprecated-declarations) + endif() + if(ARROW_FLIGHT_SQL) if(ARROW_BUILD_SHARED AND ARROW_GRPC_USE_SHARED) set(FLIGHT_SQL_EXAMPLES_LINK_LIBS arrow_flight_sql_shared) @@ -143,6 +152,13 @@ if(ARROW_FLIGHT) gRPC::grpc++ ${ARROW_PROTOBUF_LIBPROTOBUF} ${GFLAGS_LIBRARIES}) + + # gRPC headers use deprecated std::iterator + # TODO: Can't we pass this to add_arrow_example() to apply it to the target directly? + if(NOT MSVC) + target_compile_options(flight-sql-example + PRIVATE -Wno-error=deprecated-declarations) + endif() endif() endif() diff --git a/cpp/src/arrow/flight/CMakeLists.txt b/cpp/src/arrow/flight/CMakeLists.txt index 8974c9581f7..6eeb003609d 100644 --- a/cpp/src/arrow/flight/CMakeLists.txt +++ b/cpp/src/arrow/flight/CMakeLists.txt @@ -17,6 +17,16 @@ add_custom_target(arrow_flight) +# gRPC headers use deprecated std::iterator (deprecated in C++17, removed in C++20). +# This causes compilation errors with GCC 15+ when using -Werror. +# This workaround can be removed once we upgrade to a newer gRPC version that doesn't +# use std::iterator (likely gRPC 1.60+). +# Apply to all Flight targets (libraries, tests, executables) in this directory. +# TODO: Check whether this is global and try a better approach if so. +if(NOT MSVC) + add_compile_options(-Wno-error=deprecated-declarations) +endif() + arrow_install_all_headers("arrow/flight") # If libarrow_flight.a is only built, "pkg-config --cflags --libs From 30c03027bbcc6f519b0f8a4c7e895548763d6b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 25 Nov 2025 16:57:31 +0100 Subject: [PATCH 02/24] Some more cleaning after initial tests --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 105 +++++--------------- 1 file changed, 25 insertions(+), 80 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index e8e55cea52e..154bb6dc003 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3042,13 +3042,13 @@ function(build_absl) prepare_fetchcontent() # We have to enable Abseil install to generate abslConfig.cmake - # so gRPC can find Abseil through ExternalProject_Add. Our expectation - # is that this will not be necessary once gRPC supports FetchContent. + # so google-cloud-cpp can find Abseil through ExternalProject_Add. Our expectation + # is that this will not be necessary once google-cloud-cpp supports FetchContent. set(ABSL_ENABLE_INSTALL ON) fetchcontent_makeavailable(absl) # This custom target is required due to a timing issue between FetchContent - # and the install command below, which is necessary for GRPC to find Abseil + # and the install command below, which is necessary for google-cloud-cpp to find Abseil # due to mixing FetchContent and ExternalProject_Add. # Create a target that depends on ALL Abseil libraries that will be installed. # This ensures they're all built before we try to install. @@ -3120,7 +3120,7 @@ function(build_absl) absl::time absl::time_zone) - # gRPC requires Abseil to be installed to a known location. + # google-cloud-cpp requires Abseil to be installed to a known location. # We have to do this in two steps to avoid double installation of Abseil # when Arrow is installed. # Disable Abseil's install script this target runs after Abseil is built @@ -3140,7 +3140,7 @@ function(build_absl) add_custom_target(absl_install_disabled ALL DEPENDS "${absl_BINARY_DIR}/cmake_install.cmake.saved") - # Install Abseil to ABSL_PREFIX for gRPC to find. + # Install Abseil to ABSL_PREFIX for google-cloud-cpp to find. # Using the saved original cmake_install.cmake.saved install script # for other dependencies to find Abseil. add_custom_command(OUTPUT "${ABSL_PREFIX}/.absl_installed" @@ -3183,21 +3183,12 @@ function(build_grpc) PC_PACKAGE_NAMES libcares) - list(APPEND CMAKE_MESSAGE_INDENT "GRPC: ") + list(APPEND CMAKE_MESSAGE_INDENT "gRPC: ") message(STATUS "Building gRPC from source using FetchContent") set(GRPC_VENDORED TRUE PARENT_SCOPE) - set(gRPC_ABSL_PROVIDER - "none" - CACHE STRING "" FORCE) - - # Skip Protobuf provider and set required library variables directly. - set(gRPC_PROTOBUF_PROVIDER - "none" - CACHE STRING "" FORCE) - set(_gRPC_PROTOBUF_LIBRARIES "protobuf::libprotobuf" CACHE STRING "" FORCE) @@ -3282,8 +3273,7 @@ function(build_grpc) OFF CACHE BOOL "" FORCE) - # Add warning suppression flags for gRPC build - + # Add warning suppression flags for gRPC build. if(NOT MSVC) string(APPEND CMAKE_C_FLAGS " -Wno-attributes -Wno-format-security -Wno-unknown-warning-option") @@ -3297,79 +3287,34 @@ function(build_grpc) prepare_fetchcontent() fetchcontent_makeavailable(grpc) - # Create namespace aliases for gRPC targets (these are not created automatically with add_subdirectory) - # Is there a way to iterate over all those created targets instead of listing them manually? - if(NOT TARGET gRPC::address_sorting) - add_library(gRPC::address_sorting ALIAS address_sorting) - endif() - - if(NOT TARGET gRPC::gpr) - add_library(gRPC::gpr ALIAS gpr) - endif() - - if(NOT TARGET gRPC::grpc) - add_library(gRPC::grpc ALIAS grpc) - endif() - - if(NOT TARGET gRPC::grpc++) - add_library(gRPC::grpc++ ALIAS grpc++) - endif() - - if(NOT TARGET gRPC::grpc++_alts) - add_library(gRPC::grpc++_alts ALIAS grpc++_alts) - endif() - - if(NOT TARGET gRPC::grpc++_error_details) - add_library(gRPC::grpc++_error_details ALIAS grpc++_error_details) - endif() - - if(NOT TARGET gRPC::grpc++_reflection) - add_library(gRPC::grpc++_reflection ALIAS grpc++_reflection) - endif() - - if(NOT TARGET gRPC::grpc++_unsecure) - add_library(gRPC::grpc++_unsecure ALIAS grpc++_unsecure) - endif() - - if(NOT TARGET gRPC::grpc_unsecure) - add_library(gRPC::grpc_unsecure ALIAS grpc_unsecure) - endif() + # FetchContent builds gRPC libraries without gRPC:: prefix. + # Create gRPC:: alias targets for consistency. + set(GRPC_LIBRARY_TARGETS + address_sorting + gpr + grpc + grpc++ + grpc++_reflection + upb) + + foreach(target ${GRPC_LIBRARY_TARGETS}) + if(TARGET ${target} AND NOT TARGET gRPC::${target}) + add_library(gRPC::${target} ALIAS ${target}) + endif() + endforeach() - if(NOT TARGET gRPC::grpc_cpp_plugin AND TARGET grpc_cpp_plugin) + if(TARGET grpc_cpp_plugin AND NOT TARGET gRPC::grpc_cpp_plugin) add_executable(gRPC::grpc_cpp_plugin ALIAS grpc_cpp_plugin) endif() - if(NOT TARGET gRPC::upb) - add_library(gRPC::upb ALIAS upb) - endif() - - # ar -M rejects with the "libgrpc++.a" filename because "+" is a line - # continuation character in these scripts, so we have to create a copy of the - # static lib that we will bundle later - set(GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR - "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}grpcpp${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - add_custom_command(OUTPUT ${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR} - COMMAND ${CMAKE_COMMAND} -E copy $ - ${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR} - DEPENDS gRPC::grpc++) - add_library(gRPC::grpcpp_for_bundling STATIC IMPORTED) - set_target_properties(gRPC::grpcpp_for_bundling - PROPERTIES IMPORTED_LOCATION - "${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}") - - set_source_files_properties("${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}" PROPERTIES GENERATED - TRUE) - add_custom_target(grpc_copy_grpc++ ALL DEPENDS "${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}") - add_dependencies(gRPC::grpcpp_for_bundling grpc_copy_grpc++) - # Add gRPC libraries to bundled static libs. list(APPEND ARROW_BUNDLED_STATIC_LIBS gRPC::address_sorting gRPC::gpr gRPC::grpc - gRPC::grpcpp_for_bundling + gRPC::grpc++ + gRPC::grpc++_reflection gRPC::upb) set(ARROW_BUNDLED_STATIC_LIBS "${ARROW_BUNDLED_STATIC_LIBS}" From ea0c6be6dad5f8d5a65ea5485e0dfb3eec5c53a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 26 Nov 2025 12:04:50 +0100 Subject: [PATCH 03/24] Some more cleanup --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 44 +-------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 154bb6dc003..12817cb415e 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3197,10 +3197,6 @@ function(build_grpc) "protobuf::libprotoc" CACHE STRING "" FORCE) - set(_gRPC_PROTOBUF_PROTOC - "protobuf::protoc" - CACHE STRING "" FORCE) - set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE "$" CACHE STRING "" FORCE) @@ -3228,50 +3224,14 @@ function(build_grpc) set(_gRPC_RE2_LIBRARIES "re2::re2" CACHE STRING "" FORCE) - set(gRPC_SSL_PROVIDER "package" CACHE STRING "" FORCE) - set(gRPC_ZLIB_PROVIDER "package" CACHE STRING "" FORCE) - - set(gRPC_INSTALL - OFF - CACHE BOOL "" FORCE) - - set(gRPC_BUILD_TESTS - OFF - CACHE BOOL "" FORCE) - - set(gRPC_BUILD_GRPC_CSHARP_PLUGIN - OFF - CACHE BOOL "" FORCE) - - set(gRPC_BUILD_GRPC_NODE_PLUGIN - OFF - CACHE BOOL "" FORCE) - - set(gRPC_BUILD_GRPC_OBJECTIVE_C_PLUGIN - OFF - CACHE BOOL "" FORCE) - - set(gRPC_BUILD_GRPC_PHP_PLUGIN - OFF - CACHE BOOL "" FORCE) - - set(gRPC_BUILD_GRPC_PYTHON_PLUGIN - OFF - CACHE BOOL "" FORCE) - - set(gRPC_BUILD_GRPC_RUBY_PLUGIN - OFF - CACHE BOOL "" FORCE) - - set(gRPC_BUILD_CSHARP_EXT - OFF - CACHE BOOL "" FORCE) + set(gRPC_INSTALL OFF) + set(gRPC_BUILD_TESTS OFF) # Add warning suppression flags for gRPC build. if(NOT MSVC) From 77663969cf288ff1297e01b17b32fce4130ab6f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 26 Nov 2025 12:58:33 +0100 Subject: [PATCH 04/24] Move configuration after fetchcontent_declare and prepare_fetchcontent and make config conditional to vendored third parties --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 72 +++++++++++---------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 12817cb415e..4fbfcf84799 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3189,41 +3189,49 @@ function(build_grpc) TRUE PARENT_SCOPE) - set(_gRPC_PROTOBUF_LIBRARIES - "protobuf::libprotobuf" - CACHE STRING "" FORCE) + fetchcontent_declare(grpc + URL ${GRPC_SOURCE_URL} + URL_HASH "SHA256=${ARROW_GRPC_BUILD_SHA256_CHECKSUM}") - set(_gRPC_PROTOBUF_PROTOC_LIBRARIES - "protobuf::libprotoc" - CACHE STRING "" FORCE) + prepare_fetchcontent() - set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE - "$" - CACHE STRING "" FORCE) + if(PROTOBUF_VENDORED) + set(_gRPC_PROTOBUF_LIBRARIES + "protobuf::libprotobuf" + CACHE STRING "" FORCE) - # Get include directory from protobuf source (not the target property with generator expressions) - # gRPC needs this at configure time for add_custom_command, so we can't use generator expressions - # protobuf_SOURCE_DIR points to cmake/ subdirectory due to SOURCE_SUBDIR, so go up one level - get_filename_component(_protobuf_root_dir "${protobuf_SOURCE_DIR}" DIRECTORY) - set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR - "${_protobuf_root_dir}/src" - CACHE STRING "" FORCE) + set(_gRPC_PROTOBUF_PROTOC_LIBRARIES + "protobuf::libprotoc" + CACHE STRING "" FORCE) - # For c-ares and RE2, we've already built them via FetchContent and targets exist. - # Set provider to "none" to skip gRPC's dependency resolution, and set library variables directly. - set(gRPC_CARES_PROVIDER - "none" - CACHE STRING "" FORCE) - set(_gRPC_CARES_LIBRARIES - "c-ares::cares" - CACHE STRING "" FORCE) + set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE + "$" + CACHE STRING "" FORCE) - set(gRPC_RE2_PROVIDER - "none" - CACHE STRING "" FORCE) - set(_gRPC_RE2_LIBRARIES - "re2::re2" - CACHE STRING "" FORCE) + # gRPC needs this at configure time for add_custom_command. + get_filename_component(_protobuf_root_dir "${protobuf_SOURCE_DIR}" DIRECTORY) + set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR + "${_protobuf_root_dir}/src" + CACHE STRING "" FORCE) + endif() + + if(CARES_VENDORED) + set(gRPC_CARES_PROVIDER + "none" + CACHE STRING "" FORCE) + set(_gRPC_CARES_LIBRARIES + "c-ares::cares" + CACHE STRING "" FORCE) + endif() + + if(RE2_VENDORED) + set(gRPC_RE2_PROVIDER + "none" + CACHE STRING "" FORCE) + set(_gRPC_RE2_LIBRARIES + "re2::re2" + CACHE STRING "" FORCE) + endif() set(gRPC_SSL_PROVIDER "package" CACHE STRING "" FORCE) @@ -3240,11 +3248,7 @@ function(build_grpc) string(APPEND CMAKE_CXX_FLAGS " -Wno-attributes -Wno-format-security -Wno-unknown-warning-option") endif() - fetchcontent_declare(grpc - URL ${GRPC_SOURCE_URL} - URL_HASH "SHA256=${ARROW_GRPC_BUILD_SHA256_CHECKSUM}") - prepare_fetchcontent() fetchcontent_makeavailable(grpc) # FetchContent builds gRPC libraries without gRPC:: prefix. From a4dea947ac2fa658ed19f53b2a98269fd28b3fd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 26 Nov 2025 14:07:52 +0100 Subject: [PATCH 05/24] Move the '-Wno-error=deprecated-declarations' to a common target_compile_options --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 10 ++++++++++ cpp/examples/arrow/CMakeLists.txt | 16 ---------------- cpp/src/arrow/flight/CMakeLists.txt | 10 ---------- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 4fbfcf84799..c713e3a9ffb 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3271,6 +3271,16 @@ function(build_grpc) add_executable(gRPC::grpc_cpp_plugin ALIAS grpc_cpp_plugin) endif() + # gRPC headers use deprecated std::iterator that causes compilation errors. + # This workaround can be removed once we upgrade to a newer gRPC version. + if(NOT MSVC) + foreach(target ${GRPC_LIBRARY_TARGETS}) + if(TARGET ${target}) + target_compile_options(${target} INTERFACE -Wno-error=deprecated-declarations) + endif() + endforeach() + endif() + # Add gRPC libraries to bundled static libs. list(APPEND ARROW_BUNDLED_STATIC_LIBS diff --git a/cpp/examples/arrow/CMakeLists.txt b/cpp/examples/arrow/CMakeLists.txt index 440d507299c..82c075c51df 100644 --- a/cpp/examples/arrow/CMakeLists.txt +++ b/cpp/examples/arrow/CMakeLists.txt @@ -127,15 +127,6 @@ if(ARROW_FLIGHT) "${CMAKE_CURRENT_BINARY_DIR}/helloworld.pb.cc" "${CMAKE_CURRENT_BINARY_DIR}/helloworld.grpc.pb.cc") - # gRPC headers use deprecated std::iterator (deprecated in C++17, removed in C++20). - # This causes compilation errors with GCC 15+ when using -Werror. - # This workaround can be removed once we upgrade to a newer gRPC version that doesn't - # use std::iterator (likely gRPC 1.60+). - # TODO: Can't we pass this to add_arrow_example() to apply it to the target directly? - if(NOT MSVC) - target_compile_options(flight-grpc-example PRIVATE -Wno-error=deprecated-declarations) - endif() - if(ARROW_FLIGHT_SQL) if(ARROW_BUILD_SHARED AND ARROW_GRPC_USE_SHARED) set(FLIGHT_SQL_EXAMPLES_LINK_LIBS arrow_flight_sql_shared) @@ -152,13 +143,6 @@ if(ARROW_FLIGHT) gRPC::grpc++ ${ARROW_PROTOBUF_LIBPROTOBUF} ${GFLAGS_LIBRARIES}) - - # gRPC headers use deprecated std::iterator - # TODO: Can't we pass this to add_arrow_example() to apply it to the target directly? - if(NOT MSVC) - target_compile_options(flight-sql-example - PRIVATE -Wno-error=deprecated-declarations) - endif() endif() endif() diff --git a/cpp/src/arrow/flight/CMakeLists.txt b/cpp/src/arrow/flight/CMakeLists.txt index 6eeb003609d..8974c9581f7 100644 --- a/cpp/src/arrow/flight/CMakeLists.txt +++ b/cpp/src/arrow/flight/CMakeLists.txt @@ -17,16 +17,6 @@ add_custom_target(arrow_flight) -# gRPC headers use deprecated std::iterator (deprecated in C++17, removed in C++20). -# This causes compilation errors with GCC 15+ when using -Werror. -# This workaround can be removed once we upgrade to a newer gRPC version that doesn't -# use std::iterator (likely gRPC 1.60+). -# Apply to all Flight targets (libraries, tests, executables) in this directory. -# TODO: Check whether this is global and try a better approach if so. -if(NOT MSVC) - add_compile_options(-Wno-error=deprecated-declarations) -endif() - arrow_install_all_headers("arrow/flight") # If libarrow_flight.a is only built, "pkg-config --cflags --libs From 41810b2b47a2d9d9898b1c179f4400a176b41b58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 26 Nov 2025 14:28:35 +0100 Subject: [PATCH 06/24] Add package providers for cares and re2 if not vendored as they won't be a submodule of grpc --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index c713e3a9ffb..c15d858cd25 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3222,6 +3222,10 @@ function(build_grpc) set(_gRPC_CARES_LIBRARIES "c-ares::cares" CACHE STRING "" FORCE) + else() + set(gRPC_CARES_PROVIDER + "package" + CACHE STRING "" FORCE) endif() if(RE2_VENDORED) @@ -3231,6 +3235,10 @@ function(build_grpc) set(_gRPC_RE2_LIBRARIES "re2::re2" CACHE STRING "" FORCE) + else() + set(gRPC_RE2_PROVIDER + "package" + CACHE STRING "" FORCE) endif() set(gRPC_SSL_PROVIDER "package" From 466fe9c87f5a1ec1faa72a3a7cf37122bd682e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 26 Nov 2025 14:39:50 +0100 Subject: [PATCH 07/24] Always use None as RE and C-Ares provider --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 38 ++++++++------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index c15d858cd25..50fe4cc1acb 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3215,31 +3215,21 @@ function(build_grpc) CACHE STRING "" FORCE) endif() - if(CARES_VENDORED) - set(gRPC_CARES_PROVIDER - "none" - CACHE STRING "" FORCE) - set(_gRPC_CARES_LIBRARIES - "c-ares::cares" - CACHE STRING "" FORCE) - else() - set(gRPC_CARES_PROVIDER - "package" - CACHE STRING "" FORCE) - endif() + # Use "none" provider for c-ares or re2, either we vendored it or we already found it. + set(gRPC_CARES_PROVIDER + "none" + CACHE STRING "" FORCE) + set(_gRPC_CARES_LIBRARIES + "c-ares::cares" + CACHE STRING "" FORCE) + + set(gRPC_RE2_PROVIDER + "none" + CACHE STRING "" FORCE) + set(_gRPC_RE2_LIBRARIES + "re2::re2" + CACHE STRING "" FORCE) - if(RE2_VENDORED) - set(gRPC_RE2_PROVIDER - "none" - CACHE STRING "" FORCE) - set(_gRPC_RE2_LIBRARIES - "re2::re2" - CACHE STRING "" FORCE) - else() - set(gRPC_RE2_PROVIDER - "package" - CACHE STRING "" FORCE) - endif() set(gRPC_SSL_PROVIDER "package" CACHE STRING "" FORCE) From 43ba97aef49191cdde23485db88547c31af9de58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 26 Nov 2025 16:39:00 +0100 Subject: [PATCH 08/24] Add back grpc fix for ar -M for bundling dependencies together --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 23 +++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 50fe4cc1acb..3b318326a18 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3279,14 +3279,33 @@ function(build_grpc) endforeach() endif() + # ar -M rejects with the "libgrpc++.a" filename because "+" is a line + # continuation character in these scripts, so we have to create a copy of the + # static lib that we will bundle later. + set(GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR + "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}grpcpp${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + add_custom_command(OUTPUT ${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR} + COMMAND ${CMAKE_COMMAND} -E copy $ + ${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR} + DEPENDS gRPC::grpc++) + add_library(gRPC::grpcpp_for_bundling STATIC IMPORTED) + set_target_properties(gRPC::grpcpp_for_bundling + PROPERTIES IMPORTED_LOCATION + "${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}") + + set_source_files_properties("${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}" PROPERTIES GENERATED + TRUE) + add_custom_target(grpc_copy_grpc++ ALL DEPENDS "${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}") + add_dependencies(gRPC::grpcpp_for_bundling grpc_copy_grpc++) + # Add gRPC libraries to bundled static libs. list(APPEND ARROW_BUNDLED_STATIC_LIBS gRPC::address_sorting gRPC::gpr gRPC::grpc - gRPC::grpc++ - gRPC::grpc++_reflection + gRPC::grpcpp_for_bundling gRPC::upb) set(ARROW_BUNDLED_STATIC_LIBS "${ARROW_BUNDLED_STATIC_LIBS}" From 3c6735b7d1f4a52453e58bd33149a90df6481da7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 26 Nov 2025 18:53:51 +0100 Subject: [PATCH 09/24] Do not install RE2 and force cache variables so linux packages don't override --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 3b318326a18..e545faee961 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2855,7 +2855,8 @@ function(build_re2) fetchcontent_declare(re2 URL ${RE2_SOURCE_URL} - URL_HASH "SHA256=${ARROW_RE2_BUILD_SHA256_CHECKSUM}") + URL_HASH "SHA256=${ARROW_RE2_BUILD_SHA256_CHECKSUM}" + EXCLUDE_FROM_ALL) prepare_fetchcontent() # Unity build causes some build errors @@ -3236,8 +3237,12 @@ function(build_grpc) set(gRPC_ZLIB_PROVIDER "package" CACHE STRING "" FORCE) - set(gRPC_INSTALL OFF) - set(gRPC_BUILD_TESTS OFF) + set(gRPC_INSTALL + OFF + CACHE BOOL "" FORCE) + set(gRPC_BUILD_TESTS + OFF + CACHE BOOL "" FORCE) # Add warning suppression flags for gRPC build. if(NOT MSVC) From cc9ec07a3321e121cbce5d875754136737bc89ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Thu, 27 Nov 2025 18:26:18 +0100 Subject: [PATCH 10/24] Do not include headers on install to avoid adding them on RPMs --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 25 +++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index e545faee961..d33e5b3e6e6 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2861,8 +2861,16 @@ function(build_re2) # Unity build causes some build errors set(CMAKE_UNITY_BUILD OFF) + + # Disable install rules for RE2 so it is not installed on our Linux-packages. + set(CMAKE_SKIP_INSTALL_RULES ON) + fetchcontent_makeavailable(re2) + # We have to create an empty cmake_install.cmake so include() doesn't fail but doesn't install anything. + file(WRITE "${re2_BINARY_DIR}/cmake_install.cmake" + "# RE2 install disabled via CMAKE_SKIP_INSTALL_RULES\n") + set(ARROW_BUNDLED_STATIC_LIBS ${ARROW_BUNDLED_STATIC_LIBS} re2::re2 PARENT_SCOPE) @@ -2997,12 +3005,16 @@ function(build_cares) fetchcontent_declare(cares URL ${CARES_SOURCE_URL} - URL_HASH "SHA256=${ARROW_CARES_BUILD_SHA256_CHECKSUM}") + URL_HASH "SHA256=${ARROW_CARES_BUILD_SHA256_CHECKSUM}" + EXCLUDE_FROM_ALL) prepare_fetchcontent() set(CARES_SHARED OFF) set(CARES_STATIC ON) + set(CARES_INSTALL + OFF + CACHE BOOL "" FORCE) fetchcontent_makeavailable(cares) if(APPLE) @@ -3209,7 +3221,7 @@ function(build_grpc) "$" CACHE STRING "" FORCE) - # gRPC needs this at configure time for add_custom_command. + # gRPC needs this at configure time. get_filename_component(_protobuf_root_dir "${protobuf_SOURCE_DIR}" DIRECTORY) set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR "${_protobuf_root_dir}/src" @@ -3252,8 +3264,17 @@ function(build_grpc) " -Wno-attributes -Wno-format-security -Wno-unknown-warning-option") endif() + # Disable install rules for gRPC so it is not installed on our Linux-packages. + set(CMAKE_SKIP_INSTALL_RULES ON) + fetchcontent_makeavailable(grpc) + # CMAKE_SKIP_INSTALL_RULES prevents cmake_install.cmake from being created, + # but the parent cmake_install.cmake still tries to include() it. + # Create an empty one manually so include() doesn't fail. + file(WRITE "${grpc_BINARY_DIR}/cmake_install.cmake" + "# gRPC install disabled via CMAKE_SKIP_INSTALL_RULES\n") + # FetchContent builds gRPC libraries without gRPC:: prefix. # Create gRPC:: alias targets for consistency. set(GRPC_LIBRARY_TARGETS From e60761d4c1f5affcf5f4ea05f5bd5950ffd86761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Fri, 28 Nov 2025 12:10:55 +0100 Subject: [PATCH 11/24] Remove unnecessary EXCLUDE_FROM_ALL on cares fetchcontent declare --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index d33e5b3e6e6..cd6f61d94d8 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3005,16 +3005,12 @@ function(build_cares) fetchcontent_declare(cares URL ${CARES_SOURCE_URL} - URL_HASH "SHA256=${ARROW_CARES_BUILD_SHA256_CHECKSUM}" - EXCLUDE_FROM_ALL) + URL_HASH "SHA256=${ARROW_CARES_BUILD_SHA256_CHECKSUM}") prepare_fetchcontent() set(CARES_SHARED OFF) set(CARES_STATIC ON) - set(CARES_INSTALL - OFF - CACHE BOOL "" FORCE) fetchcontent_makeavailable(cares) if(APPLE) From 645e0a329be8fa9dce241464ff63328aeedc2fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Mon, 1 Dec 2025 11:19:29 +0100 Subject: [PATCH 12/24] Use FC_DECLARE_COMMON_OPTIONS instead of manually setting variables for RE2 --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index cd6f61d94d8..4b276763ddc 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2854,23 +2854,16 @@ function(build_re2) PARENT_SCOPE) fetchcontent_declare(re2 + ${FC_DECLARE_COMMON_OPTIONS} URL ${RE2_SOURCE_URL} - URL_HASH "SHA256=${ARROW_RE2_BUILD_SHA256_CHECKSUM}" - EXCLUDE_FROM_ALL) + URL_HASH "SHA256=${ARROW_RE2_BUILD_SHA256_CHECKSUM}") prepare_fetchcontent() # Unity build causes some build errors set(CMAKE_UNITY_BUILD OFF) - # Disable install rules for RE2 so it is not installed on our Linux-packages. - set(CMAKE_SKIP_INSTALL_RULES ON) - fetchcontent_makeavailable(re2) - # We have to create an empty cmake_install.cmake so include() doesn't fail but doesn't install anything. - file(WRITE "${re2_BINARY_DIR}/cmake_install.cmake" - "# RE2 install disabled via CMAKE_SKIP_INSTALL_RULES\n") - set(ARROW_BUNDLED_STATIC_LIBS ${ARROW_BUNDLED_STATIC_LIBS} re2::re2 PARENT_SCOPE) From 43fd073b58d07d3ecf3abdfa00544fba9e53ccd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Mon, 1 Dec 2025 12:53:59 +0100 Subject: [PATCH 13/24] Add back CMAKE_SKIP_INSTALL_RULES on RE2 to fix centos-7 --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 4b276763ddc..034c0d84008 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2862,8 +2862,17 @@ function(build_re2) # Unity build causes some build errors set(CMAKE_UNITY_BUILD OFF) + # Disable install rules for RE2 so it is not installed on centos-7. + # This can be removed once we drop centos-7 support (GH-40735). + set(CMAKE_SKIP_INSTALL_RULES ON) + fetchcontent_makeavailable(re2) + # We have to create an empty cmake_install.cmake so include() doesn't fail but doesn't install anything. + # This can be removed once we drop centos-7 support (GH-40735). + file(WRITE "${re2_BINARY_DIR}/cmake_install.cmake" + "# RE2 install disabled via CMAKE_SKIP_INSTALL_RULES\n") + set(ARROW_BUNDLED_STATIC_LIBS ${ARROW_BUNDLED_STATIC_LIBS} re2::re2 PARENT_SCOPE) From 2f8c2abb243829ca87f5a9b8a169378ca889f77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Mon, 1 Dec 2025 13:23:27 +0100 Subject: [PATCH 14/24] Remove CACHE variable for some gRPC variables --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 24 ++++++--------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 034c0d84008..6229d36f5d5 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3207,23 +3207,15 @@ function(build_grpc) prepare_fetchcontent() if(PROTOBUF_VENDORED) - set(_gRPC_PROTOBUF_LIBRARIES - "protobuf::libprotobuf" - CACHE STRING "" FORCE) + set(_gRPC_PROTOBUF_LIBRARIES "protobuf::libprotobuf") - set(_gRPC_PROTOBUF_PROTOC_LIBRARIES - "protobuf::libprotoc" - CACHE STRING "" FORCE) + set(_gRPC_PROTOBUF_PROTOC_LIBRARIES "protobuf::libprotoc") - set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE - "$" - CACHE STRING "" FORCE) + set(_gRPC_PROTOBUF_PROTOC_EXECUTABLE "$") # gRPC needs this at configure time. get_filename_component(_protobuf_root_dir "${protobuf_SOURCE_DIR}" DIRECTORY) - set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR - "${_protobuf_root_dir}/src" - CACHE STRING "" FORCE) + set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR "${_protobuf_root_dir}/src") endif() # Use "none" provider for c-ares or re2, either we vendored it or we already found it. @@ -3247,12 +3239,8 @@ function(build_grpc) set(gRPC_ZLIB_PROVIDER "package" CACHE STRING "" FORCE) - set(gRPC_INSTALL - OFF - CACHE BOOL "" FORCE) - set(gRPC_BUILD_TESTS - OFF - CACHE BOOL "" FORCE) + set(gRPC_INSTALL OFF) + set(gRPC_BUILD_TESTS OFF) # Add warning suppression flags for gRPC build. if(NOT MSVC) From cac8c3b76c84b1af8fbfcab3f8acd1e5e733670c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Mon, 1 Dec 2025 14:19:27 +0100 Subject: [PATCH 15/24] Set EXCLUDE_FROM_ALL TRUE to re2_SOURCE_DIR if CMake less than 3.28 --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 6229d36f5d5..07aaebff9c8 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -2862,16 +2862,11 @@ function(build_re2) # Unity build causes some build errors set(CMAKE_UNITY_BUILD OFF) - # Disable install rules for RE2 so it is not installed on centos-7. - # This can be removed once we drop centos-7 support (GH-40735). - set(CMAKE_SKIP_INSTALL_RULES ON) - fetchcontent_makeavailable(re2) - # We have to create an empty cmake_install.cmake so include() doesn't fail but doesn't install anything. - # This can be removed once we drop centos-7 support (GH-40735). - file(WRITE "${re2_BINARY_DIR}/cmake_install.cmake" - "# RE2 install disabled via CMAKE_SKIP_INSTALL_RULES\n") + if(CMAKE_VERSION VERSION_LESS 3.28) + set_property(DIRECTORY ${re2_SOURCE_DIR} PROPERTY EXCLUDE_FROM_ALL TRUE) + endif() set(ARROW_BUNDLED_STATIC_LIBS ${ARROW_BUNDLED_STATIC_LIBS} re2::re2 From d9031e082f8a62a5f6c9c19a933d5cbb3d194808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Mon, 1 Dec 2025 14:38:42 +0100 Subject: [PATCH 16/24] Use FC_DECLARE_COMMON_OPTIONS and set EXCLUDE_FROM_ALL to grpc_SOURCE_DIR if CMake less than 3.28 --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 07aaebff9c8..461658dca16 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3196,6 +3196,7 @@ function(build_grpc) PARENT_SCOPE) fetchcontent_declare(grpc + ${FC_DECLARE_COMMON_OPTIONS} URL ${GRPC_SOURCE_URL} URL_HASH "SHA256=${ARROW_GRPC_BUILD_SHA256_CHECKSUM}") @@ -3245,16 +3246,11 @@ function(build_grpc) " -Wno-attributes -Wno-format-security -Wno-unknown-warning-option") endif() - # Disable install rules for gRPC so it is not installed on our Linux-packages. - set(CMAKE_SKIP_INSTALL_RULES ON) - fetchcontent_makeavailable(grpc) - # CMAKE_SKIP_INSTALL_RULES prevents cmake_install.cmake from being created, - # but the parent cmake_install.cmake still tries to include() it. - # Create an empty one manually so include() doesn't fail. - file(WRITE "${grpc_BINARY_DIR}/cmake_install.cmake" - "# gRPC install disabled via CMAKE_SKIP_INSTALL_RULES\n") + if(CMAKE_VERSION VERSION_LESS 3.28) + set_property(DIRECTORY ${grpc_SOURCE_DIR} PROPERTY EXCLUDE_FROM_ALL TRUE) + endif() # FetchContent builds gRPC libraries without gRPC:: prefix. # Create gRPC:: alias targets for consistency. From 90cd1a0cbc191afeb9b0a2387185a445d132caa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Mon, 1 Dec 2025 16:11:55 +0100 Subject: [PATCH 17/24] Remove more CACHE variables --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 461658dca16..be18aa0aadf 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3218,23 +3218,15 @@ function(build_grpc) set(gRPC_CARES_PROVIDER "none" CACHE STRING "" FORCE) - set(_gRPC_CARES_LIBRARIES - "c-ares::cares" - CACHE STRING "" FORCE) + set(_gRPC_CARES_LIBRARIES "c-ares::cares") - set(gRPC_RE2_PROVIDER - "none" - CACHE STRING "" FORCE) - set(_gRPC_RE2_LIBRARIES - "re2::re2" - CACHE STRING "" FORCE) + set(gRPC_RE2_PROVIDER "none") + set(_gRPC_RE2_LIBRARIES "re2::re2") set(gRPC_SSL_PROVIDER "package" CACHE STRING "" FORCE) - set(gRPC_ZLIB_PROVIDER - "package" - CACHE STRING "" FORCE) + set(gRPC_ZLIB_PROVIDER "package") set(gRPC_INSTALL OFF) set(gRPC_BUILD_TESTS OFF) From 8ad3a0274ce2d7dc13195f6c9a45c20836af6cdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Mon, 1 Dec 2025 20:36:29 +0100 Subject: [PATCH 18/24] Validate gRPC_SSL_PROVIDER needs CACHE variable clean --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index be18aa0aadf..b438d76783d 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3223,9 +3223,7 @@ function(build_grpc) set(gRPC_RE2_PROVIDER "none") set(_gRPC_RE2_LIBRARIES "re2::re2") - set(gRPC_SSL_PROVIDER - "package" - CACHE STRING "" FORCE) + set(gRPC_SSL_PROVIDER "package") set(gRPC_ZLIB_PROVIDER "package") set(gRPC_INSTALL OFF) set(gRPC_BUILD_TESTS OFF) From 00a838f3b338c986e19d0376847eb72210643c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Mon, 1 Dec 2025 21:48:54 +0100 Subject: [PATCH 19/24] Validate gRPC_CARES_PROVIDER needs CACHE variable clean --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index b438d76783d..4a20ac5b9d3 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3215,9 +3215,7 @@ function(build_grpc) endif() # Use "none" provider for c-ares or re2, either we vendored it or we already found it. - set(gRPC_CARES_PROVIDER - "none" - CACHE STRING "" FORCE) + set(gRPC_CARES_PROVIDER "none") set(_gRPC_CARES_LIBRARIES "c-ares::cares") set(gRPC_RE2_PROVIDER "none") From 711662ffbd89b9db9bf7d529b218c5a1bf79385c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 2 Dec 2025 09:30:14 +0100 Subject: [PATCH 20/24] Move back gRPC_CARES_PROVIDER to CACHE STRING FORCE --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 4a20ac5b9d3..b438d76783d 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3215,7 +3215,9 @@ function(build_grpc) endif() # Use "none" provider for c-ares or re2, either we vendored it or we already found it. - set(gRPC_CARES_PROVIDER "none") + set(gRPC_CARES_PROVIDER + "none" + CACHE STRING "" FORCE) set(_gRPC_CARES_LIBRARIES "c-ares::cares") set(gRPC_RE2_PROVIDER "none") From 296882c0eeaa4413e3b66954708de4b71316759b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 2 Dec 2025 10:33:34 +0100 Subject: [PATCH 21/24] Fix for Debian forky? --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index b438d76783d..7c9e6a925c1 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3223,7 +3223,8 @@ function(build_grpc) set(gRPC_RE2_PROVIDER "none") set(_gRPC_RE2_LIBRARIES "re2::re2") - set(gRPC_SSL_PROVIDER "package") + set(gRPC_SSL_PROVIDER "none") + set(_gRPC_SSL_LIBRARIES "OpenSSL::SSL;OpenSSL::Crypto") set(gRPC_ZLIB_PROVIDER "package") set(gRPC_INSTALL OFF) set(gRPC_BUILD_TESTS OFF) From 66e80626d8a63a957264f9d65d6ae24ab0134182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Wed, 3 Dec 2025 09:58:22 +0100 Subject: [PATCH 22/24] Add back CARES_BUILD_TOOLS OFF --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 7c9e6a925c1..93d4474a0cd 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3008,6 +3008,7 @@ function(build_cares) set(CARES_SHARED OFF) set(CARES_STATIC ON) + set(CARES_BUILD_TOOLS OFF) fetchcontent_makeavailable(cares) if(APPLE) From eda80768dd65ffe3d0b6dbff8791faf67a67ee19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 2 Dec 2025 18:59:10 +0100 Subject: [PATCH 23/24] Try upgrading Abseil, gRPC, Protobuf --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 66 +++++++++++++-------- cpp/thirdparty/versions.txt | 14 ++--- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 93d4474a0cd..85426be494b 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -753,7 +753,7 @@ else() ARROW_PROTOBUF_STRIPPED_BUILD_VERSION) # strip the leading `v` set_urls(PROTOBUF_SOURCE_URL - "https://github.com/protocolbuffers/protobuf/releases/download/${ARROW_PROTOBUF_BUILD_VERSION}/protobuf-all-${ARROW_PROTOBUF_STRIPPED_BUILD_VERSION}.tar.gz" + "https://github.com/protocolbuffers/protobuf/releases/download/${ARROW_PROTOBUF_BUILD_VERSION}/protobuf-${ARROW_PROTOBUF_STRIPPED_BUILD_VERSION}.tar.gz" "${THIRDPARTY_MIRROR_URL}/protobuf-${ARROW_PROTOBUF_BUILD_VERSION}.tar.gz") endif() @@ -1884,8 +1884,7 @@ function(build_protobuf) fetchcontent_declare(protobuf URL ${PROTOBUF_SOURCE_URL} - URL_HASH "SHA256=${ARROW_PROTOBUF_BUILD_SHA256_CHECKSUM}" - SOURCE_SUBDIR cmake) + URL_HASH "SHA256=${ARROW_PROTOBUF_BUILD_SHA256_CHECKSUM}") prepare_fetchcontent() @@ -3060,26 +3059,29 @@ function(build_absl) # Create a target that depends on ALL Abseil libraries that will be installed. # This ensures they're all built before we try to install. add_custom_target(absl_built - DEPENDS absl::bad_any_cast_impl - absl::bad_optional_access - absl::bad_variant_access - absl::base + DEPENDS absl::base absl::city absl::civil_time - absl::cord absl::cord_internal + absl::cord absl::cordz_functions absl::cordz_handle absl::cordz_info absl::cordz_sample_token + absl::crc_cord_state + absl::crc_cpu_detect + absl::crc_internal + absl::crc32c absl::debugging_internal + absl::decode_rust_punycode absl::demangle_internal + absl::demangle_rust + absl::die_if_null absl::examine_stack absl::exponential_biased absl::failure_signal_handler - absl::flags - absl::flags_commandlineflag absl::flags_commandlineflag_internal + absl::flags_commandlineflag absl::flags_config absl::flags_internal absl::flags_marshalling @@ -3087,26 +3089,41 @@ function(build_absl) absl::flags_private_handle_accessor absl::flags_program_name absl::flags_reflection - absl::flags_usage absl::flags_usage_internal + absl::flags_usage absl::graphcycles_internal absl::hash absl::hashtablez_sampler absl::int128 + absl::kernel_timeout_internal absl::leak_check - absl::leak_check_disable + absl::log_flags + absl::log_globals + absl::log_initialize + absl::log_internal_check_op + absl::log_internal_conditions + absl::log_internal_fnmatch + absl::log_internal_format + absl::log_internal_globals + absl::log_internal_log_sink_set + absl::log_internal_message + absl::log_internal_nullguard + absl::log_internal_proto + absl::log_internal_structured_proto absl::log_severity + absl::log_sink absl::low_level_hash absl::malloc_internal absl::periodic_sampler + absl::poison absl::random_distributions absl::random_internal_distribution_test_util + absl::random_internal_entropy_pool absl::random_internal_platform - absl::random_internal_pool_urbg - absl::random_internal_randen - absl::random_internal_randen_hwaes absl::random_internal_randen_hwaes_impl + absl::random_internal_randen_hwaes absl::random_internal_randen_slow + absl::random_internal_randen absl::random_internal_seed_material absl::random_seed_gen_exception absl::random_seed_sequences @@ -3119,13 +3136,17 @@ function(build_absl) absl::statusor absl::str_format_internal absl::strerror - absl::strings + absl::string_view absl::strings_internal + absl::strings absl::symbolize absl::synchronization absl::throw_delegate + absl::time_zone absl::time - absl::time_zone) + absl::tracing_internal + absl::utf8_for_code_point + absl::vlog_config_internal) # google-cloud-cpp requires Abseil to be installed to a known location. # We have to do this in two steps to avoid double installation of Abseil @@ -3226,7 +3247,8 @@ function(build_grpc) set(gRPC_SSL_PROVIDER "none") set(_gRPC_SSL_LIBRARIES "OpenSSL::SSL;OpenSSL::Crypto") - set(gRPC_ZLIB_PROVIDER "package") + set(gRPC_ZLIB_PROVIDER "none") + set(_gRPC_ZLIB_LIBRARIES "ZLIB::ZLIB") set(gRPC_INSTALL OFF) set(gRPC_BUILD_TESTS OFF) @@ -3251,8 +3273,7 @@ function(build_grpc) gpr grpc grpc++ - grpc++_reflection - upb) + grpc++_reflection) foreach(target ${GRPC_LIBRARY_TARGETS}) if(TARGET ${target} AND NOT TARGET gRPC::${target}) @@ -3300,8 +3321,7 @@ function(build_grpc) gRPC::address_sorting gRPC::gpr gRPC::grpc - gRPC::grpcpp_for_bundling - gRPC::upb) + gRPC::grpcpp_for_bundling) set(ARROW_BUNDLED_STATIC_LIBS "${ARROW_BUNDLED_STATIC_LIBS}" PARENT_SCOPE) @@ -3636,8 +3656,6 @@ macro(build_google_cloud_cpp_storage) # (and then some regexing) list(APPEND ARROW_BUNDLED_STATIC_LIBS - absl::bad_optional_access - absl::bad_variant_access absl::base absl::civil_time absl::cord diff --git a/cpp/thirdparty/versions.txt b/cpp/thirdparty/versions.txt index fd596f9a24d..a74f59301b6 100644 --- a/cpp/thirdparty/versions.txt +++ b/cpp/thirdparty/versions.txt @@ -23,8 +23,8 @@ # `DEPENDENCIES` array (see the comment on top of the declaration for the # format). -ARROW_ABSL_BUILD_VERSION=20211102.0 -ARROW_ABSL_BUILD_SHA256_CHECKSUM=dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4 +ARROW_ABSL_BUILD_VERSION=20250512.1 +ARROW_ABSL_BUILD_SHA256_CHECKSUM=9b7a064305e9fd94d124ffa6cc358592eb42b5da588fb4e07d09254aa40086db ARROW_AWS_C_AUTH_BUILD_VERSION=v0.9.0 ARROW_AWS_C_AUTH_BUILD_SHA256_CHECKSUM=aa6e98864fefb95c249c100da4ae7aed36ba13a8a91415791ec6fad20bec0427 ARROW_AWS_C_CAL_BUILD_VERSION=v0.9.2 @@ -74,8 +74,8 @@ ARROW_GLOG_BUILD_VERSION=v0.5.0 ARROW_GLOG_BUILD_SHA256_CHECKSUM=eede71f28371bf39aa69b45de23b329d37214016e2055269b3b5e7cfd40b59f5 ARROW_GOOGLE_CLOUD_CPP_BUILD_VERSION=v2.22.0 ARROW_GOOGLE_CLOUD_CPP_BUILD_SHA256_CHECKSUM=0c68782e57959c82e0c81def805c01460a042c1aae0c2feee905acaa2a2dc9bf -ARROW_GRPC_BUILD_VERSION=v1.46.3 -ARROW_GRPC_BUILD_SHA256_CHECKSUM=d6cbf22cb5007af71b61c6be316a79397469c58c82a942552a62e708bce60964 +ARROW_GRPC_BUILD_VERSION=v1.76.0 +ARROW_GRPC_BUILD_SHA256_CHECKSUM=0af37b800953130b47c075b56683ee60bdc3eda3c37fc6004193f5b569758204 ARROW_GTEST_BUILD_VERSION=1.16.0 ARROW_GTEST_BUILD_SHA256_CHECKSUM=78c676fc63881529bf97bf9d45948d905a66833fbfa5318ea2cd7478cb98f399 ARROW_JEMALLOC_BUILD_VERSION=5.3.0 @@ -92,8 +92,8 @@ ARROW_OPENTELEMETRY_PROTO_BUILD_VERSION=v1.7.0 ARROW_OPENTELEMETRY_PROTO_BUILD_SHA256_CHECKSUM=11330d850f5e24d34c4246bc8cb21fcd311e7565d219195713455a576bb11bed ARROW_ORC_BUILD_VERSION=2.2.1 ARROW_ORC_BUILD_SHA256_CHECKSUM=52fc762332442e8b05d7182f8c035f9e04d945b9a52be22ab69f28b3f37d4500 -ARROW_PROTOBUF_BUILD_VERSION=v21.3 -ARROW_PROTOBUF_BUILD_SHA256_CHECKSUM=2f723218f6cb709ae4cdc4fb5ed56a5951fc5d466f0128ce4c946b8c78c8c49f +ARROW_PROTOBUF_BUILD_VERSION=v33.1 +ARROW_PROTOBUF_BUILD_SHA256_CHECKSUM=fda132cb0c86400381c0af1fe98bd0f775cb566cb247cdcc105e344e00acc30e # Because of https://github.com/Tencent/rapidjson/pull/1323, we require # a pre-release version of RapidJSON to build with GCC 8 without # warnings. @@ -160,7 +160,7 @@ DEPENDENCIES=( "ARROW_OPENTELEMETRY_URL opentelemetry-cpp-${ARROW_OPENTELEMETRY_BUILD_VERSION}.tar.gz https://github.com/open-telemetry/opentelemetry-cpp/archive/refs/tags/${ARROW_OPENTELEMETRY_BUILD_VERSION}.tar.gz" "ARROW_OPENTELEMETRY_PROTO_URL opentelemetry-proto-${ARROW_OPENTELEMETRY_PROTO_BUILD_VERSION}.tar.gz https://github.com/open-telemetry/opentelemetry-proto/archive/refs/tags/${ARROW_OPENTELEMETRY_PROTO_BUILD_VERSION}.tar.gz" "ARROW_ORC_URL orc-${ARROW_ORC_BUILD_VERSION}.tar.gz https://www.apache.org/dyn/closer.lua/orc/orc-${ARROW_ORC_BUILD_VERSION}/orc-${ARROW_ORC_BUILD_VERSION}.tar.gz?action=download" - "ARROW_PROTOBUF_URL protobuf-${ARROW_PROTOBUF_BUILD_VERSION}.tar.gz https://github.com/google/protobuf/releases/download/${ARROW_PROTOBUF_BUILD_VERSION}/protobuf-all-${ARROW_PROTOBUF_BUILD_VERSION:1}.tar.gz" + "ARROW_PROTOBUF_URL protobuf-${ARROW_PROTOBUF_BUILD_VERSION}.tar.gz https://github.com/google/protobuf/releases/download/${ARROW_PROTOBUF_BUILD_VERSION}/protobuf-${ARROW_PROTOBUF_BUILD_VERSION:1}.tar.gz" "ARROW_RAPIDJSON_URL rapidjson-${ARROW_RAPIDJSON_BUILD_VERSION}.tar.gz https://github.com/miloyip/rapidjson/archive/${ARROW_RAPIDJSON_BUILD_VERSION}.tar.gz" "ARROW_RE2_URL re2-${ARROW_RE2_BUILD_VERSION}.tar.gz https://github.com/google/re2/archive/${ARROW_RE2_BUILD_VERSION}.tar.gz" "ARROW_S2N_TLS_URL s2n-${ARROW_S2N_TLS_BUILD_VERSION}.tar.gz https://github.com/aws/s2n-tls/archive/${ARROW_S2N_TLS_BUILD_VERSION}.tar.gz" From bbed18d16334906d7c2a34dc89e8efe9dad1adfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Cumplido?= Date: Tue, 2 Dec 2025 19:46:38 +0100 Subject: [PATCH 24/24] Try with protobuf 31.1 instead --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 26 +++++++++++++-------- cpp/thirdparty/versions.txt | 4 ++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 85426be494b..0f745f6784f 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -3059,19 +3059,22 @@ function(build_absl) # Create a target that depends on ALL Abseil libraries that will be installed. # This ensures they're all built before we try to install. add_custom_target(absl_built - DEPENDS absl::base + DEPENDS absl::bad_any_cast_impl + absl::bad_optional_access + absl::bad_variant_access + absl::base absl::city absl::civil_time - absl::cord_internal absl::cord + absl::cord_internal absl::cordz_functions absl::cordz_handle absl::cordz_info absl::cordz_sample_token + absl::crc32c absl::crc_cord_state absl::crc_cpu_detect absl::crc_internal - absl::crc32c absl::debugging_internal absl::decode_rust_punycode absl::demangle_internal @@ -3080,8 +3083,8 @@ function(build_absl) absl::examine_stack absl::exponential_biased absl::failure_signal_handler - absl::flags_commandlineflag_internal absl::flags_commandlineflag + absl::flags_commandlineflag_internal absl::flags_config absl::flags_internal absl::flags_marshalling @@ -3089,14 +3092,15 @@ function(build_absl) absl::flags_private_handle_accessor absl::flags_program_name absl::flags_reflection - absl::flags_usage_internal absl::flags_usage + absl::flags_usage_internal absl::graphcycles_internal absl::hash absl::hashtablez_sampler absl::int128 absl::kernel_timeout_internal absl::leak_check + absl::log_entry absl::log_flags absl::log_globals absl::log_initialize @@ -3118,12 +3122,12 @@ function(build_absl) absl::poison absl::random_distributions absl::random_internal_distribution_test_util - absl::random_internal_entropy_pool absl::random_internal_platform - absl::random_internal_randen_hwaes_impl + absl::random_internal_pool_urbg + absl::random_internal_randen absl::random_internal_randen_hwaes + absl::random_internal_randen_hwaes_impl absl::random_internal_randen_slow - absl::random_internal_randen absl::random_internal_seed_material absl::random_seed_gen_exception absl::random_seed_sequences @@ -3137,13 +3141,13 @@ function(build_absl) absl::str_format_internal absl::strerror absl::string_view - absl::strings_internal absl::strings + absl::strings_internal absl::symbolize absl::synchronization absl::throw_delegate - absl::time_zone absl::time + absl::time_zone absl::tracing_internal absl::utf8_for_code_point absl::vlog_config_internal) @@ -3656,6 +3660,8 @@ macro(build_google_cloud_cpp_storage) # (and then some regexing) list(APPEND ARROW_BUNDLED_STATIC_LIBS + absl::bad_optional_access + absl::bad_variant_access absl::base absl::civil_time absl::cord diff --git a/cpp/thirdparty/versions.txt b/cpp/thirdparty/versions.txt index a74f59301b6..d9877d4220e 100644 --- a/cpp/thirdparty/versions.txt +++ b/cpp/thirdparty/versions.txt @@ -92,8 +92,8 @@ ARROW_OPENTELEMETRY_PROTO_BUILD_VERSION=v1.7.0 ARROW_OPENTELEMETRY_PROTO_BUILD_SHA256_CHECKSUM=11330d850f5e24d34c4246bc8cb21fcd311e7565d219195713455a576bb11bed ARROW_ORC_BUILD_VERSION=2.2.1 ARROW_ORC_BUILD_SHA256_CHECKSUM=52fc762332442e8b05d7182f8c035f9e04d945b9a52be22ab69f28b3f37d4500 -ARROW_PROTOBUF_BUILD_VERSION=v33.1 -ARROW_PROTOBUF_BUILD_SHA256_CHECKSUM=fda132cb0c86400381c0af1fe98bd0f775cb566cb247cdcc105e344e00acc30e +ARROW_PROTOBUF_BUILD_VERSION=v31.1 +ARROW_PROTOBUF_BUILD_SHA256_CHECKSUM=12bfd76d27b9ac3d65c00966901609e020481b9474ef75c7ff4601ac06fa0b82 # Because of https://github.com/Tencent/rapidjson/pull/1323, we require # a pre-release version of RapidJSON to build with GCC 8 without # warnings.