diff --git a/ci/docker/centos-7-cpp.dockerfile b/ci/docker/centos-7-cpp.dockerfile index 1f30eed694e..cfa2dbe6e44 100644 --- a/ci/docker/centos-7-cpp.dockerfile +++ b/ci/docker/centos-7-cpp.dockerfile @@ -46,6 +46,7 @@ RUN \ make \ openssl-devel \ openssl11-devel \ + patch \ wget \ which diff --git a/ci/docker/conda-cpp.dockerfile b/ci/docker/conda-cpp.dockerfile index dff1f222480..08ce5b5ca90 100644 --- a/ci/docker/conda-cpp.dockerfile +++ b/ci/docker/conda-cpp.dockerfile @@ -36,6 +36,7 @@ RUN mamba install -q -y \ compilers \ doxygen \ libnuma \ + patch \ python=${python} \ ucx \ ucx-proc=*=cpu \ diff --git a/ci/docker/ubuntu-20.04-cpp-minimal.dockerfile b/ci/docker/ubuntu-20.04-cpp-minimal.dockerfile index e17c0306f11..c8818980ff8 100644 --- a/ci/docker/ubuntu-20.04-cpp-minimal.dockerfile +++ b/ci/docker/ubuntu-20.04-cpp-minimal.dockerfile @@ -32,6 +32,7 @@ RUN apt-get update -y -q && \ git \ libssl-dev \ libcurl4-openssl-dev \ + patch \ python3-pip \ tzdata \ wget && \ diff --git a/ci/docker/ubuntu-20.04-cpp.dockerfile b/ci/docker/ubuntu-20.04-cpp.dockerfile index d78c7a99cf4..55fd81123c6 100644 --- a/ci/docker/ubuntu-20.04-cpp.dockerfile +++ b/ci/docker/ubuntu-20.04-cpp.dockerfile @@ -106,6 +106,7 @@ RUN apt-get update -y -q && \ ninja-build \ nlohmann-json3-dev \ npm \ + patch \ pkg-config \ protobuf-compiler \ python3-dev \ diff --git a/ci/docker/ubuntu-22.04-cpp-minimal.dockerfile b/ci/docker/ubuntu-22.04-cpp-minimal.dockerfile index 341d8a87e86..64f9e4d17c8 100644 --- a/ci/docker/ubuntu-22.04-cpp-minimal.dockerfile +++ b/ci/docker/ubuntu-22.04-cpp-minimal.dockerfile @@ -32,6 +32,7 @@ RUN apt-get update -y -q && \ git \ libssl-dev \ libcurl4-openssl-dev \ + patch \ python3-pip \ tzdata \ wget && \ diff --git a/ci/docker/ubuntu-22.04-cpp.dockerfile b/ci/docker/ubuntu-22.04-cpp.dockerfile index f12e7456add..950da29becf 100644 --- a/ci/docker/ubuntu-22.04-cpp.dockerfile +++ b/ci/docker/ubuntu-22.04-cpp.dockerfile @@ -107,6 +107,7 @@ RUN apt-get update -y -q && \ ninja-build \ nlohmann-json3-dev \ npm \ + patch \ pkg-config \ protobuf-compiler \ protobuf-compiler-grpc \ diff --git a/ci/docker/ubuntu-24.04-cpp-minimal.dockerfile b/ci/docker/ubuntu-24.04-cpp-minimal.dockerfile index a995ab2a8bc..f24b4958449 100644 --- a/ci/docker/ubuntu-24.04-cpp-minimal.dockerfile +++ b/ci/docker/ubuntu-24.04-cpp-minimal.dockerfile @@ -32,6 +32,7 @@ RUN apt-get update -y -q && \ git \ libssl-dev \ libcurl4-openssl-dev \ + patch \ python3-pip \ tzdata \ tzdata-legacy \ diff --git a/ci/docker/ubuntu-24.04-cpp.dockerfile b/ci/docker/ubuntu-24.04-cpp.dockerfile index 7d0772c33a2..ccaccee3fd0 100644 --- a/ci/docker/ubuntu-24.04-cpp.dockerfile +++ b/ci/docker/ubuntu-24.04-cpp.dockerfile @@ -107,6 +107,7 @@ RUN apt-get update -y -q && \ ninja-build \ nlohmann-json3-dev \ npm \ + patch \ pkg-config \ protobuf-compiler \ protobuf-compiler-grpc \ diff --git a/ci/scripts/r_docker_configure.sh b/ci/scripts/r_docker_configure.sh index 8a962fe576c..0241c85a68e 100755 --- a/ci/scripts/r_docker_configure.sh +++ b/ci/scripts/r_docker_configure.sh @@ -73,7 +73,7 @@ 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. -$PACKAGE_MANAGER install -y rsync cmake curl +$PACKAGE_MANAGER install -y rsync cmake curl patch # Workaround for html help install failure; see https://github.com/r-lib/devtools/issues/2084#issuecomment-530912786 Rscript -e 'x <- file.path(R.home("doc"), "html"); if (!file.exists(x)) {dir.create(x, recursive=TRUE); file.copy(system.file("html/R.css", package="stats"), x)}' diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 495aa704836..920381c3168 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -1353,26 +1353,9 @@ macro(build_snappy) set(SNAPPY_CMAKE_ARGS ${EP_COMMON_CMAKE_ARGS} -DSNAPPY_BUILD_TESTS=OFF -DSNAPPY_BUILD_BENCHMARKS=OFF "-DCMAKE_INSTALL_PREFIX=${SNAPPY_PREFIX}") - # Snappy unconditionally enables -Werror when building with clang this can lead - # to build failures by way of new compiler warnings. This adds a flag to disable - # Werror to the very end of the invocation to override the snappy internal setting. - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - foreach(CONFIG DEBUG MINSIZEREL RELEASE RELWITHDEBINFO) - list(APPEND - SNAPPY_CMAKE_ARGS - "-DCMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}=${EP_CXX_FLAGS_${CONFIG}} -Wno-error" - ) - endforeach() - endif() - - if(APPLE AND CMAKE_HOST_SYSTEM_VERSION VERSION_LESS 20) - # On macOS 10.13 we need to explicitly add to avoid a missing include error - # This can be removed once CRAN no longer checks on macOS 10.13 - find_program(PATCH patch REQUIRED) - set(SNAPPY_PATCH_COMMAND ${PATCH} -p1 -i ${CMAKE_CURRENT_LIST_DIR}/snappy.diff) - else() - set(SNAPPY_PATCH_COMMAND) - endif() + # See comments in snappy.diff. + find_program(PATCH patch REQUIRED) + set(SNAPPY_PATCH_COMMAND ${PATCH} -p1 -i ${CMAKE_CURRENT_LIST_DIR}/snappy.diff) if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # ignore linker flag errors, as Snappy sets diff --git a/cpp/cmake_modules/snappy.diff b/cpp/cmake_modules/snappy.diff index e763636e1da..b41b31df621 100644 --- a/cpp/cmake_modules/snappy.diff +++ b/cpp/cmake_modules/snappy.diff @@ -14,9 +14,41 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -# -# https://github.com/google/snappy/pull/172 +# 1. Snappy unconditionally enables -Werror when building with clang this can lead +# to build failures by way of new compiler warnings. This adds a flag to disable +# -Werror to the very end of the invocation to override the snappy internal setting. +# 2. Snappy unconditionally disables RTTI, which is incompatible with some other +# build settings (https://github.com/apache/arrow/issues/43688). +# 3. On macOS 10.13 we need to explicitly add to avoid a missing +# include error. This can be removed once CRAN no longer checks on macOS 10.13 +# (https://github.com/google/snappy/pull/172). + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c3062e2..21b49a7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -66,20 +66,9 @@ else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") + endif(NOT CMAKE_CXX_FLAGS MATCHES "-Wextra") + +- # Use -Werror for clang only. +- if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") +- if(NOT CMAKE_CXX_FLAGS MATCHES "-Werror") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +- endif(NOT CMAKE_CXX_FLAGS MATCHES "-Werror") +- endif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") +- + # Disable C++ exceptions. + string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") +- +- # Disable RTTI. +- string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") + endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + + # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make diff --git a/snappy.cc b/snappy.cc index d414718..5b0d0d6 100644 --- a/snappy.cc diff --git a/docker-compose.yml b/docker-compose.yml index daa5c74bcb9..14eeeeee6e5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1889,6 +1889,9 @@ services: command: > /bin/bash -c " git config --global --add safe.directory /arrow && + python3 -m venv /build/pyvenv && + source /build/pyvenv/bin/activate && + pip install -U pip setuptools && pip install arrow/dev/archery[lint] && archery lint --all --no-clang-tidy --no-iwyu --no-numpydoc --src /arrow"