[PATCH] D61356: [compiler-rt] Rework the object build support
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 30 17:33:26 PDT 2019
phosek created this revision.
phosek added reviewers: smeenai, beanz.
Herald added subscribers: llvm-commits, Sanitizers, mgorny, dberris.
Herald added projects: LLVM, Sanitizers.
The initial implementation didn't properly support cross-compilation
via the runtime build, the updated implementation should address that
by expanding the CMAKE_C_COMPILE_OBJECT variable with correct values.
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D61356
Files:
compiler-rt/cmake/Modules/AddCompilerRT.cmake
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===================================================================
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -274,12 +274,37 @@
endif()
if(type STREQUAL "OBJECT")
- string(TOUPPER ${CMAKE_BUILD_TYPE} config)
- get_property(cflags SOURCE ${sources_${libname}} PROPERTY COMPILE_FLAGS)
- separate_arguments(cflags)
+ # TODO: CMake 3.4 doesn't allow installing library objects so we have to build them manually.
+ # When LLVM migrates to LLVM 3.9, we can use add_library just like for other library types.
+ if(CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_TARGET)
+ list(APPEND extra_cflags_${libname} "-target ${CMAKE_C_COMPILER_TARGET}")
+ endif()
+ string(REPLACE ";" " " extra_cflags_${libname} "${extra_cflags_${libname}}")
+ string(REGEX MATCHALL "<[A-Za-z0-9_]*>" substitutions
+ ${CMAKE_C_COMPILE_OBJECT})
+ set(compile_command_${libname} "${CMAKE_C_COMPILE_OBJECT}")
+ foreach(substitution ${substitutions})
+ if(substitution STREQUAL "<CMAKE_C_COMPILER>")
+ string(REPLACE "<CMAKE_C_COMPILER>" "${CMAKE_C_COMPILER}"
+ compile_command_${libname} ${compile_command_${libname}})
+ elseif(substitution STREQUAL "<OBJECT>")
+ string(REPLACE "<OBJECT>" "${output_dir_${libname}}/${output_name_${libname}}.o"
+ compile_command_${libname} ${compile_command_${libname}})
+ elseif(substitution STREQUAL "<SOURCE>")
+ string(REPLACE "<SOURCE>" "${sources_${libname}}"
+ compile_command_${libname} ${compile_command_${libname}})
+ elseif(substitution STREQUAL "<FLAGS>")
+ string(REPLACE "<FLAGS>" "${CMAKE_C_FLAGS} ${extra_cflags_${libname}}"
+ compile_command_${libname} ${compile_command_${libname}})
+ else()
+ string(REPLACE "${substitution}" "" compile_command_${libname}
+ ${compile_command_${libname}})
+ endif()
+ endforeach()
+ string(REPLACE " " ";" compile_command_${libname} "${compile_command_${libname}}")
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
+ COMMAND ${compile_command_${libname}}
DEPENDS ${sources_${libname}}
COMMENT "Building C object ${output_name_${libname}}.o")
add_custom_target(${libname} DEPENDS ${output_dir_${libname}}/${output_name_${libname}}.o)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61356.197489.patch
Type: text/x-patch
Size: 2714 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190501/d986e5bd/attachment.bin>
More information about the llvm-commits
mailing list