CMake: Fix sanitizer build when using Clang on Linux

Apparently the combination of the --no-undefined linker flag together
with ASAN when building on Linux with Clang does not work.

Disable --no-undefined flag in such a scenario. Note that linux-clang
mkspec doesn't add that flag at all, which is why asan builds work
there.

Change-Id: I6167c757ce4be5d2263311bc84e5fb445b0f7c2d
Fixes: QTBUG-86879
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2020-09-24 17:00:25 +02:00
parent 22bf3a4511
commit 3031787485

View File

@ -51,6 +51,9 @@ function(qt_internal_add_link_flags_no_undefined target)
return()
endif()
if (GCC OR CLANG)
if(CLANG AND QT_FEATURE_sanitizer)
return()
endif()
set(previous_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,-undefined,error")