From 74bcb32c9f02a99ffa4b441aa5caa3e96f5be91f Mon Sep 17 00:00:00 2001 From: Ankit Meel Date: Sat, 26 Sep 2020 13:05:33 +0530 Subject: [PATCH] macOS: Remove ASan debug flags from release config. Setting `PLATFORM_LINKLIBS` is not required for clang, compiler and linker flags are enough. Note that the change made in {rBa4c5811e2127}) to `platform_apple.cmake` (appending to `PLATFORM_CFLAGS`) has not been reverted. platform file shouldn't be overwriting the flags. `PLATFORM_LINKFLAGS` is overwritten by `platform_apple.cmake`, so no point in setting it. Fixing that like `PLATFORM_CFLAGS` is out of the scope of this change. `PLATFORM_LINKFLAGS_DEBUG` has been replaced with generator expression to include RelWithDebInfo and MinSizeRel build types also. --- CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf8af6a17b7..c858862df94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -859,13 +859,13 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "Release") if(MSVC) set(COMPILER_ASAN_LINKER_FLAGS "/FUNCTIONPADMIN:6") endif() - if(APPLE) - # COMPILER_ASAN_CFLAGS and COMPILER_ASAN_CXXFLAGS are the same as of - # now, so use either for PLATFORM_CFLAGS. - set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} ${COMPILER_ASAN_CFLAGS}") - set(COMPILER_ASAN_LINKER_FLAGS "-fno-omit-frame-pointer -fsanitize=address") - endif(APPLE) - if(COMPILER_ASAN_LIBRARY) + + if(APPLE AND COMPILER_ASAN_LIBRARY) + string(REPLACE " " ";" _list_COMPILER_ASAN_CFLAGS ${COMPILER_ASAN_CFLAGS}) + add_compile_options("$<$>:${_list_COMPILER_ASAN_CFLAGS}>") + add_link_options("$<$>:-fno-omit-frame-pointer;-fsanitize=address>") + unset(_list_COMPILER_ASAN_CFLAGS) + elseif(COMPILER_ASAN_LIBRARY) set(PLATFORM_LINKLIBS "${PLATFORM_LINKLIBS};${COMPILER_ASAN_LIBRARY}") set(PLATFORM_LINKFLAGS "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}") set(PLATFORM_LINKFLAGS_DEBUG "${COMPILER_ASAN_LIBRARY} ${COMPILER_ASAN_LINKER_FLAGS}")