diff --git a/ci/scripts/r_docker_configure.sh b/ci/scripts/r_docker_configure.sh index 3bc16a69a05..af814e28c71 100755 --- a/ci/scripts/r_docker_configure.sh +++ b/ci/scripts/r_docker_configure.sh @@ -78,11 +78,13 @@ if [ -f "${ARROW_SOURCE_HOME}/ci/scripts/r_install_system_dependencies.sh" ]; th fi # Install rsync for bundling cpp source and curl to make sure it is installed on all images, -# cmake is now a listed sys req. +# cmake is now a listed sys req. patch is needed by r/tools/trim/boost.sh. +# TODO: Remove patch once we use a Boost release that includes +# https://github.com/boostorg/locale/pull/273 if [ "$PACKAGE_MANAGER" = "apk" ]; then - "$PACKAGE_MANAGER" add rsync cmake curl + "$PACKAGE_MANAGER" add rsync cmake curl patch else - "$PACKAGE_MANAGER" install -y rsync cmake curl + "$PACKAGE_MANAGER" install -y rsync cmake curl patch fi # Newer Debian/Ubuntu require tzdata-legacy for our tests, install it if available. diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 55f3dba0aad..9a169c1edc1 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -1097,8 +1097,22 @@ function(build_boost) list(APPEND CMAKE_MESSAGE_INDENT "Boost: ") message(STATUS "Building from source") + # Boost.Locale 1.92.0 fails to configure with CMake 4.5.0. + # + # TODO: Once we use a Boost release that includes + # https://github.com/boostorg/locale/pull/273, + # remove this workaround and boost-locale-source-group.patch. + # https://github.com/boostorg/boost/issues/1162 + find_program(PATCH patch) + set(BOOST_PATCH_COMMAND) + if(PATCH) + set(BOOST_PATCH_COMMAND ${PATCH} -p1 -i + ${CMAKE_CURRENT_LIST_DIR}/boost-locale-source-group.patch) + endif() + fetchcontent_declare(boost ${FC_DECLARE_COMMON_OPTIONS} OVERRIDE_FIND_PACKAGE + PATCH_COMMAND ${BOOST_PATCH_COMMAND} URL ${BOOST_SOURCE_URL} URL_HASH "SHA256=${ARROW_BOOST_BUILD_SHA256_CHECKSUM}") diff --git a/cpp/cmake_modules/boost-locale-source-group.patch b/cpp/cmake_modules/boost-locale-source-group.patch new file mode 100644 index 00000000000..39566e192ae --- /dev/null +++ b/cpp/cmake_modules/boost-locale-source-group.patch @@ -0,0 +1,40 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# https://github.com/boostorg/locale/pull/273 + +From f51b58cd34a2a0e3a1ce974287ec0ede0fc9d1fe Mon Sep 17 00:00:00 2001 +From: aouxwoux <81102668+aouxwoux@users.noreply.github.com> +Date: Sun, 25 Oct 2026 17:42:54 +0000 +Subject: [PATCH] cmake: use remove_item for locale.hpp + +diff --git a/libs/locale/CMakeLists.txt b/libs/locale/CMakeLists.txt +index c0b4e6932a..efae306234 100644 +--- a/libs/locale/CMakeLists.txt ++++ b/libs/locale/CMakeLists.txt +@@ -232,9 +232,10 @@ + list(FILTER sources_src INCLUDE REGEX "^src/") + set(sources_inc ${sources}) + list(FILTER sources_inc EXCLUDE REGEX "^src/") ++list(REMOVE_ITEM sources_inc "${CMAKE_CURRENT_SOURCE_DIR}/include/boost/locale.hpp") ++source_group("headers" FILES "include/boost/locale.hpp") + source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/src" PREFIX "sources" FILES ${sources_src}) + source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/include/boost/locale" PREFIX "headers" FILES ${sources_inc}) +-source_group("headers" FILES "include/boost/locale.hpp") + + message(STATUS "Boost.Locale: " + "iconv ${BOOST_LOCALE_ENABLE_ICONV}, " diff --git a/r/tools/trim/boost.sh b/r/tools/trim/boost.sh index e7701f64a88..95156c4335b 100644 --- a/r/tools/trim/boost.sh +++ b/r/tools/trim/boost.sh @@ -53,6 +53,20 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" IN="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" OUT="$(cd "$(dirname "$2")" && pwd)/$(basename "$2")" +# tools/cpp is the synced copy of cpp/ (`make sync-cpp`); fall back to the +# repository's cpp/ so this can also be run by hand from a git checkout. +CPP_DIR="" +for dir in "${SCRIPT_DIR}/../cpp" "${SCRIPT_DIR}/../../../cpp"; do + if [ -f "${dir}/cmake_modules/ThirdpartyToolchain.cmake" ]; then + CPP_DIR="$(cd "${dir}" && pwd)" + break + fi +done +if [ -z "${CPP_DIR}" ]; then + echo "Can't find cpp/; run \`make sync-cpp\` first" >&2 + exit 1 +fi + # Libraries that build_boost() can add to BOOST_INCLUDE_LIBRARIES but that # the R package's libarrow build never needs. If you add a library here, # say why. @@ -107,20 +121,7 @@ boost_libraries_from_cmake() { } if [ -z "${BOOST_INCLUDE_LIBRARIES:-}" ]; then - # tools/cpp is the synced copy of cpp/ (`make sync-cpp`); fall back to the - # repository's cpp/ so this can also be run by hand from a git checkout. - TOOLCHAIN="" - for dir in "${SCRIPT_DIR}/../cpp" "${SCRIPT_DIR}/../../../cpp"; do - if [ -f "${dir}/cmake_modules/ThirdpartyToolchain.cmake" ]; then - TOOLCHAIN="${dir}/cmake_modules/ThirdpartyToolchain.cmake" - break - fi - done - if [ -z "${TOOLCHAIN}" ]; then - echo "Can't find ThirdpartyToolchain.cmake; run \`make sync-cpp\` first" >&2 - exit 1 - fi - + TOOLCHAIN="${CPP_DIR}/cmake_modules/ThirdpartyToolchain.cmake" ALL_LIBRARIES="$(boost_libraries_from_cmake "${TOOLCHAIN}")" if [ -z "${ALL_LIBRARIES}" ]; then echo "No BOOST_INCLUDE_LIBRARIES found in build_boost() in ${TOOLCHAIN}." >&2 @@ -152,6 +153,16 @@ if [ ! -f "${SRC}/tools/cmake/include/BoostRoot.cmake" ]; then exit 1 fi +# Boost.Locale 1.92.0 fails to configure with CMake 4.5.0, so patch it for +# the configure step below. +# The patch is reverted right after configuring, because the trimmed +# tarball must stay unpatched to allow build_boost() to apply the patch when +# libarrow is built. +# TODO: Remove this once we use a Boost release that includes +# https://github.com/boostorg/locale/pull/273 +BOOST_PATCH="${CPP_DIR}/cmake_modules/boost-locale-source-group.patch" +(cd "${SRC}" && patch -p1 -N -s -i "${BOOST_PATCH}") + # Let Boost's CMake resolve the transitive dependencies. With # --log-level=VERBOSE, BoostRoot.cmake logs "Adding Boost library 'x'" for # each requested library and "Adding Boost dependency 'x'" for each @@ -167,6 +178,7 @@ cmake -S "${SRC}" -B "${WORK}/build" \ echo "Configuring Boost failed" >&2 exit 1 } +(cd "${SRC}" && patch -R -p1 -s -i "${BOOST_PATCH}") if grep -q "has not been found" "${WORK}/cmake.log"; then grep "has not been found" "${WORK}/cmake.log" >&2 echo "A library in BOOST_INCLUDE_LIBRARIES doesn't exist in ${SRC_NAME}" >&2