ASan/macOS: fix incomplete C/CXX compiler flags.
While testing for {rB40dcf686f04f}, compiler flags got mixed up and non-working ASan configuration was committed. Platform file, which is `include`d after the `CMAKE_C_FLAGS_DEBUG` etc., are set, overwrites those flags instead of appending to them. To fix this, `PLATFORM_CFLAGS` is used to pass the `-fsanitize=*` flags to the C/C++ compiler. Tested on fresh build using both Xcode and Ninja, with & without ccache. Also silence a clang warning for multi-config generators: the object size sanitizer has no effect at -O0, but is explicitly enabled: -fsanitize=object-size [-Winvalid-command-line-argument] Reviewed By: brecht Differential Revision: https://developer.blender.org/D8879
This commit is contained in:
parent
84032fd110
commit
a4c5811e21
Notes:
blender-bot
2023-10-18 15:23:11 +02:00
Referenced by commit 74bcb32c9f
, macOS: Remove ASan debug flags from release config.
|
@ -522,7 +522,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|||
set(_asan_defaults "${_asan_defaults}")
|
||||
elseif(APPLE)
|
||||
# AppleClang doesn't support all sanitizers, but leak gives error.
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
# Build type is not known for multi-config generator, so don't add object-size sanitizer.
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug" OR GENERATOR_IS_MULTI_CONFIG)
|
||||
# Silence the warning that object-size is not effective in -O0.
|
||||
set(_asan_defaults "${_asan_defaults}")
|
||||
else()
|
||||
|
@ -553,9 +554,11 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|||
)
|
||||
string(STRIP "${CLANG_LIB_DIR}" CLANG_LIB_DIR)
|
||||
find_library(
|
||||
COMPILER_ASAN_LIBRARY NAMES libclang_rt.asan_osx_dynamic.dylib
|
||||
COMPILER_ASAN_LIBRARY
|
||||
NAMES
|
||||
libclang_rt.asan_osx_dynamic.dylib
|
||||
PATHS
|
||||
"${CLANG_LIB_DIR}/darwin/"
|
||||
"${CLANG_LIB_DIR}/darwin/"
|
||||
)
|
||||
unset(CLANG_LIB_DIR)
|
||||
else()
|
||||
|
@ -858,6 +861,9 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "Release")
|
|||
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)
|
||||
|
|
|
@ -190,7 +190,7 @@ if(SYSTEMSTUBS_LIBRARY)
|
|||
list(APPEND PLATFORM_LINKLIBS SystemStubs)
|
||||
endif()
|
||||
|
||||
set(PLATFORM_CFLAGS "-pipe -funsigned-char")
|
||||
set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -pipe -funsigned-char")
|
||||
set(PLATFORM_LINKFLAGS
|
||||
"-fexceptions -framework CoreServices -framework Foundation -framework IOKit -framework AppKit -framework Cocoa -framework Carbon -framework AudioUnit -framework AudioToolbox -framework CoreAudio -framework Metal -framework QuartzCore"
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue