[compiler-rt] 443e734 - [compiler-rt][cmake] Don't pass --version-script to Illumos ld
Rainer Orth via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 28 04:22:26 PDT 2020
Author: Rainer Orth
Date: 2020-07-28T13:21:36+02:00
New Revision: 443e734fb98df422c90cbc8177520a8182597912
URL: https://github.com/llvm/llvm-project/commit/443e734fb98df422c90cbc8177520a8182597912
DIFF: https://github.com/llvm/llvm-project/commit/443e734fb98df422c90cbc8177520a8182597912.diff
LOG: [compiler-rt][cmake] Don't pass --version-script to Illumos ld
Neither the Illumos `ld` nor the Solaris 11.3 one support the `--version-script` and
`z gnu-linker-script-compat` options, which breaks the `compiler-rt` build.
This patch checks for both options instead of hardcoding their use.
Tested on `amd-pc-solaris2.11` (all of Solaris 11.4, 11.3, and Illumos).
Differential Revision: https://reviews.llvm.org/D84559
Added:
Modified:
compiler-rt/cmake/config-ix.cmake
compiler-rt/lib/asan/CMakeLists.txt
compiler-rt/lib/ubsan/CMakeLists.txt
Removed:
################################################################################
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 0a27910ed494..74fef8933ef9 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -157,6 +157,19 @@ check_library_exists(stdc++ __cxa_throw "" COMPILER_RT_HAS_LIBSTDCXX)
check_linker_flag("-Wl,-z,text" COMPILER_RT_HAS_Z_TEXT)
check_linker_flag("-fuse-ld=lld" COMPILER_RT_HAS_FUSE_LD_LLD_FLAG)
+set(VERS_COMPAT_OPTION "-Wl,-z,gnu-version-script-compat")
+check_linker_flag("${VERS_COMPAT_OPTION}" COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
+
+set(DUMMY_VERS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/dummy.vers)
+file(WRITE ${DUMMY_VERS} "{};")
+set(VERS_OPTION "-Wl,--version-script,${DUMMY_VERS}")
+if(COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
+ # Solaris 11.4 ld only supports --version-script with
+ # -z gnu-version-script-compat.
+ string(APPEND VERS_OPTION " ${VERS_COMPAT_OPTION}")
+endif()
+check_linker_flag("${VERS_OPTION}" COMPILER_RT_HAS_VERSION_SCRIPT)
+
if(ANDROID)
check_linker_flag("-Wl,-z,global" COMPILER_RT_HAS_Z_GLOBAL)
check_library_exists(log __android_log_write "" COMPILER_RT_HAS_LIBLOG)
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index 2a1bbb58cce4..0c29893ebfe2 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -224,7 +224,7 @@ else()
PARENT_TARGET asan)
foreach(arch ${ASAN_SUPPORTED_ARCH})
- if (UNIX)
+ if (UNIX AND COMPILER_RT_HAS_VERSION_SCRIPT)
add_sanitizer_rt_version_list(clang_rt.asan-dynamic-${arch}
LIBS clang_rt.asan-${arch} clang_rt.asan_cxx-${arch}
EXTRA asan.syms.extra)
@@ -232,7 +232,7 @@ else()
-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 (COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
list(APPEND VERSION_SCRIPT_FLAG -Wl,-z,gnu-version-script-compat)
endif()
set_property(SOURCE
diff --git a/compiler-rt/lib/ubsan/CMakeLists.txt b/compiler-rt/lib/ubsan/CMakeLists.txt
index dca02a65e971..00b74a63cbe5 100644
--- a/compiler-rt/lib/ubsan/CMakeLists.txt
+++ b/compiler-rt/lib/ubsan/CMakeLists.txt
@@ -200,7 +200,7 @@ else()
CFLAGS ${UBSAN_CXXFLAGS}
PARENT_TARGET ubsan)
- if (FUCHSIA OR UNIX)
+ if ((FUCHSIA OR UNIX) AND COMPILER_RT_HAS_VERSION_SCRIPT)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp "")
add_compiler_rt_object_libraries(RTUbsan_dynamic_version_script_dummy
ARCHS ${UBSAN_SUPPORTED_ARCH}
@@ -216,7 +216,7 @@ else()
-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 (COMPILER_RT_HAS_GNU_VERSION_SCRIPT_COMPAT)
list(APPEND VERSION_SCRIPT_FLAG -Wl,-z,gnu-version-script-compat)
endif()
set_property(SOURCE
More information about the llvm-commits
mailing list