diff options
author | Ruoyu Zhong <zhongruoyu@outlook.com> | 2024-02-13 13:34:13 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-02-13 13:35:09 -0800 |
commit | 0a362eb290044fa39f6c6a120e4627ff9998e55b (patch) | |
tree | c122b67530da3a8f40082a20fd3f7ba4de59cdb7 /CMake/AbseilHelpers.cmake | |
parent | 4ea6e47cea43a546307afae982350f0899349c20 (diff) |
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
Diffstat (limited to 'CMake/AbseilHelpers.cmake')
-rw-r--r-- | CMake/AbseilHelpers.cmake | 10 |
1 files changed, 9 insertions, 1 deletions
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])") |