From b5a0668880a4118cd2bab3a62a7228686af85e4c Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" <96995091+alinaliBQ@users.noreply.github.com> Date: Mon, 23 Nov 2026 14:43:00 -0700 Subject: [PATCH 1/4] Apply a Boost.Locale patch for CMake 4.5.0 compatibility --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 14 +++++++ .../boost-locale-source-group.patch | 40 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 cpp/cmake_modules/boost-locale-source-group.patch 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}, " From fc7bd43961fe1a713912f2d5501a0c38ea28136a Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" <96995091+alinaliBQ@users.noreply.github.com> Date: Mon, 23 Nov 2026 15:09:06 -0700 Subject: [PATCH 2/4] Apply same patch to boost.sh * temp patch to get configuration working, then revert the patch to get `cpp/cmake_modules/ThirdpartyToolchain.cmake` to apply the patch --- r/tools/trim/boost.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/r/tools/trim/boost.sh b/r/tools/trim/boost.sh index e7701f64a88..075cc947d9d 100644 --- a/r/tools/trim/boost.sh +++ b/r/tools/trim/boost.sh @@ -152,6 +152,22 @@ 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="" +for dir in "${SCRIPT_DIR}/../cpp" "${SCRIPT_DIR}/../../../cpp"; do + if [ -f "${dir}/cmake_modules/boost-locale-source-group.patch" ]; then + BOOST_PATCH="$(cd "${dir}/cmake_modules" && pwd)/boost-locale-source-group.patch" + break + fi +done +(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 +183,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 From 9d575bbfbb54e5bf2282240594d756ff16acf8ab Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" <96995091+alinaliBQ@users.noreply.github.com> Date: Tue, 24 Nov 2026 15:17:22 -0700 Subject: [PATCH 3/4] Add patch to fix R Extra workflows --- ci/scripts/r_docker_configure.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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. From d839fa88f788c35b7b6c7e2413917a8cc3f3ba69 Mon Sep 17 00:00:00 2001 From: "Alina (Xi) Li" <96995091+alinaliBQ@users.noreply.github.com> Date: Thu, 26 Nov 2026 12:57:28 -0700 Subject: [PATCH 4/4] work on kou's comment Move original `TOOLCHAIN` logic to detect `cpp/` path to avoid duplicate code --- r/tools/trim/boost.sh | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/r/tools/trim/boost.sh b/r/tools/trim/boost.sh index 075cc947d9d..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 @@ -159,13 +160,7 @@ fi # libarrow is built. # TODO: Remove this once we use a Boost release that includes # https://github.com/boostorg/locale/pull/273 -BOOST_PATCH="" -for dir in "${SCRIPT_DIR}/../cpp" "${SCRIPT_DIR}/../../../cpp"; do - if [ -f "${dir}/cmake_modules/boost-locale-source-group.patch" ]; then - BOOST_PATCH="$(cd "${dir}/cmake_modules" && pwd)/boost-locale-source-group.patch" - break - fi -done +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