diff options
| author | Bhushan Shah <bhush94@gmail.com> | 2022-01-26 13:16:28 +0530 | 
|---|---|---|
| committer | Bhushan Shah <bhush94@gmail.com> | 2022-01-26 13:16:28 +0530 | 
| commit | fffae63daa48648784919aec4b576034e44a2da0 (patch) | |
| tree | 769a578a5f3de17d94fcf139504b7db28e0a1623 | |
| parent | 9ff6f346b7e5265fb89c8e946b3ee841f6d4c305 (diff) | |
| download | extra-cmake-modules-fffae63daa48648784919aec4b576034e44a2da0.tar.gz extra-cmake-modules-fffae63daa48648784919aec4b576034e44a2da0.tar.bz2 | |
Revert "ECMEnableSanitizers: do not enable linker flags when not supported"
This reverts commit abc3a698abc0dfea19040007a7c57d04c3bb6865.
Unfortunately it caused various problems:
- Minimum cmake version for extra-cmake-modules does not contain the
  required module
- Even with newer cmake it had issue with old policy that was not fixed
  until very late that breaks packages using old policy
CCMAIL: kde-frameworks-devel@kde.org
| -rw-r--r-- | modules/ECMEnableSanitizers.cmake | 27 | 
1 files changed, 10 insertions, 17 deletions
| diff --git a/modules/ECMEnableSanitizers.cmake b/modules/ECMEnableSanitizers.cmake index 42d5fcb7..84f1819c 100644 --- a/modules/ECMEnableSanitizers.cmake +++ b/modules/ECMEnableSanitizers.cmake @@ -74,7 +74,6 @@ This is an example of usage::  Since 1.3.0.  #]=======================================================================] -include(CheckLinkerFlag)  # MACRO check_compiler_version  #-----------------------------  macro (check_compiler_version gcc_required_version clang_required_version msvc_required_version) @@ -148,24 +147,18 @@ if (ECM_ENABLE_SANITIZERS)              string(TOLOWER ${CUR_SANITIZER} CUR_SANITIZER)              # check option and enable appropriate flags              enable_sanitizer_flags ( ${CUR_SANITIZER} ) -            check_linker_flag(CXX "-l${XSAN_LINKER_FLAGS}" _HAVE_XSAN_LINKER_FLAGS) -            if (_HAVE_XSAN_LINKER_FLAGS) -              # TODO: GCC will not link pthread library if enabled ASan -              if(CMAKE_C_COMPILER_ID MATCHES "Clang") -                string(APPEND CMAKE_C_FLAGS " ${XSAN_COMPILE_FLAGS}") -              endif() -              string(APPEND CMAKE_CXX_FLAGS " ${XSAN_COMPILE_FLAGS}") -              if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") -                  link_libraries(${XSAN_LINKER_FLAGS}) -              endif() -              if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") +            # TODO: GCC will not link pthread library if enabled ASan +            if(CMAKE_C_COMPILER_ID MATCHES "Clang") +              set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XSAN_COMPILE_FLAGS}" ) +            endif() +            set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${XSAN_COMPILE_FLAGS}" ) +            if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") +              link_libraries(${XSAN_LINKER_FLAGS}) +            endif() +            if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")                  string(REPLACE "-Wl,--no-undefined" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")                  string(REPLACE "-Wl,--no-undefined" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}") -              endif () -            else() -              message(STATUS "Tried to enable sanitizers -DECM_ENABLE_SANITIZERS=${ECM_ENABLE_SANITIZERS}, \ -but linker does not have sanitizer support") -            endif() +            endif ()          endforeach()      else()          message(STATUS "Tried to enable sanitizers (-DECM_ENABLE_SANITIZERS=${ECM_ENABLE_SANITIZERS}), \ | 
