blob: bb65f58c9b9f79b08bbc6b6cc790fbb79f2496d9 [file] [log] [blame]
Alexey Samsonov2e8e4412014-05-09 22:11:03 +00001include(ExternalProject)
Alexey Samsonov392c50d2013-01-18 16:05:21 +00002include(CompilerRTUtils)
Alexey Samsonov02dcc632012-12-19 12:33:39 +00003
Chris Bieneman5c2fd242015-06-10 23:55:07 +00004# Tries to add an "object library" target for a given list of OSs and/or
5# architectures with name "<name>.<arch>" for non-Darwin platforms if
6# architecture can be targeted, and "<name>.<os>" for Darwin platforms.
7# add_compiler_rt_object_libraries(<name>
Filipe Cabecinhasc309de72015-06-19 03:39:24 +00008# OS <os names>
9# ARCHS <architectures>
Chris Bieneman5c2fd242015-06-10 23:55:07 +000010# SOURCES <source files>
11# CFLAGS <compile flags>
12# DEFS <compile definitions>)
13function(add_compiler_rt_object_libraries name)
Filipe Cabecinhasc309de72015-06-19 03:39:24 +000014 cmake_parse_arguments(LIB "" "" "OS;ARCHS;SOURCES;CFLAGS;DEFS" ${ARGN})
Chris Bieneman5c2fd242015-06-10 23:55:07 +000015 set(libnames)
16 if(APPLE)
17 foreach(os ${LIB_OS})
18 set(libname "${name}.${os}")
19 set(libnames ${libnames} ${libname})
20 set(extra_cflags_${libname} ${DARWIN_${os}_CFLAGS})
Daniel Sandersbfcbe762016-01-27 09:28:01 +000021 list_intersect(LIB_ARCHS_${libname} DARWIN_${os}_ARCHS LIB_ARCHS)
Chris Bieneman5c2fd242015-06-10 23:55:07 +000022 endforeach()
Alexey Samsonov392c50d2013-01-18 16:05:21 +000023 else()
Filipe Cabecinhasc309de72015-06-19 03:39:24 +000024 foreach(arch ${LIB_ARCHS})
Chris Bieneman5c2fd242015-06-10 23:55:07 +000025 set(libname "${name}.${arch}")
26 set(libnames ${libnames} ${libname})
27 set(extra_cflags_${libname} ${TARGET_${arch}_CFLAGS})
28 if(NOT CAN_TARGET_${arch})
Filipe Cabecinhas030b5902015-08-10 18:26:29 +000029 message(FATAL_ERROR "Architecture ${arch} can't be targeted")
Chris Bieneman5c2fd242015-06-10 23:55:07 +000030 return()
31 endif()
32 endforeach()
Alexey Samsonov392c50d2013-01-18 16:05:21 +000033 endif()
Chris Bieneman5c2fd242015-06-10 23:55:07 +000034
35 foreach(libname ${libnames})
36 add_library(${libname} OBJECT ${LIB_SOURCES})
37 set_target_compile_flags(${libname}
38 ${CMAKE_CXX_FLAGS} ${extra_cflags_${libname}} ${LIB_CFLAGS})
39 set_property(TARGET ${libname} APPEND PROPERTY
40 COMPILE_DEFINITIONS ${LIB_DEFS})
41 if(APPLE)
Chris Bieneman19c84512015-08-13 20:38:16 +000042 set_target_properties(${libname} PROPERTIES
43 OSX_ARCHITECTURES "${LIB_ARCHS_${libname}}")
Chris Bieneman5c2fd242015-06-10 23:55:07 +000044 endif()
45 endforeach()
46endfunction()
Alexey Samsonov51623142013-01-20 14:36:12 +000047
Chris Bieneman97c46102015-08-26 18:33:51 +000048# Takes a list of object library targets, and a suffix and appends the proper
49# TARGET_OBJECTS string to the output variable.
50# format_object_libs(<output> <suffix> ...)
51macro(format_object_libs output suffix)
52 foreach(lib ${ARGN})
53 list(APPEND ${output} $<TARGET_OBJECTS:${lib}.${suffix}>)
54 endforeach()
55endmacro()
56
Chris Bieneman0576c362015-08-25 19:53:09 +000057# Adds static or shared runtime for a list of architectures and operating
58# systems and puts it in the proper directory in the build and install trees.
59# add_compiler_rt_runtime(<name>
60# {STATIC|SHARED}
61# ARCHS <architectures>
62# OS <os list>
Alexey Samsonove18b7852014-03-31 13:45:36 +000063# SOURCES <source files>
64# CFLAGS <compile flags>
Chris Bieneman0576c362015-08-25 19:53:09 +000065# LINKFLAGS <linker flags>
Evgeniy Stepanov44014732014-09-29 13:18:55 +000066# DEFS <compile definitions>
Chris Bieneman0576c362015-08-25 19:53:09 +000067# LINK_LIBS <linked libraries> (only for shared library)
Chris Bieneman97c46102015-08-26 18:33:51 +000068# OBJECT_LIBS <object libraries to use as sources>
Chris Bieneman0576c362015-08-25 19:53:09 +000069# PARENT_TARGET <convenience parent target>)
70function(add_compiler_rt_runtime name type)
71 if(NOT type MATCHES "^(STATIC|SHARED)$")
72 message(FATAL_ERROR "type argument must be STATIC or SHARED")
73 return()
Alexey Samsonove16af952013-01-20 13:58:10 +000074 endif()
Chris Bieneman0576c362015-08-25 19:53:09 +000075 cmake_parse_arguments(LIB
76 ""
77 "PARENT_TARGET"
Chris Bieneman97c46102015-08-26 18:33:51 +000078 "OS;ARCHS;SOURCES;CFLAGS;LINKFLAGS;DEFS;LINK_LIBS;OBJECT_LIBS"
Chris Bieneman0576c362015-08-25 19:53:09 +000079 ${ARGN})
80 set(libnames)
81 if(APPLE)
82 foreach(os ${LIB_OS})
83 if(type STREQUAL "STATIC")
84 set(libname "${name}_${os}")
85 else()
86 set(libname "${name}_${os}_dynamic")
87 set(extra_linkflags_${libname} ${DARWIN_${os}_LINKFLAGS} ${LIB_LINKFLAGS})
88 endif()
Daniel Sandersbfcbe762016-01-27 09:28:01 +000089 list_intersect(LIB_ARCHS_${libname} DARWIN_${os}_ARCHS LIB_ARCHS)
Chris Bieneman0576c362015-08-25 19:53:09 +000090 if(LIB_ARCHS_${libname})
91 list(APPEND libnames ${libname})
92 set(extra_cflags_${libname} ${DARWIN_${os}_CFLAGS} ${LIB_CFLAGS})
93 set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX})
Chris Bieneman97c46102015-08-26 18:33:51 +000094 set(sources_${libname} ${LIB_SOURCES})
95 format_object_libs(sources_${libname} ${os} ${LIB_OBJECT_LIBS})
Chris Bieneman0576c362015-08-25 19:53:09 +000096 endif()
97 endforeach()
98 else()
99 foreach(arch ${LIB_ARCHS})
100 if(NOT CAN_TARGET_${arch})
101 message(FATAL_ERROR "Architecture ${arch} can't be targeted")
102 return()
103 endif()
104 if(type STREQUAL "STATIC")
105 set(libname "${name}-${arch}")
106 set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX})
107 else()
108 set(libname "${name}-dynamic-${arch}")
109 set(extra_linkflags_${libname} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS} ${LIB_LINKFLAGS})
110 if(WIN32)
111 set(output_name_${libname} ${name}_dynamic-${arch}${COMPILER_RT_OS_SUFFIX})
112 else()
113 set(output_name_${libname} ${name}-${arch}${COMPILER_RT_OS_SUFFIX})
114 endif()
115 endif()
Chris Bieneman97c46102015-08-26 18:33:51 +0000116 set(sources_${libname} ${LIB_SOURCES})
117 format_object_libs(sources_${libname} ${arch} ${LIB_OBJECT_LIBS})
Chris Bieneman0576c362015-08-25 19:53:09 +0000118 set(libnames ${libnames} ${libname})
119 set(extra_cflags_${libname} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
120 endforeach()
121 endif()
Alexey Samsonove16af952013-01-20 13:58:10 +0000122
Chris Bieneman0576c362015-08-25 19:53:09 +0000123 if(NOT libnames)
124 return()
125 endif()
126
127 if(LIB_PARENT_TARGET)
128 set(COMPONENT_OPTION COMPONENT ${LIB_PARENT_TARGET})
129 endif()
130
131 foreach(libname ${libnames})
Chris Bieneman97c46102015-08-26 18:33:51 +0000132 add_library(${libname} ${type} ${sources_${libname}})
Chris Bieneman0576c362015-08-25 19:53:09 +0000133 set_target_compile_flags(${libname} ${extra_cflags_${libname}})
134 set_target_link_flags(${libname} ${extra_linkflags_${libname}})
135 set_property(TARGET ${libname} APPEND PROPERTY
136 COMPILE_DEFINITIONS ${LIB_DEFS})
137 set_target_properties(${libname} PROPERTIES
138 ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
139 LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
140 RUNTIME_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
141 set_target_properties(${libname} PROPERTIES
142 OUTPUT_NAME ${output_name_${libname}})
143 if(LIB_LINK_LIBS AND ${type} STREQUAL "SHARED")
144 target_link_libraries(${libname} ${LIB_LINK_LIBS})
Chris Bieneman607a4f72015-08-18 17:32:18 +0000145 endif()
Chris Bieneman0576c362015-08-25 19:53:09 +0000146 install(TARGETS ${libname}
147 ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
148 ${COMPONENT_OPTION}
149 LIBRARY DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
150 ${COMPONENT_OPTION}
151 RUNTIME DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR}
152 ${COMPONENT_OPTION})
153 if(APPLE)
154 set_target_properties(${libname} PROPERTIES
155 OSX_ARCHITECTURES "${LIB_ARCHS_${libname}}")
156 endif()
Chris Bieneman1d908be2015-12-03 20:08:22 +0000157
158 if(type STREQUAL "SHARED")
159 rt_externalize_debuginfo(${libname})
160 endif()
Chris Bieneman0576c362015-08-25 19:53:09 +0000161 endforeach()
162 if(LIB_PARENT_TARGET)
163 add_dependencies(${LIB_PARENT_TARGET} ${libnames})
Chris Bieneman607a4f72015-08-18 17:32:18 +0000164 endif()
165endfunction()
Alexey Samsonov2aad7c12013-01-21 08:12:20 +0000166
Sumanth Gundapanenid52305f2016-01-14 18:18:49 +0000167# when cross compiling, COMPILER_RT_TEST_COMPILER_CFLAGS help
168# in compilation and linking of unittests.
169string(REPLACE " " ";" COMPILER_RT_UNITTEST_CFLAGS "${COMPILER_RT_TEST_COMPILER_CFLAGS}")
170set(COMPILER_RT_UNITTEST_LINKFLAGS ${COMPILER_RT_UNITTEST_CFLAGS})
Timur Iskhodzhanova73e9db2014-05-30 12:42:57 +0000171
Alexey Samsonov392c50d2013-01-18 16:05:21 +0000172# Unittests support.
Alexey Samsonov02dcc632012-12-19 12:33:39 +0000173set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest)
Chandler Carruthace53502013-11-15 10:21:15 +0000174set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/src/gtest-all.cc)
Alexey Samsonov1e5d8be2014-03-24 13:29:20 +0000175set(COMPILER_RT_GTEST_CFLAGS
Alexey Samsonov02dcc632012-12-19 12:33:39 +0000176 -DGTEST_NO_LLVM_RAW_OSTREAM=1
Timur Iskhodzhanov402bcb52014-05-28 08:38:13 +0000177 -DGTEST_HAS_RTTI=0
Alexey Samsonov02dcc632012-12-19 12:33:39 +0000178 -I${COMPILER_RT_GTEST_PATH}/include
Chandler Carruthace53502013-11-15 10:21:15 +0000179 -I${COMPILER_RT_GTEST_PATH}
Alexey Samsonov02dcc632012-12-19 12:33:39 +0000180)
181
Sumanth Gundapanenid52305f2016-01-14 18:18:49 +0000182append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 COMPILER_RT_UNITTEST_CFLAGS)
Alexey Samsonov001d0382015-01-06 20:58:40 +0000183
Timur Iskhodzhanov402bcb52014-05-28 08:38:13 +0000184if(MSVC)
Timur Iskhodzhanova73e9db2014-05-30 12:42:57 +0000185 # clang doesn't support exceptions on Windows yet.
Sumanth Gundapanenid52305f2016-01-14 18:18:49 +0000186 list(APPEND COMPILER_RT_UNITTEST_CFLAGS -D_HAS_EXCEPTIONS=0)
Timur Iskhodzhanova73e9db2014-05-30 12:42:57 +0000187
188 # We should teach clang to understand "#pragma intrinsic", see PR19898.
Sumanth Gundapanenid52305f2016-01-14 18:18:49 +0000189 list(APPEND COMPILER_RT_UNITTEST_CFLAGS -Wno-undefined-inline)
Timur Iskhodzhanova73e9db2014-05-30 12:42:57 +0000190
Timur Iskhodzhanov402bcb52014-05-28 08:38:13 +0000191 # Clang doesn't support SEH on Windows yet.
192 list(APPEND COMPILER_RT_GTEST_CFLAGS -DGTEST_HAS_SEH=0)
Timur Iskhodzhanova73e9db2014-05-30 12:42:57 +0000193
194 # gtest use a lot of stuff marked as deprecated on Windows.
195 list(APPEND COMPILER_RT_GTEST_CFLAGS -Wno-deprecated-declarations)
Ehsan Akhgari1c4db802014-09-15 11:33:50 +0000196
197 # Visual Studio 2012 only supports up to 8 template parameters in
198 # std::tr1::tuple by default, but gtest requires 10
199 if(MSVC_VERSION EQUAL 1700)
Ehsan Akhgari494410f2014-09-25 20:42:49 +0000200 list(APPEND COMPILER_RT_GTEST_CFLAGS -D_VARIADIC_MAX=10)
Ehsan Akhgari1c4db802014-09-15 11:33:50 +0000201 endif()
Timur Iskhodzhanov402bcb52014-05-28 08:38:13 +0000202endif()
203
Alexey Samsonov17cf7c52014-02-19 13:01:03 +0000204# Link objects into a single executable with COMPILER_RT_TEST_COMPILER,
205# using specified link flags. Make executable a part of provided
Alexey Samsonov02dcc632012-12-19 12:33:39 +0000206# test_suite.
207# add_compiler_rt_test(<test_suite> <test_name>
Alexey Samsonov431f94d2014-12-17 23:14:01 +0000208# SUBDIR <subdirectory for binary>
Alexey Samsonov02dcc632012-12-19 12:33:39 +0000209# OBJECTS <object files>
210# DEPS <deps (e.g. runtime libs)>
211# LINK_FLAGS <link flags>)
212macro(add_compiler_rt_test test_suite test_name)
Filipe Cabecinhasc309de72015-06-19 03:39:24 +0000213 cmake_parse_arguments(TEST "" "SUBDIR" "OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN})
Alexey Samsonov431f94d2014-12-17 23:14:01 +0000214 if(TEST_SUBDIR)
215 set(output_bin "${CMAKE_CURRENT_BINARY_DIR}/${TEST_SUBDIR}/${test_name}")
216 else()
217 set(output_bin "${CMAKE_CURRENT_BINARY_DIR}/${test_name}")
218 endif()
Timur Iskhodzhanov00b915c2015-01-22 14:54:22 +0000219 if(MSVC)
220 set(output_bin "${output_bin}.exe")
221 endif()
Alexey Samsonov17cf7c52014-02-19 13:01:03 +0000222 # Use host compiler in a standalone build, and just-built Clang otherwise.
223 if(NOT COMPILER_RT_STANDALONE_BUILD)
224 list(APPEND TEST_DEPS clang)
225 endif()
Chandler Carruth272eef92014-05-15 16:33:58 +0000226 # If we're not on MSVC, include the linker flags from CMAKE but override them
227 # with the provided link flags. This ensures that flags which are required to
228 # link programs at all are included, but the changes needed for the test
229 # trump. With MSVC we can't do that because CMake is set up to run link.exe
230 # when linking, not the compiler. Here, we hack it to use the compiler
231 # because we want to use -fsanitize flags.
232 if(NOT MSVC)
233 set(TEST_LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TEST_LINK_FLAGS}")
234 separate_arguments(TEST_LINK_FLAGS)
235 endif()
Alexey Samsonova74424e2013-01-28 09:07:30 +0000236 add_custom_target(${test_name}
Timur Iskhodzhanov7c707342014-05-12 08:55:20 +0000237 COMMAND ${COMPILER_RT_TEST_COMPILER} ${TEST_OBJECTS}
Timur Iskhodzhanov402bcb52014-05-28 08:38:13 +0000238 -o "${output_bin}"
Alexey Samsonov02dcc632012-12-19 12:33:39 +0000239 ${TEST_LINK_FLAGS}
Alexey Samsonov17cf7c52014-02-19 13:01:03 +0000240 DEPENDS ${TEST_DEPS})
Alexey Samsonov02dcc632012-12-19 12:33:39 +0000241 # Make the test suite depend on the binary.
242 add_dependencies(${test_suite} ${test_name})
243endmacro()
Alexey Samsonovc1caace2013-05-21 13:48:27 +0000244
Chris Bieneman772a58d2016-02-23 21:50:39 +0000245macro(add_compiler_rt_resource_file target_name file_name component)
Alexey Samsonovc1caace2013-05-21 13:48:27 +0000246 set(src_file "${CMAKE_CURRENT_SOURCE_DIR}/${file_name}")
Alexey Samsonova52e2dc2014-02-18 14:28:53 +0000247 set(dst_file "${COMPILER_RT_OUTPUT_DIR}/${file_name}")
Alexey Samsonov41bf0bc2014-02-27 07:22:59 +0000248 add_custom_command(OUTPUT ${dst_file}
249 DEPENDS ${src_file}
Alexey Samsonovc1caace2013-05-21 13:48:27 +0000250 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src_file} ${dst_file}
Alexey Samsonov41bf0bc2014-02-27 07:22:59 +0000251 COMMENT "Copying ${file_name}...")
252 add_custom_target(${target_name} DEPENDS ${dst_file})
Alexey Samsonovc1caace2013-05-21 13:48:27 +0000253 # Install in Clang resource directory.
Chris Bieneman772a58d2016-02-23 21:50:39 +0000254 install(FILES ${file_name}
255 DESTINATION ${COMPILER_RT_INSTALL_PATH}
256 COMPONENT ${component})
257 add_dependencies(${component} ${target_name})
Alexey Samsonovc1caace2013-05-21 13:48:27 +0000258endmacro()
Evgeniy Stepanov9514ed12014-02-27 08:41:40 +0000259
260macro(add_compiler_rt_script name)
261 set(dst ${COMPILER_RT_EXEC_OUTPUT_DIR}/${name})
262 set(src ${CMAKE_CURRENT_SOURCE_DIR}/${name})
263 add_custom_command(OUTPUT ${dst}
264 DEPENDS ${src}
265 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
266 COMMENT "Copying ${name}...")
267 add_custom_target(${name} DEPENDS ${dst})
268 install(FILES ${dst}
269 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
270 DESTINATION ${COMPILER_RT_INSTALL_PATH}/bin)
271endmacro(add_compiler_rt_script src name)
Alexey Samsonov2e8e4412014-05-09 22:11:03 +0000272
273# Builds custom version of libc++ and installs it in <prefix>.
274# Can be used to build sanitized versions of libc++ for running unit tests.
275# add_custom_libcxx(<name> <prefix>
276# DEPS <list of build deps>
277# CFLAGS <list of compile flags>)
278macro(add_custom_libcxx name prefix)
279 if(NOT COMPILER_RT_HAS_LIBCXX_SOURCES)
280 message(FATAL_ERROR "libcxx not found!")
281 endif()
282
Filipe Cabecinhasc309de72015-06-19 03:39:24 +0000283 cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS" ${ARGN})
Alexey Samsonov2e8e4412014-05-09 22:11:03 +0000284 foreach(flag ${LIBCXX_CFLAGS})
285 set(flagstr "${flagstr} ${flag}")
286 endforeach()
287 set(LIBCXX_CFLAGS ${flagstr})
288
289 if(NOT COMPILER_RT_STANDALONE_BUILD)
290 list(APPEND LIBCXX_DEPS clang)
291 endif()
292
293 ExternalProject_Add(${name}
294 PREFIX ${prefix}
295 SOURCE_DIR ${COMPILER_RT_LIBCXX_PATH}
Andy Gibbs61adea82015-12-02 13:46:56 +0000296 CMAKE_ARGS -DCMAKE_MAKE_PROGRAM:STRING=${CMAKE_MAKE_PROGRAM}
297 -DCMAKE_C_COMPILER=${COMPILER_RT_TEST_COMPILER}
Daniel Sandersa268a2f2016-02-02 12:55:28 +0000298 -DCMAKE_CXX_COMPILER=${COMPILER_RT_TEST_CXX_COMPILER}
Alexey Samsonov2e8e4412014-05-09 22:11:03 +0000299 -DCMAKE_C_FLAGS=${LIBCXX_CFLAGS}
300 -DCMAKE_CXX_FLAGS=${LIBCXX_CFLAGS}
301 -DCMAKE_BUILD_TYPE=Release
302 -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
Daniel Sandersa268a2f2016-02-02 12:55:28 +0000303 -DLLVM_PATH=${LLVM_MAIN_SRC_DIR}
Alexey Samsonov19de1ba2014-05-12 21:07:28 +0000304 LOG_BUILD 1
305 LOG_CONFIGURE 1
306 LOG_INSTALL 1
Alexey Samsonov2e8e4412014-05-09 22:11:03 +0000307 )
Alexey Samsonovdd6f8442015-07-16 21:20:05 +0000308 set_target_properties(${name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
Alexey Samsonov2e8e4412014-05-09 22:11:03 +0000309
310 ExternalProject_Add_Step(${name} force-reconfigure
311 DEPENDERS configure
312 ALWAYS 1
313 )
314
315 ExternalProject_Add_Step(${name} clobber
316 COMMAND ${CMAKE_COMMAND} -E remove_directory <BINARY_DIR>
317 COMMAND ${CMAKE_COMMAND} -E make_directory <BINARY_DIR>
318 COMMENT "Clobberring ${name} build directory..."
319 DEPENDERS configure
320 DEPENDS ${LIBCXX_DEPS}
321 )
322endmacro()
Chris Bieneman1d908be2015-12-03 20:08:22 +0000323
324function(rt_externalize_debuginfo name)
325 if(NOT COMPILER_RT_EXTERNALIZE_DEBUGINFO)
326 return()
327 endif()
328
329 if(APPLE)
330 if(CMAKE_CXX_FLAGS MATCHES "-flto"
331 OR CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE} MATCHES "-flto")
332
333 set(lto_object ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${name}-lto.o)
Chris Bieneman5d5bc5b2015-12-03 22:52:22 +0000334 set_property(TARGET ${name} APPEND_STRING PROPERTY
Chris Bieneman960c4902015-12-03 22:56:21 +0000335 LINK_FLAGS " -Wl,-object_path_lto -Wl,${lto_object}")
Chris Bieneman1d908be2015-12-03 20:08:22 +0000336 endif()
337 add_custom_command(TARGET ${name} POST_BUILD
338 COMMAND xcrun dsymutil $<TARGET_FILE:${name}>
339 COMMAND xcrun strip -Sl $<TARGET_FILE:${name}>)
340 else()
341 message(FATAL_ERROR "COMPILER_RT_EXTERNALIZE_DEBUGINFO isn't implemented for non-darwin platforms!")
342 endif()
343endfunction()