[compiler-rt] r238367 - [asan] Fix build dependency issues with ASan version list file.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Wed May 27 15:38:01 PDT 2015
Author: eugenis
Date: Wed May 27 17:38:01 2015
New Revision: 238367
URL: http://llvm.org/viewvc/llvm-project?rev=238367&view=rev
Log:
[asan] Fix build dependency issues with ASan version list file.
CMake pre-3.1 has a bug where a shared library depending on a custom_target
does not really depend on it.
This commit implements a hilariously ugly workaround for this problem, see
code comments for more details.
Modified:
compiler-rt/trunk/lib/asan/CMakeLists.txt
Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=238367&r1=238366&r2=238367&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Wed May 27 17:38:01 2015
@@ -96,6 +96,12 @@ else()
SOURCES ${ASAN_SOURCES} ${ASAN_CXX_SOURCES}
CFLAGS ${ASAN_DYNAMIC_CFLAGS}
DEFS ${ASAN_DYNAMIC_DEFINITIONS})
+
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummy.cc "")
+ add_compiler_rt_object_library(RTAsan_dynamic_version_script_dummy ${arch}
+ SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummy.cc
+ CFLAGS ${ASAN_DYNAMIC_CFLAGS}
+ DEFS ${ASAN_DYNAMIC_DEFINITIONS})
endforeach()
endif()
@@ -149,9 +155,12 @@ else()
add_sanitizer_rt_version_list(clang_rt.asan-dynamic-${arch}
LIB clang_rt.asan-${arch} clang_rt.asan_cxx-${arch}
EXTRA asan.syms.extra)
- add_dependencies(asan clang_rt.asan-dynamic-${arch}-version-list)
set(VERSION_SCRIPT_FLAG
-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/clang_rt.asan-dynamic-${arch}.vers)
+ set_source_files_properties(
+ ${CMAKE_CURRENT_BINARY_DIR}/dummy.cc
+ PROPERTIES
+ OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/clang_rt.asan-dynamic-${arch}.vers)
else()
set(VERSION_SCRIPT_FLAG)
endif()
@@ -164,6 +173,11 @@ else()
add_compiler_rt_runtime(clang_rt.asan-dynamic-${arch} ${arch} SHARED
OUTPUT_NAME ${SHARED_ASAN_NAME}
SOURCES $<TARGET_OBJECTS:RTAsan_dynamic.${arch}>
+ # The only purpose of RTAsan_dynamic_version_script_dummy is to carry
+ # a dependency of the shared runtime on the version script. With CMake
+ # 3.1 or later it can be replaced with a straightforward
+ # add_dependencies(clang_rt.asan-dynamic-${arch} clang_rt.asan-dynamic-${arch}-version-list)
+ $<TARGET_OBJECTS:RTAsan_dynamic_version_script_dummy.${arch}>
$<TARGET_OBJECTS:RTUbsan_cxx.${arch}>
${ASAN_COMMON_RUNTIME_OBJECTS}
CFLAGS ${ASAN_DYNAMIC_CFLAGS}
@@ -174,7 +188,6 @@ else()
add_dependencies(asan clang_rt.asan-dynamic-${arch})
if (UNIX AND NOT ${arch} MATCHES "i386|i686")
- add_dependencies(clang_rt.asan-dynamic-${arch} clang_rt.asan-dynamic-${arch}-version-list)
add_sanitizer_rt_symbols(clang_rt.asan_cxx-${arch})
add_dependencies(asan clang_rt.asan_cxx-${arch}-symbols)
add_sanitizer_rt_symbols(clang_rt.asan-${arch} asan.syms.extra)
More information about the llvm-commits
mailing list