Skip to content

Commit 0a362eb

Browse files
ZhongRuoyucopybara-github
authored andcommitted
PR #1412: Filter out -Xarch_ flags from pkg-config files
Imported from GitHub PR #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 89d20ab into 34604d5 Merging this change closes #1412 COPYBARA_INTEGRATE_REVIEW=#1412 from ZhongRuoyu:xarch-pkgconfig 89d20ab PiperOrigin-RevId: 606730193 Change-Id: I3e177a56721acd3145fd03c64102741898afd2a5
1 parent 4ea6e47 commit 0a362eb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

CMake/AbseilHelpers.cmake

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,16 @@ function(absl_cc_library)
186186
endif()
187187
endif()
188188
endforeach()
189+
set(skip_next_cflag OFF)
189190
foreach(cflag ${ABSL_CC_LIB_COPTS})
190-
if(${cflag} MATCHES "^(-Wno|/wd)")
191+
if(skip_next_cflag)
192+
set(skip_next_cflag OFF)
193+
elseif(${cflag} MATCHES "^-Xarch_")
194+
# An -Xarch_ flag implies that its successor only applies to the
195+
# specified platform. Filter both of them out before the successor
196+
# reaches the "^-m" filter.
197+
set(skip_next_cflag ON)
198+
elseif(${cflag} MATCHES "^(-Wno|/wd)")
191199
# These flags are needed to suppress warnings that might fire in our headers.
192200
set(PC_CFLAGS "${PC_CFLAGS} ${cflag}")
193201
elseif(${cflag} MATCHES "^(-W|/w[1234eo])")

0 commit comments

Comments
 (0)