Skip to content

Commit 26ee072

Browse files
Royna2544copybara-github
authored andcommitted
PR #1710: fixup! PR #1707: Fixup absl_random compile breakage in Apple ARM64 targets
Imported from GitHub PR #1710 Use the SHELL: prefix in compile flag string to avoid passing it as quoted string Introduced in CMake 3.12, but as CMake 3.16 is required by this project it will be ok. According to https://cmake.org/cmake/help/latest/command/target_compile_options.html#option-de-duplication, CMake's target_compile_options ignores duplicate items, like from the quote of the link: > While beneficial for individual options, the de-duplication step can break up option groups. For example, -option A -option B becomes -option A B. One may specify a group of options using shell-like quoting along with a SHELL: prefix. This was our problem, -option A -option B should be there, but CMake just made it like -option A B, B was not guarded by -Xarch which led to a compilation error. I originally tried the fix with quoting the "-option A", but it led to the quoted string passed to the compiler, and therefore ignored. Now I am using the SHELL: suffix supported by CMake, and it shows differences: > Current build command with quotes: > ... -DNOMINMAX "-Xarch_x86_64 -maes" "-Xarch_x86_64 -msse4.1" ... (Wrong) > With the SHELL: prefix applied: > ... -DNOMINMAX -Xarch_x86_64 -maes -Xarch_x86_64 -msse4.1 ... (Correct) Merge 6615346 into cd7f66c Merging this change closes #1710 COPYBARA_INTEGRATE_REVIEW=#1710 from Royna2544:master 6615346 PiperOrigin-RevId: 651433382 Change-Id: I4c626e18ae8b33a8177ea79714b9678f955f469f
1 parent db1255c commit 26ee072

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

absl/copts/AbseilConfigureCopts.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES [[Clang]])
4242
string(TOUPPER "${_arch}" _arch_uppercase)
4343
string(REPLACE "X86_64" "X64" _arch_uppercase ${_arch_uppercase})
4444
foreach(_flag IN LISTS ABSL_RANDOM_HWAES_${_arch_uppercase}_FLAGS)
45-
list(APPEND ABSL_RANDOM_RANDEN_COPTS "-Xarch_${_arch} ${_flag}")
45+
list(APPEND ABSL_RANDOM_RANDEN_COPTS "SHELL:-Xarch_${_arch} ${_flag}")
4646
endforeach()
4747
endforeach()
4848
# If a compiler happens to deal with an argument for a currently unused

0 commit comments

Comments
 (0)