cmake: ASAN and PIE don't mix

Binaries built with both crash on startup with maybe 25% probability
This commit is contained in:
moneromooo-monero 2020-05-15 17:18:50 +00:00
parent 81773f55a4
commit cb4edc1f45
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
1 changed files with 4 additions and 2 deletions

View File

@ -652,7 +652,8 @@ else()
endif() endif()
# linker # linker
if (NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9.1))) if (NOT SANITIZE AND NOT (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9.1)))
# PIE executables randomly crash at startup with ASAN
# Windows binaries die on startup with PIE when compiled with GCC <9.x # Windows binaries die on startup with PIE when compiled with GCC <9.x
add_linker_flag_if_supported(-pie LD_SECURITY_FLAGS) add_linker_flag_if_supported(-pie LD_SECURITY_FLAGS)
endif() endif()
@ -774,7 +775,8 @@ else()
endif(ARM) endif(ARM)
if(ANDROID AND NOT BUILD_GUI_DEPS STREQUAL "ON" OR IOS) # random crash on startup when asan is on if pie is enabled
if(NOT SANITIZE AND ANDROID AND NOT BUILD_GUI_DEPS STREQUAL "ON" OR IOS)
#From Android 5: "only position independent executables (PIE) are supported" #From Android 5: "only position independent executables (PIE) are supported"
message(STATUS "Enabling PIE executable") message(STATUS "Enabling PIE executable")
set(PIC_FLAG "") set(PIC_FLAG "")