diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt --- a/compiler-rt/lib/asan/CMakeLists.txt +++ b/compiler-rt/lib/asan/CMakeLists.txt @@ -228,12 +228,14 @@ add_sanitizer_rt_version_list(clang_rt.asan-dynamic-${arch} LIBS clang_rt.asan-${arch} clang_rt.asan_cxx-${arch} EXTRA asan.syms.extra) - set(VERSION_SCRIPT_FLAG - -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/clang_rt.asan-dynamic-${arch}.vers) - # The Solaris 11.4 linker supports a subset of GNU ld version scripts, - # but requires a special option to enable it. - if (OS_NAME MATCHES "SunOS") + if (NOT ${LLVM_LINKER_IS_SOLARISLD}) + set(VERSION_SCRIPT_FLAG + -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/clang_rt.asan-dynamic-${arch}.vers) + # The Solaris 11.4 linker supports a subset of GNU ld version scripts, + # but requires a special option to enable it. + if (OS_NAME MATCHES "SunOS") list(APPEND VERSION_SCRIPT_FLAG -Wl,-z,gnu-version-script-compat) + endif() endif() set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp diff --git a/compiler-rt/lib/ubsan/CMakeLists.txt b/compiler-rt/lib/ubsan/CMakeLists.txt --- a/compiler-rt/lib/ubsan/CMakeLists.txt +++ b/compiler-rt/lib/ubsan/CMakeLists.txt @@ -212,13 +212,15 @@ LIBS clang_rt.ubsan_standalone-${arch} clang_rt.ubsan_standalone_cxx-${arch} EXTRA ubsan.syms.extra) - set(VERSION_SCRIPT_FLAG - -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/clang_rt.ubsan_standalone-dynamic-${arch}.vers) - # The Solaris 11.4 linker supports a subset of GNU ld version scripts, - # but requires a special option to enable it. - if (OS_NAME MATCHES "SunOS") + if (NOT ${LLVM_LINKER_IS_SOLARISLD}) + set(VERSION_SCRIPT_FLAG + -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/clang_rt.ubsan_standalone-dynamic-${arch}.vers) + # The Solaris 11.4 linker supports a subset of GNU ld version scripts, + # but requires a special option to enable it. + if (OS_NAME MATCHES "SunOS") list(APPEND VERSION_SCRIPT_FLAG -Wl,-z,gnu-version-script-compat) - endif() + endif() + endif() set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp APPEND PROPERTY