diff --git a/ci/scripts/r_docker_configure.sh b/ci/scripts/r_docker_configure.sh index 4d837d9d7f1..4ac693881fe 100755 --- a/ci/scripts/r_docker_configure.sh +++ b/ci/scripts/r_docker_configure.sh @@ -77,5 +77,19 @@ if [ "$ARROW_S3" == "ON" ] || [ "$ARROW_R_DEV" == "TRUE" ]; then fi fi +# Install patch if it doesn't already exist +if [ ! $(command -v patch) ]; then + if [ "`which dnf`" ]; then + dnf install -y patch + elif [ "`which yum`" ]; then + yum install -y patch + elif [ "`which zypper`" ]; then + zypper install -y patch + else + apt-get update + apt-get install -y patch + fi +fi + # 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/build-support/snappy-UBSAN.patch b/cpp/build-support/snappy-UBSAN.patch new file mode 100644 index 00000000000..61856510bad --- /dev/null +++ b/cpp/build-support/snappy-UBSAN.patch @@ -0,0 +1,30 @@ +# 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. + +diff --git a/snappy.cc b/snappy.cc +index 79dc0e8..2b5e662 100644 +--- a/snappy.cc ++++ b/snappy.cc +@@ -348,7 +348,7 @@ static inline bool Copy64BytesWithPatternExtension(char* dst, size_t offset) { + if (SNAPPY_PREDICT_TRUE(offset < 16)) { + if (SNAPPY_PREDICT_FALSE(offset == 0)) return false; + // Extend the pattern to the first 16 bytes. +- for (int i = 0; i < 16; i++) dst[i] = dst[i - offset]; ++ for (int i = 0; i < 16; i++) dst[i] = (dst - offset)[i]; + // Find a multiple of pattern >= 16. + static std::array pattern_sizes = []() { + std::array res; diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 66d04acae06..5ff3478769e 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -620,6 +620,14 @@ else() "https://github.com/google/snappy/archive/${ARROW_SNAPPY_BUILD_VERSION}.tar.gz" "https://github.com/ursa-labs/thirdparty/releases/download/latest/snappy-${ARROW_SNAPPY_BUILD_VERSION}.tar.gz" ) + + # This can be removed when https://github.com/google/snappy/pull/148 is released + # Some platforms don't have patch, but this is probably ok to skip + find_program(patch "patch") + if(patch) + set(SNAPPY_PATCH_COMMAND "patch" "snappy.cc" + "${CMAKE_SOURCE_DIR}/build-support/snappy-UBSAN.patch") + endif() endif() endif() @@ -1039,6 +1047,7 @@ macro(build_snappy) URL ${SNAPPY_SOURCE_URL} URL_HASH "SHA256=${ARROW_SNAPPY_BUILD_SHA256_CHECKSUM}" CMAKE_ARGS ${SNAPPY_CMAKE_ARGS} + PATCH_COMMAND ${SNAPPY_PATCH_COMMAND} BUILD_BYPRODUCTS "${SNAPPY_STATIC_LIB}") file(MAKE_DIRECTORY "${SNAPPY_PREFIX}/include") diff --git a/cpp/thirdparty/versions.txt b/cpp/thirdparty/versions.txt index 19c19ced0fb..06fd74bab36 100644 --- a/cpp/thirdparty/versions.txt +++ b/cpp/thirdparty/versions.txt @@ -81,6 +81,7 @@ ARROW_RAPIDJSON_BUILD_VERSION=1a803826f1197b5e30703afe4b9c0e7dd48074f5 ARROW_RAPIDJSON_BUILD_SHA256_CHECKSUM=0b6b780b6c534bfb0b23d29910bfe361e486bcfeaf106db8bc8995792072905a ARROW_RE2_BUILD_VERSION=2021-02-02 ARROW_RE2_BUILD_SHA256_CHECKSUM=1396ab50c06c1a8885fb68bf49a5ecfd989163015fd96699a180d6414937f33f +# 1.1.9 is patched to implement https://github.com/google/snappy/pull/148 if this is bumped, remove the patch ARROW_SNAPPY_BUILD_VERSION=1.1.9 ARROW_SNAPPY_BUILD_SHA256_CHECKSUM=75c1fbb3d618dd3a0483bff0e26d0a92b495bbe5059c8b4f1c962b478b6e06e7 # There is a bug in GCC < 4.9 with Snappy 1.1.9, so revert to 1.1.8 for those (ARROW-14661) diff --git a/r/inst/build_arrow_static.sh b/r/inst/build_arrow_static.sh index 38db2bf3fcf..f3856255ab9 100755 --- a/r/inst/build_arrow_static.sh +++ b/r/inst/build_arrow_static.sh @@ -47,6 +47,12 @@ else ARROW_DEFAULT_PARAM="OFF" fi +# Snappy 1.1.9 is patched to implement https://github.com/google/snappy/pull/148 but some platforms don't have +# patch available, so disable snappy in those cases. If the snappy version is bumped, we should remove this. +if [ ! $(command -v patch) ]; then + ARROW_WITH_SNAPPY=OFF +fi + mkdir -p "${BUILD_DIR}" pushd "${BUILD_DIR}" ${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \