Another big step toward a viable CMake build system for CompilerRT,
ASan, and friends. This explicitly switches the CompilerRT CMake build to require CMake version 2.8.8 or newer which provides first-class support for "object" libraries which consist of a pile of '.o' files -- exactly what is desired for composing runtime libraries. I've gone ahead and switched to using this. I've also added the interception library which I missed initially. And I've added proper dependencies between the various libraries. With this, I'm able to build archives for asan that appear to contain all of the necessary .o files. The final tweak here is to start setting up the compile flags and macro defines expected by ASan and its helper libraries. These may not be entirely correct currently, they're based loosely on my reading of the old Makefiles. However, they can be tweaked more easily now that they're wired up properly. llvm-svn: 159129
This commit is contained in:
@@ -9,6 +9,12 @@
|
|||||||
|
|
||||||
include(LLVMParseArguments)
|
include(LLVMParseArguments)
|
||||||
|
|
||||||
|
# The CompilerRT build system requires CMake version 2.8.8 or higher in order
|
||||||
|
# to use its support for building convenience "libraries" as a collection of
|
||||||
|
# .o files. This is particularly useful in producing larger, more complex
|
||||||
|
# runtime libraries.
|
||||||
|
cmake_minimum_required(VERSION 2.8.8)
|
||||||
|
|
||||||
# FIXME: Below we assume that the target build of LLVM/Clang is x86, which is
|
# FIXME: Below we assume that the target build of LLVM/Clang is x86, which is
|
||||||
# not at all valid. Much of this can be fixed just by switching to use
|
# not at all valid. Much of this can be fixed just by switching to use
|
||||||
# a just-built-clang binary for the compiles.
|
# a just-built-clang binary for the compiles.
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
# First, add the subdirectories which contain feature-based runtime libraries.
|
# First, add the subdirectories which contain feature-based runtime libraries
|
||||||
add_subdirectory(sanitizer_common)
|
# and several convenience helper libraries.
|
||||||
add_subdirectory(asan)
|
add_subdirectory(asan)
|
||||||
|
add_subdirectory(interception)
|
||||||
|
add_subdirectory(sanitizer_common)
|
||||||
|
|
||||||
# FIXME: Add support for the profile library.
|
# FIXME: Add support for the profile library.
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,33 @@ set(ASAN_SOURCES
|
|||||||
asan_win.cc
|
asan_win.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(ASAN_CFLAGS "-fvisibility=hidden")
|
||||||
|
|
||||||
|
set(ASAN_COMMON_DEFINITIONS
|
||||||
|
ASAN_UAR=0
|
||||||
|
ASAN_HAS_EXCEPTIONS=1
|
||||||
|
ASAN_HAS_BLACKLIST=1
|
||||||
|
ASAN_NEEDS_SEGV=1)
|
||||||
|
|
||||||
if(CAN_TARGET_X86_64)
|
if(CAN_TARGET_X86_64)
|
||||||
add_library(clang_rt.asan-x86_64 STATIC ${ASAN_SOURCES})
|
add_library(clang_rt.asan-x86_64 STATIC
|
||||||
set_target_properties(clang_rt.asan-x86_64 PROPERTIES COMPILE_FLAGS "${TARGET_X86_64_CFLAGS}")
|
${ASAN_SOURCES}
|
||||||
|
$<TARGET_OBJECTS:RTInterception.x86_64>
|
||||||
|
$<TARGET_OBJECTS:RTSanitizerCommon.x86_64>
|
||||||
|
)
|
||||||
|
set_property(TARGET clang_rt.asan-x86_64 PROPERTY COMPILE_FLAGS
|
||||||
|
"${ASAN_CFLAGS} ${TARGET_X86_64_CFLAGS}")
|
||||||
|
set_property(TARGET clang_rt.asan-x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
|
||||||
|
${ASAN_COMMON_DEFINITIONS})
|
||||||
endif()
|
endif()
|
||||||
if(CAN_TARGET_I386)
|
if(CAN_TARGET_I386)
|
||||||
add_library(clang_rt.asan-i386 STATIC ${ASAN_SOURCES})
|
add_library(clang_rt.asan-i386 STATIC
|
||||||
set_target_properties(clang_rt.asan-i386 PROPERTIES COMPILE_FLAGS "${TARGET_I386_CFLAGS}")
|
${ASAN_SOURCES}
|
||||||
|
$<TARGET_OBJECTS:RTInterception.i386>
|
||||||
|
$<TARGET_OBJECTS:RTSanitizerCommon.i386>
|
||||||
|
)
|
||||||
|
set_property(TARGET clang_rt.asan-i386 PROPERTY COMPILE_FLAGS
|
||||||
|
"${ASAN_CFLAGS} ${TARGET_I386_CFLAGS}")
|
||||||
|
set_property(TARGET clang_rt.asan-x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
|
||||||
|
${ASAN_COMMON_DEFINITIONS})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
34
compiler-rt/lib/interception/CMakeLists.txt
Normal file
34
compiler-rt/lib/interception/CMakeLists.txt
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Build for the runtime interception helper library.
|
||||||
|
|
||||||
|
set(INTERCEPTION_SOURCES
|
||||||
|
interception_linux.cc
|
||||||
|
interception_mac.cc
|
||||||
|
interception_win.cc
|
||||||
|
)
|
||||||
|
|
||||||
|
# Only add this C file if we're building on a Mac. Other source files can be
|
||||||
|
# harmlessly compiled on any platform, but the C file is complained about due
|
||||||
|
# to pedantic rules about empty translation units.
|
||||||
|
if (APPLE)
|
||||||
|
list(APPEND INTERCEPTION_SOURCES mach_override/mach_override.c)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(INTERCEPTION_CFLAGS "-fvisibility=hidden")
|
||||||
|
|
||||||
|
set(INTERCEPTION_COMMON_DEFINITIONS
|
||||||
|
INTERCEPTION_HAS_EXCEPTIONS=1)
|
||||||
|
|
||||||
|
if(CAN_TARGET_X86_64)
|
||||||
|
add_library(RTInterception.x86_64 OBJECT ${INTERCEPTION_SOURCES})
|
||||||
|
set_property(TARGET RTInterception.x86_64 PROPERTY COMPILE_FLAGS
|
||||||
|
"${INTERCEPTION_CFLAGS} ${TARGET_X86_64_CFLAGS}")
|
||||||
|
set_property(TARGET RTInterception.x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
|
||||||
|
${INTERCEPTION_COMMON_DEFINITIONS})
|
||||||
|
endif()
|
||||||
|
if(CAN_TARGET_I386)
|
||||||
|
add_library(RTInterception.i386 OBJECT ${INTERCEPTION_SOURCES})
|
||||||
|
set_property(TARGET RTInterception.i386 PROPERTY COMPILE_FLAGS
|
||||||
|
"${INTERCEPTION_CFLAGS} ${TARGET_I386_CFLAGS}")
|
||||||
|
set_property(TARGET RTInterception.i386 APPEND PROPERTY COMPILE_DEFINITIONS
|
||||||
|
${INTERCEPTION_COMMON_DEFINITIONS})
|
||||||
|
endif()
|
||||||
@@ -13,11 +13,22 @@ set(SANITIZER_SOURCES
|
|||||||
sanitizer_win.cc
|
sanitizer_win.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(SANITIZER_CFLAGS "-fvisibility=hidden")
|
||||||
|
|
||||||
|
set(SANITIZER_COMMON_DEFINITIONS
|
||||||
|
SANITIZER_HAS_EXCEPTIONS=1)
|
||||||
|
|
||||||
if(CAN_TARGET_X86_64)
|
if(CAN_TARGET_X86_64)
|
||||||
add_library(clang_rt.sanitizer-x86_64 STATIC ${SANITIZER_SOURCES})
|
add_library(RTSanitizerCommon.x86_64 OBJECT ${SANITIZER_SOURCES})
|
||||||
set_target_properties(clang_rt.sanitizer-x86_64 PROPERTIES COMPILE_FLAGS "${TARGET_X86_64_CFLAGS}")
|
set_property(TARGET RTSanitizerCommon.x86_64 PROPERTY COMPILE_FLAGS
|
||||||
|
"${SANITIZER_CFLAGS} ${TARGET_X86_64_CFLAGS}")
|
||||||
|
set_property(TARGET RTSanitizerCommon.x86_64 APPEND PROPERTY COMPILE_DEFINITIONS
|
||||||
|
${SANITIZER_COMMON_DEFINITIONS})
|
||||||
endif()
|
endif()
|
||||||
if(CAN_TARGET_I386)
|
if(CAN_TARGET_I386)
|
||||||
add_library(clang_rt.sanitizer-i386 STATIC ${SANITIZER_SOURCES})
|
add_library(RTSanitizerCommon.i386 OBJECT ${SANITIZER_SOURCES})
|
||||||
set_target_properties(clang_rt.sanitizer-i386 PROPERTIES COMPILE_FLAGS "${TARGET_I386_CFLAGS}")
|
set_property(TARGET RTSanitizerCommon.i386 PROPERTY COMPILE_FLAGS
|
||||||
|
"${SANITIZER_CFLAGS} ${TARGET_I386_CFLAGS}")
|
||||||
|
set_property(TARGET RTSanitizerCommon.i386 APPEND PROPERTY COMPILE_DEFINITIONS
|
||||||
|
${SANITIZER_COMMON_DEFINITIONS})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
Reference in New Issue
Block a user