From 26ee072e14dea17fa8870d47cd7e8b4cc1c95e93 Mon Sep 17 00:00:00 2001 From: Soo-Hwan Na Date: Thu, 11 Jul 2024 09:16:57 -0700 Subject: PR #1710: fixup! PR #1707: Fixup absl_random compile breakage in Apple ARM64 targets Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/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 661534618fb62c22336e473aff66a8915f9b4185 into cd7f66cab520e99531979b3fd727a25616a1ccbb Merging this change closes #1710 COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1710 from Royna2544:master 661534618fb62c22336e473aff66a8915f9b4185 PiperOrigin-RevId: 651433382 Change-Id: I4c626e18ae8b33a8177ea79714b9678f955f469f --- absl/copts/AbseilConfigureCopts.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'absl') diff --git a/absl/copts/AbseilConfigureCopts.cmake b/absl/copts/AbseilConfigureCopts.cmake index e0007ef8..a618199d 100644 --- a/absl/copts/AbseilConfigureCopts.cmake +++ b/absl/copts/AbseilConfigureCopts.cmake @@ -42,7 +42,7 @@ if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES [[Clang]]) string(TOUPPER "${_arch}" _arch_uppercase) string(REPLACE "X86_64" "X64" _arch_uppercase ${_arch_uppercase}) foreach(_flag IN LISTS ABSL_RANDOM_HWAES_${_arch_uppercase}_FLAGS) - list(APPEND ABSL_RANDOM_RANDEN_COPTS "-Xarch_${_arch} ${_flag}") + list(APPEND ABSL_RANDOM_RANDEN_COPTS "SHELL:-Xarch_${_arch} ${_flag}") endforeach() endforeach() # If a compiler happens to deal with an argument for a currently unused -- cgit v1.2.3