PATTERN ".svn" EXCLUDE
)
-# Call add_clang_compiler_rt_libraries to make sure that targets are built
-# and installed in the directories where Clang driver expects to find them.
-macro(add_clang_compiler_rt_libraries)
- # Setup output directories so that clang in build tree works.
- set_target_properties(${ARGN} PROPERTIES
- ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
- LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
- # Add installation command.
- install(TARGETS ${ARGN}
- ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
- LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
-endmacro(add_clang_compiler_rt_libraries)
-
# Add the public header's directory to the includes for all of compiler-rt.
include_directories(include)
set(libname "${name}.osx")
add_library(${libname} OBJECT ${LIB_SOURCES})
set_target_compile_flags(${libname} ${LIB_CFLAGS})
- set_target_properties(${libname} PROPERTIES
- OSX_ARCHITECTURES "${LIB_ARCH}")
+ set_target_properties(${libname} PROPERTIES OSX_ARCHITECTURES "${LIB_ARCH}")
endmacro()
# Adds static runtime for a given architecture and puts it in the proper
COMPILE_DEFINITIONS ${LIB_DEFS})
# Setup correct output directory in the build tree.
set_target_properties(${name} PROPERTIES
- ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
+ ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
# Add installation command.
install(TARGETS ${name}
ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
endif()
endmacro()
+# Same as add_compiler_rt_static_runtime, but creates a universal library
+# for several architectures.
+# add_compiler_rt_osx_static_runtime(<name> ARCH <architectures>
+# SOURCES <source files>
+# CFLAGS <compile flags>
+# DEFS <compile definitions>)
+macro(add_compiler_rt_osx_static_runtime name)
+ parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS" "" ${ARGN})
+ add_library(${name} STATIC ${LIB_SOURCES})
+ set_target_compile_flags(${name} ${LIB_CFLAGS})
+ set_property(TARGET ${name} APPEND PROPERTY
+ COMPILE_DEFINITIONS ${LIB_DEFS})
+ set_target_properties(${name} PROPERTIES
+ OSX_ARCHITECTURES "${LIB_ARCH}"
+ ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
+ install(TARGETS ${name}
+ ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+endmacro()
+
+# Adds dynamic runtime library on osx, which supports multiple architectures.
+# add_compiler_rt_osx_dynamic_runtime(<name> ARCH <architectures>
+# SOURCES <source files>
+# CFLAGS <compile flags>
+# DEFS <compile definitions>
+# LINKFLAGS <link flags>)
+macro(add_compiler_rt_osx_dynamic_runtime name)
+ parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS;LINKFLAGS" "" ${ARGN})
+ add_library(${name} SHARED ${LIB_SOURCES})
+ set_target_compile_flags(${name} ${LIB_CFLAGS})
+ set_target_link_flags(${name} ${LIB_LINKFLAGS})
+ set_property(TARGET ${name} APPEND PROPERTY
+ COMPILE_DEFINITIONS ${LIB_DEFS})
+ set_target_properties(${name} PROPERTIES
+ OSX_ARCHITECTURES "${LIB_ARCH}"
+ LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
+ install(TARGETS ${name}
+ LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+endmacro()
+
# Unittests support.
set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest)
set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/gtest-all.cc)
set(ASAN_RUNTIME_LIBRARIES)
if(APPLE)
# Build universal binary on APPLE.
- add_library(clang_rt.asan_osx STATIC
- ${ASAN_SOURCES}
- $<TARGET_OBJECTS:RTInterception.osx>
- $<TARGET_OBJECTS:RTSanitizerCommon.osx>
- )
- set_target_compile_flags(clang_rt.asan_osx ${ASAN_CFLAGS})
- set_target_properties(clang_rt.asan_osx PROPERTIES
- OSX_ARCHITECTURES "${ASAN_SUPPORTED_ARCH}")
+ add_compiler_rt_osx_static_runtime(clang_rt.asan_osx
+ ARCH ${ASAN_SUPPORTED_ARCH}
+ SOURCES ${ASAN_SOURCES}
+ $<TARGET_OBJECTS:RTInterception.osx>
+ $<TARGET_OBJECTS:RTSanitizerCommon.osx>
+ CFLAGS ${ASAN_CFLAGS}
+ DEFS ${ASAN_COMMON_DEFINITIONS})
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan_osx)
elseif(ANDROID)
add_library(clang_rt.asan-arm-android SHARED
$<TARGET_OBJECTS:RTSanitizerCommon.arm.android>
)
set_target_compile_flags(clang_rt.asan-arm-android
- ${ASAN_CFLAGS}
- )
+ ${ASAN_CFLAGS})
+ set_property(TARGET clang_rt.asan-arm-android APPEND PROPERTY
+ COMPILE_DEFINITIONS ${ASAN_COMMON_DEFINITIONS})
target_link_libraries(clang_rt.asan-arm-android dl)
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-arm-android)
else()
# Otherwise, build separate libraries for each target.
foreach(arch ${ASAN_SUPPORTED_ARCH})
- add_library(clang_rt.asan-${arch} STATIC
- ${ASAN_SOURCES}
- $<TARGET_OBJECTS:RTInterception.${arch}>
- $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>)
- set_target_compile_flags(clang_rt.asan-${arch}
- ${ASAN_CFLAGS} ${TARGET_${arch}_CFLAGS})
+ add_compiler_rt_static_runtime(clang_rt.asan-${arch} ${arch}
+ SOURCES ${ASAN_SOURCES}
+ $<TARGET_OBJECTS:RTInterception.${arch}>
+ $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
+ CFLAGS ${ASAN_CFLAGS}
+ DEFS ${ASAN_COMMON_DEFINITIONS})
list(APPEND ASAN_RUNTIME_LIBRARIES clang_rt.asan-${arch})
endforeach()
endif()
-set_property(TARGET ${ASAN_RUNTIME_LIBRARIES} APPEND PROPERTY
- COMPILE_DEFINITIONS ${ASAN_COMMON_DEFINITIONS})
-add_clang_compiler_rt_libraries(${ASAN_RUNTIME_LIBRARIES})
-
set(ASAN_DYNAMIC_RUNTIME_LIBRARIES)
if(APPLE)
# Build universal binary on APPLE.
- add_library(clang_rt.asan_osx_dynamic SHARED
- ${ASAN_DYLIB_SOURCES}
- $<TARGET_OBJECTS:RTInterception.osx>
- $<TARGET_OBJECTS:RTSanitizerCommon.osx>
- )
- set_target_compile_flags(clang_rt.asan_osx_dynamic ${ASAN_CFLAGS})
- set_target_properties(clang_rt.asan_osx_dynamic PROPERTIES
- COMPILE_DEFINITIONS "${ASAN_DYLIB_DEFINITIONS}"
- OSX_ARCHITECTURES "${ASAN_SUPPORTED_ARCH}"
- LINK_FLAGS "-framework Foundation")
+ add_compiler_rt_osx_dynamic_runtime(clang_rt.asan_osx_dynamic
+ ARCH ${ASAN_SUPPORTED_ARCH}
+ SOURCES ${ASAN_DYLIB_SOURCES}
+ $<TARGET_OBJECTS:RTInterception.osx>
+ $<TARGET_OBJECTS:RTSanitizerCommon.osx>
+ CFLAGS ${ASAN_CFLAGS}
+ DEFS ${ASAN_DYLIB_DEFINITIONS}
+ LINKFLAGS "-framework Foundation")
list(APPEND ASAN_DYNAMIC_RUNTIME_LIBRARIES clang_rt.asan_osx_dynamic)
endif()
-add_clang_compiler_rt_libraries(${ASAN_DYNAMIC_RUNTIME_LIBRARIES})
-
if(LLVM_INCLUDE_TESTS)
add_subdirectory(tests)
if(APPLE)
# Build universal binary on APPLE.
- add_library(clang_rt.ubsan_osx STATIC
- ${UBSAN_SOURCES}
- $<TARGET_OBJECTS:RTSanitizerCommon.osx>
- )
- set_target_compile_flags(clang_rt.ubsan_osx ${UBSAN_CFLAGS})
- set_target_properties(clang_rt.ubsan_osx PROPERTIES
- OSX_ARCHITECTURES "${UBSAN_SUPPORTED_ARCH}")
+ add_compiler_rt_osx_static_runtime(clang_rt.ubsan_osx
+ ARCH ${UBSAN_SUPPORTED_ARCH}
+ SOURCES ${UBSAN_SOURCES}
+ $<TARGET_OBJECTS:RTSanitizerCommon.osx>
+ CFLAGS ${UBSAN_CFLAGS})
list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan_osx)
else()
# Build separate libraries for each target.
foreach(arch ${UBSAN_SUPPORTED_ARCH})
- add_library(clang_rt.ubsan-${arch} STATIC
- ${UBSAN_SOURCES}
- $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
- )
- set_target_compile_flags(clang_rt.ubsan-${arch}
- ${UBSAN_CFLAGS} ${TARGET_${arch}_CFLAGS}
- )
+ add_compiler_rt_static_runtime(clang_rt.ubsan-${arch} ${arch}
+ SOURCES ${UBSAN_SOURCES}
+ $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
+ CFLAGS ${UBSAN_CFLAGS})
list(APPEND UBSAN_RUNTIME_LIBRARIES clang_rt.ubsan-${arch})
endforeach()
endif()
-
-set_property(TARGET ${UBSAN_RUNTIME_LIBRARIES} APPEND PROPERTY
- COMPILE_DEFINITIONS ${UBSAN_COMMON_DEFINITIONS})
-add_clang_compiler_rt_libraries(${UBSAN_RUNTIME_LIBRARIES})
-
add_subdirectory(lit_tests)