diff options
author | Petr Hosek <phosek@chromium.org> | 2019-04-30 18:13:22 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2019-04-30 18:13:22 +0000 |
commit | 92a5e92e9aa2c8dbd6e7c53d258dbefa9125aa29 (patch) | |
tree | 2bf782750bcb28b932e8ccd9db62a3d9c8eb3b6b /cmake/Modules | |
parent | 6bc95905026e2f898ae65b6e00d093718ed94be7 (diff) | |
download | compiler-rt-92a5e92e9aa2c8dbd6e7c53d258dbefa9125aa29.tar.gz |
Reland "[compiler-rt] Simple crtbegin.o and crtend.o implementation"
Clang relies on existence of certain symbols that are normally
provided by crtbegin.o/crtend.o. However, LLVM does not currently
provide implementation of these files, instead relying on either
libgcc or implementations provided as part of the system.
This change provides an initial implementation of crtbegin.o/crtend.o
that can be used on system that don't provide crtbegin.o/crtend.o as
part of their C library.
Differential Revision: https://reviews.llvm.org/D28791
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359591 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/Modules')
-rw-r--r-- | cmake/Modules/AddCompilerRT.cmake | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake index bed0826ff..8b6518d13 100644 --- a/cmake/Modules/AddCompilerRT.cmake +++ b/cmake/Modules/AddCompilerRT.cmake @@ -132,7 +132,7 @@ endmacro() # Adds static or shared runtime for a list of architectures and operating # systems and puts it in the proper directory in the build and install trees. # add_compiler_rt_runtime(<name> -# {STATIC|SHARED} +# {OBJECT|STATIC|SHARED} # ARCHS <architectures> # OS <os list> # SOURCES <source files> @@ -144,8 +144,8 @@ endmacro() # PARENT_TARGET <convenience parent target> # ADDITIONAL_HEADERS <header files>) function(add_compiler_rt_runtime name type) - if(NOT type MATCHES "^(STATIC|SHARED)$") - message(FATAL_ERROR "type argument must be STATIC or SHARED") + if(NOT type MATCHES "^(OBJECT|STATIC|SHARED)$") + message(FATAL_ERROR "type argument must be OBJECT, STATIC or SHARED") return() endif() cmake_parse_arguments(LIB @@ -204,7 +204,10 @@ function(add_compiler_rt_runtime name type) message(FATAL_ERROR "Architecture ${arch} can't be targeted") return() endif() - if(type STREQUAL "STATIC") + if(type STREQUAL "OBJECT") + set(libname "${name}-${arch}") + set_output_name(output_name_${libname} ${name}${COMPILER_RT_OS_SUFFIX} ${arch}) + elseif(type STREQUAL "STATIC") set(libname "${name}-${arch}") set_output_name(output_name_${libname} ${name} ${arch}) else() @@ -270,12 +273,34 @@ function(add_compiler_rt_runtime name type) set(COMPONENT_OPTION COMPONENT ${libname}) endif() - add_library(${libname} ${type} ${sources_${libname}}) - set_target_compile_flags(${libname} ${extra_cflags_${libname}}) - set_target_link_flags(${libname} ${extra_link_flags_${libname}}) - set_property(TARGET ${libname} APPEND PROPERTY - COMPILE_DEFINITIONS ${LIB_DEFS}) - set_target_output_directories(${libname} ${output_dir_${libname}}) + if(type STREQUAL "OBJECT") + string(TOUPPER ${CMAKE_BUILD_TYPE} config) + get_property(cflags SOURCE ${sources_${libname}} PROPERTY COMPILE_FLAGS) + separate_arguments(cflags) + add_custom_command( + OUTPUT ${output_dir_${libname}}/${output_name_${libname}}.o + COMMAND ${CMAKE_C_COMPILER} ${sources_${libname}} ${cflags} ${extra_cflags_${libname}} -c -o ${output_dir_${libname}}/${output_name_${libname}}.o + DEPENDS ${sources_${libname}} + COMMENT "Building C object ${output_name_${libname}}.o") + add_custom_target(${libname} DEPENDS ${output_dir_${libname}}/${output_name_${libname}}.o) + install(FILES ${output_dir_${libname}}/${output_name_${libname}}.o + DESTINATION ${install_dir_${libname}} + ${COMPONENT_OPTION}) + else() + add_library(${libname} ${type} ${sources_${libname}}) + set_target_compile_flags(${libname} ${extra_cflags_${libname}}) + set_target_link_flags(${libname} ${extra_link_flags_${libname}}) + set_property(TARGET ${libname} APPEND PROPERTY + COMPILE_DEFINITIONS ${LIB_DEFS}) + set_target_output_directories(${libname} ${output_dir_${libname}}) + install(TARGETS ${libname} + ARCHIVE DESTINATION ${install_dir_${libname}} + ${COMPONENT_OPTION} + LIBRARY DESTINATION ${install_dir_${libname}} + ${COMPONENT_OPTION} + RUNTIME DESTINATION ${install_dir_${libname}} + ${COMPONENT_OPTION}) + endif() set_target_properties(${libname} PROPERTIES OUTPUT_NAME ${output_name_${libname}}) set_target_properties(${libname} PROPERTIES FOLDER "Compiler-RT Runtime") @@ -299,13 +324,6 @@ function(add_compiler_rt_runtime name type) ) endif() endif() - install(TARGETS ${libname} - ARCHIVE DESTINATION ${install_dir_${libname}} - ${COMPONENT_OPTION} - LIBRARY DESTINATION ${install_dir_${libname}} - ${COMPONENT_OPTION} - RUNTIME DESTINATION ${install_dir_${libname}} - ${COMPONENT_OPTION}) # We only want to generate per-library install targets if you aren't using # an IDE because the extra targets get cluttered in IDEs. |