From 0a362eb290044fa39f6c6a120e4627ff9998e55b Mon Sep 17 00:00:00 2001 From: Ruoyu Zhong Date: Tue, 13 Feb 2024 13:34:13 -0800 Subject: PR #1412: Filter out `-Xarch_` flags from pkg-config files Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1412 In Clang, an `-Xarch_` compiler flag indicates that its successor only applies to the specified platform (e.g., `-Xarch_x86_64 -maes`). This is used in `absl/copts/AbseilConfigureCopts.cmake` to selectively enable hardware AES support on Apple platforms. However, when generating pkg-config files, those `-m` flags are filtered out, while the `-Xarch_` flags that precede them are left untouched. This led to the error reported in #1408. Fix that by filtering out each `-Xarch_` flag with its successor at once. Fixes #1408. Merge 89d20ab816b7cead56f05d5a6bc5146d1c4f4335 into 34604d5b1f6ae14c65b3992478b59f7108051979 Merging this change closes #1412 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1412 from ZhongRuoyu:xarch-pkgconfig 89d20ab816b7cead56f05d5a6bc5146d1c4f4335 PiperOrigin-RevId: 606730193 Change-Id: I3e177a56721acd3145fd03c64102741898afd2a5 --- CMake/AbseilHelpers.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'CMake/AbseilHelpers.cmake') diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake index bd1c71b0..44f5bb3f 100644 --- a/CMake/AbseilHelpers.cmake +++ b/CMake/AbseilHelpers.cmake @@ -186,8 +186,16 @@ function(absl_cc_library) endif() endif() endforeach() + set(skip_next_cflag OFF) foreach(cflag ${ABSL_CC_LIB_COPTS}) - if(${cflag} MATCHES "^(-Wno|/wd)") + if(skip_next_cflag) + set(skip_next_cflag OFF) + elseif(${cflag} MATCHES "^-Xarch_") + # An -Xarch_ flag implies that its successor only applies to the + # specified platform. Filter both of them out before the successor + # reaches the "^-m" filter. + set(skip_next_cflag ON) + elseif(${cflag} MATCHES "^(-Wno|/wd)") # These flags are needed to suppress warnings that might fire in our headers. set(PC_CFLAGS "${PC_CFLAGS} ${cflag}") elseif(${cflag} MATCHES "^(-W|/w[1234eo])") -- cgit v1.2.3 From d06b82773e2306a99a8971934fb5845d5c04a170 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Fri, 31 May 2024 14:31:21 -0700 Subject: Move SOVERSION to global CMakeLists, apply SOVERSION to DLL So that multiple LTS builds can co-exist. PiperOrigin-RevId: 639154515 Change-Id: Id34d6fbef823151a4f3c73cf7b9b340257eadd63 --- CMake/AbseilDll.cmake | 5 ++++- CMake/AbseilHelpers.cmake | 2 +- CMakeLists.txt | 1 + create_lts.py | 27 ++++++++++++++------------- 4 files changed, 20 insertions(+), 15 deletions(-) (limited to 'CMake/AbseilHelpers.cmake') diff --git a/CMake/AbseilDll.cmake b/CMake/AbseilDll.cmake index 88e1d35f..828cc347 100644 --- a/CMake/AbseilDll.cmake +++ b/CMake/AbseilDll.cmake @@ -827,7 +827,10 @@ function(absl_make_dll) ${_dll_libs} ${ABSL_DEFAULT_LINKOPTS} ) - set_property(TARGET ${_dll} PROPERTY LINKER_LANGUAGE "CXX") + set_target_properties(${_dll} PROPERTIES + LINKER_LANGUAGE "CXX" + SOVERSION ${ABSL_SOVERSION} + ) target_include_directories( ${_dll} PUBLIC diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake index 44f5bb3f..70a37f11 100644 --- a/CMake/AbseilHelpers.cmake +++ b/CMake/AbseilHelpers.cmake @@ -306,7 +306,7 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n") if(ABSL_ENABLE_INSTALL) set_target_properties(${_NAME} PROPERTIES OUTPUT_NAME "absl_${_NAME}" - SOVERSION 0 + SOVERSION "${ABSL_SOVERSION}" ) endif() else() diff --git a/CMakeLists.txt b/CMakeLists.txt index 56c054ef..d88283b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,6 +59,7 @@ if (POLICY CMP0141) endif (POLICY CMP0141) project(absl LANGUAGES CXX) +set(ABSL_SOVERSION 0) include(CTest) # Output directory is correct by default for most build setups. However, when diff --git a/create_lts.py b/create_lts.py index 7e5368e1..c20577a7 100755 --- a/create_lts.py +++ b/create_lts.py @@ -116,20 +116,21 @@ def main(argv): datestamp) }) ReplaceStringsInFile( - 'CMakeLists.txt', { - 'project(absl LANGUAGES CXX)': + 'CMakeLists.txt', + { + 'project(absl LANGUAGES CXX)': ( 'project(absl LANGUAGES CXX VERSION {})'.format(datestamp) - }) - # Set the SOVERSION to YYMM.0.0 - The first 0 means we only have ABI - # compatible changes, and the second 0 means we can increment it to - # mark changes as ABI-compatible, for patch releases. Note that we - # only use the last two digits of the year and the month because the - # MacOS linker requires the first part of the SOVERSION to fit into - # 16 bits. - # https://www.sicpers.info/2013/03/how-to-version-a-mach-o-library/ - ReplaceStringsInFile( - 'CMake/AbseilHelpers.cmake', - {'SOVERSION 0': 'SOVERSION "{}.0.0"'.format(datestamp[2:6])}) + ), + # Set the SOVERSION to YYMM.0.0 - The first 0 means we only have ABI + # compatible changes, and the second 0 means we can increment it to + # mark changes as ABI-compatible, for patch releases. Note that we + # only use the last two digits of the year and the month because the + # MacOS linker requires the first part of the SOVERSION to fit into + # 16 bits. + # https://www.sicpers.info/2013/03/how-to-version-a-mach-o-library/ + 'ABSL_SOVERSION 0': 'ABSL_SOVERSION "{}.0.0"'.format(datestamp[2:6]), + }, + ) StripContentBetweenTags('CMakeLists.txt', '# absl:lts-remove-begin', '# absl:lts-remove-end') -- cgit v1.2.3 From 7e5c339b1aa790ae03cc614a8d7626d5b4831891 Mon Sep 17 00:00:00 2001 From: Derek Mauro <761129+derekmauro@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:28:46 -0400 Subject: Cherry-picks for Release Candidate 2 (#1727) cmake: Fix RUNPATH when using BUILD_WITH_INSTALL_RPATH=True 21385900073e3ca2c4aefb13fd05ca2da40d5ff1 Add absl_vlog_is_on and vlog_is_on to ABSL_INTERNAL_DLL_TARGETS 9a0743ac27df5ec018974e605cf61db7652b26c1 --- CMake/AbseilDll.cmake | 2 ++ CMake/AbseilHelpers.cmake | 7 +++++++ 2 files changed, 9 insertions(+) (limited to 'CMake/AbseilHelpers.cmake') diff --git a/CMake/AbseilDll.cmake b/CMake/AbseilDll.cmake index 24093634..32cc28fb 100644 --- a/CMake/AbseilDll.cmake +++ b/CMake/AbseilDll.cmake @@ -486,6 +486,7 @@ endif() set(ABSL_INTERNAL_DLL_TARGETS "absl_check" "absl_log" + "absl_vlog_is_on" "algorithm" "algorithm_container" "any" @@ -643,6 +644,7 @@ set(ABSL_INTERNAL_DLL_TARGETS "utility" "variant" "vlog_config_internal" + "vlog_is_on" ) if(NOT MSVC) diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake index 70a37f11..b177e590 100644 --- a/CMake/AbseilHelpers.cmake +++ b/CMake/AbseilHelpers.cmake @@ -258,6 +258,13 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n") elseif(_build_type STREQUAL "static" OR _build_type STREQUAL "shared") add_library(${_NAME} "") target_sources(${_NAME} PRIVATE ${ABSL_CC_LIB_SRCS} ${ABSL_CC_LIB_HDRS}) + if(APPLE) + set_target_properties(${_NAME} PROPERTIES + INSTALL_RPATH "@loader_path") + elseif(UNIX) + set_target_properties(${_NAME} PROPERTIES + INSTALL_RPATH "$ORIGIN") + endif() target_link_libraries(${_NAME} PUBLIC ${ABSL_CC_LIB_DEPS} PRIVATE -- cgit v1.2.3