[frameworks/extra-cmake-modules] modules: Revert "ECMEnableSanitizers: do not enable linker flags when not supported"

Bhushan Shah null at kde.org
Wed Jan 26 07:57:12 GMT 2022


Git commit fffae63daa48648784919aec4b576034e44a2da0 by Bhushan Shah.
Committed on 26/01/2022 at 07:46.
Pushed by cgiboudeaux into branch 'master'.

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 at kde.org

M  +10   -17   modules/ECMEnableSanitizers.cmake

https://invent.kde.org/frameworks/extra-cmake-modules/commit/fffae63daa48648784919aec4b576034e44a2da0

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}), \


More information about the Kde-frameworks-devel mailing list