mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Fix linking with address sanitizer.
`-fsanitize=address` also needs to be passed to the linker.
This commit is contained in:
parent
16f5cc8c24
commit
90e1d969ac
|
@ -191,18 +191,14 @@ endif()
|
||||||
|
|
||||||
option(ASAN "Enable address-sanitizer to detect invalid memory accesses" OFF)
|
option(ASAN "Enable address-sanitizer to detect invalid memory accesses" OFF)
|
||||||
if(ASAN)
|
if(ASAN)
|
||||||
set(SAFE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
|
|
||||||
set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=address")
|
|
||||||
add_cflag("-fsanitize=address")
|
add_cflag("-fsanitize=address")
|
||||||
set(CMAKE_REQUIRED_LIBRARIES "${SAFE_CMAKE_REQUIRED_LIBRARIES}")
|
add_dllflag("-fsanitize=address")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LINUX)
|
||||||
|
add_dllflag("-Wl,-z,defs")
|
||||||
else()
|
else()
|
||||||
# Forbid undefined symbols in shared libraries. This is incompatible with
|
add_dllflag("-undefined error")
|
||||||
# asan, so it's in the else branch here.
|
|
||||||
if(LINUX)
|
|
||||||
add_dllflag("-Wl,-z,defs")
|
|
||||||
else()
|
|
||||||
add_dllflag("-undefined error")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(USE_IPV6 "Use IPv6 in tests" ON)
|
option(USE_IPV6 "Use IPv6 in tests" ON)
|
||||||
|
|
|
@ -37,6 +37,7 @@ function(add_dllflag flag)
|
||||||
check_c_compiler_flag("${flag}" HAVE_LD${var} QUIET)
|
check_c_compiler_flag("${flag}" HAVE_LD${var} QUIET)
|
||||||
if(HAVE_LD${var})
|
if(HAVE_LD${var})
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${flag}" PARENT_SCOPE)
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${flag}" PARENT_SCOPE)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}" PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user