From 2d354329dc642b8e952d42ca58aa14ad297b3edd Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 11 Jul 2024 23:36:49 +0200 Subject: [PATCH 1/5] Fixes #2998 --- ci/install_abseil.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/ci/install_abseil.sh b/ci/install_abseil.sh index 46a7870627..92dee9904f 100755 --- a/ci/install_abseil.sh +++ b/ci/install_abseil.sh @@ -22,6 +22,61 @@ if [ ! -z "${CXX_STANDARD}" ]; then ABSEIL_CPP_BUILD_OPTIONS=(${ABSEIL_CPP_BUILD_OPTIONS[@]} "-DCMAKE_CXX_STANDARD=${CXX_STANDARD}") fi +# +# ABSEIL_CPP_VERSION="20240116.1" fails to build with CMake 3.30 +# ABSEIL_CPP_VERSION="20240116.2" fails to build with CMake 3.30 +# note that somehow the same builds with CMake 3.29.6 +# +# Error reported: +# CMake Error at CMake/AbseilHelpers.cmake:317 (target_link_libraries): +# The link interface of target "test_allocator" contains: +# +# GTest::gmock +# +# but the target was not found. Possible reasons include: +# +# * There is a typo in the target name. +# * A find_package call is missing for an IMPORTED target. +# * An ALIAS target is missing. +# +# Call Stack (most recent call first): +# absl/container/CMakeLists.txt:206 (absl_cc_library) +# +# Root cause: +# https://github.com/abseil/abseil-cpp/pull/1536 +# +# Applying fix from abseil commit 779a3565ac6c5b69dd1ab9183e500a27633117d5 +# +# TODO(marcalff) Cleanup once abseil is upgraded to the next LTS + +echo "Patching abseil" + +patch -p1 << EOF +commit 779a3565ac6c5b69dd1ab9183e500a27633117d5 +Author: Derek Mauro +Date: Tue Jan 30 10:13:25 2024 -0800 + + Avoid export of testonly target absl::test_allocator in CMake builds + + Closes #1536 + + PiperOrigin-RevId: 602764437 + Change-Id: Ia5c20a3874262a2ddb8797f608af17d7e86dd6d6 + +diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt +index 449a2cad..ee9ca9c3 100644 +--- a/absl/container/CMakeLists.txt ++++ b/absl/container/CMakeLists.txt +@@ -213,6 +213,7 @@ absl_cc_library( + DEPS + absl::config + GTest::gmock ++ TESTONLY + ) + + absl_cc_test( +EOF + mkdir build && pushd build cmake "${ABSEIL_CPP_BUILD_OPTIONS[@]}" .. make -j $(nproc) From 3b1f185bbdf486c1b9349004fe83733e1ef1e6f1 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 11 Jul 2024 23:53:08 +0200 Subject: [PATCH 2/5] Only fix 20240116 --- ci/install_abseil.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ci/install_abseil.sh b/ci/install_abseil.sh index 92dee9904f..82756b8d88 100755 --- a/ci/install_abseil.sh +++ b/ci/install_abseil.sh @@ -49,9 +49,10 @@ fi # # TODO(marcalff) Cleanup once abseil is upgraded to the next LTS -echo "Patching abseil" -patch -p1 << EOF +if [ "${ABSEIL_CPP_VERSION}" -eq "20240116.1" ] || [ "${ABSEIL_CPP_VERSION}" -eq "20240116.2" ]; then + echo "Patching abseil" + patch -p1 << EOF commit 779a3565ac6c5b69dd1ab9183e500a27633117d5 Author: Derek Mauro Date: Tue Jan 30 10:13:25 2024 -0800 @@ -76,6 +77,9 @@ index 449a2cad..ee9ca9c3 100644 absl_cc_test( EOF +else + echo "Not patching abseil" +fi mkdir build && pushd build cmake "${ABSEIL_CPP_BUILD_OPTIONS[@]}" .. From 8185835b5953c6eeeb676cb63bb29c54d0d4a822 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 11 Jul 2024 23:58:37 +0200 Subject: [PATCH 3/5] bash syntax --- ci/install_abseil.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/install_abseil.sh b/ci/install_abseil.sh index 82756b8d88..b0c07e6ec5 100755 --- a/ci/install_abseil.sh +++ b/ci/install_abseil.sh @@ -50,7 +50,7 @@ fi # TODO(marcalff) Cleanup once abseil is upgraded to the next LTS -if [ "${ABSEIL_CPP_VERSION}" -eq "20240116.1" ] || [ "${ABSEIL_CPP_VERSION}" -eq "20240116.2" ]; then +if [ "${ABSEIL_CPP_VERSION}" = "20240116.1" ] || [ "${ABSEIL_CPP_VERSION}" = "20240116.2" ]; then echo "Patching abseil" patch -p1 << EOF commit 779a3565ac6c5b69dd1ab9183e500a27633117d5 From 7d842adc098e5c7909c3298bc11077f7be274846 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Fri, 12 Jul 2024 00:19:30 +0200 Subject: [PATCH 4/5] Work around format that wants to change *.sh --- ci/fix-abseil-cpp-issue-1536.patch | 23 +++++++++++++++++++++++ ci/install_abseil.sh | 27 +++------------------------ 2 files changed, 26 insertions(+), 24 deletions(-) create mode 100644 ci/fix-abseil-cpp-issue-1536.patch diff --git a/ci/fix-abseil-cpp-issue-1536.patch b/ci/fix-abseil-cpp-issue-1536.patch new file mode 100644 index 0000000000..7004cf0479 --- /dev/null +++ b/ci/fix-abseil-cpp-issue-1536.patch @@ -0,0 +1,23 @@ +commit 779a3565ac6c5b69dd1ab9183e500a27633117d5 +Author: Derek Mauro +Date: Tue Jan 30 10:13:25 2024 -0800 + + Avoid export of testonly target absl::test_allocator in CMake builds + + Closes #1536 + + PiperOrigin-RevId: 602764437 + Change-Id: Ia5c20a3874262a2ddb8797f608af17d7e86dd6d6 + +diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt +index 449a2cad..ee9ca9c3 100644 +--- a/absl/container/CMakeLists.txt ++++ b/absl/container/CMakeLists.txt +@@ -213,6 +213,7 @@ absl_cc_library( + DEPS + absl::config + GTest::gmock ++ TESTONLY + ) + + absl_cc_test( diff --git a/ci/install_abseil.sh b/ci/install_abseil.sh index b0c07e6ec5..5c06e9a995 100755 --- a/ci/install_abseil.sh +++ b/ci/install_abseil.sh @@ -7,6 +7,8 @@ set -ex export DEBIAN_FRONTEND=noninteractive [ -z "${ABSEIL_CPP_VERSION}" ] && export ABSEIL_CPP_VERSION="20240116.1" +TOPDIR=`pwd` + BUILD_DIR=/tmp/ INSTALL_DIR=/usr/local/ pushd $BUILD_DIR @@ -52,30 +54,7 @@ fi if [ "${ABSEIL_CPP_VERSION}" = "20240116.1" ] || [ "${ABSEIL_CPP_VERSION}" = "20240116.2" ]; then echo "Patching abseil" - patch -p1 << EOF -commit 779a3565ac6c5b69dd1ab9183e500a27633117d5 -Author: Derek Mauro -Date: Tue Jan 30 10:13:25 2024 -0800 - - Avoid export of testonly target absl::test_allocator in CMake builds - - Closes #1536 - - PiperOrigin-RevId: 602764437 - Change-Id: Ia5c20a3874262a2ddb8797f608af17d7e86dd6d6 - -diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt -index 449a2cad..ee9ca9c3 100644 ---- a/absl/container/CMakeLists.txt -+++ b/absl/container/CMakeLists.txt -@@ -213,6 +213,7 @@ absl_cc_library( - DEPS - absl::config - GTest::gmock -+ TESTONLY - ) - - absl_cc_test( + patch -p1 < ${TOPDIR}/ci/fix-abseil-cpp-issue-1536.patch EOF else echo "Not patching abseil" From 6a908d615d0bd92315305af4ac8b092c5e7a098c Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Fri, 12 Jul 2024 00:29:18 +0200 Subject: [PATCH 5/5] cleanup --- ci/install_abseil.sh | 1 - tools/format.sh | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ci/install_abseil.sh b/ci/install_abseil.sh index 5c06e9a995..ced090cc64 100755 --- a/ci/install_abseil.sh +++ b/ci/install_abseil.sh @@ -55,7 +55,6 @@ fi if [ "${ABSEIL_CPP_VERSION}" = "20240116.1" ] || [ "${ABSEIL_CPP_VERSION}" = "20240116.2" ]; then echo "Patching abseil" patch -p1 < ${TOPDIR}/ci/fix-abseil-cpp-issue-1536.patch -EOF else echo "Not patching abseil" fi diff --git a/tools/format.sh b/tools/format.sh index 65728b385f..3a3863a8ea 100755 --- a/tools/format.sh +++ b/tools/format.sh @@ -23,8 +23,8 @@ fi # No CRLF line endings, except Windows files. "${SED[@]}" 's/\r$//' $($FIND -name '*.ps1' -prune -o \ -name '*.cmd' -prune -o -type f -print) -# No trailing spaces. -"${SED[@]}" 's/ \+$//' $($FIND -type f -print) +# No trailing spaces, except in patch. +"${SED[@]}" 's/ \+$//' $($FIND -name "*.patch" -prune -o -type f -print) # If not overridden, try to use clang-format-18 or clang-format. if [[ -z "$CLANG_FORMAT" ]]; then