diff options
author | Chris Bieneman <beanz@apple.com> | 2015-12-03 20:08:22 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2015-12-03 20:08:22 +0000 |
commit | 1d908be023afec71d0c770c1397304738d07b257 (patch) | |
tree | 6b4e460d3806ce565d7e0bb147356194d3c5fe21 /cmake/Modules | |
parent | e9daa5252d3608e686b3a92770fb9fa52526ff96 (diff) |
[CMake] Support externalizing debug info on Darwin
* Adds COMPILER_RT_EXTERNALIZE_DEBUGINFO option
* On Darwin this results in calling dsymutil and strip after linking
* This generates an error on non-darwin platforms, matching the LLVM behavior
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@254643 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/Modules')
-rw-r--r-- | cmake/Modules/AddCompilerRT.cmake | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake index cee0af935..5db7eb048 100644 --- a/cmake/Modules/AddCompilerRT.cmake +++ b/cmake/Modules/AddCompilerRT.cmake @@ -155,6 +155,10 @@ function(add_compiler_rt_runtime name type) set_target_properties(${libname} PROPERTIES OSX_ARCHITECTURES "${LIB_ARCHS_${libname}}") endif() + + if(type STREQUAL "SHARED") + rt_externalize_debuginfo(${libname}) + endif() endforeach() if(LIB_PARENT_TARGET) add_dependencies(${LIB_PARENT_TARGET} ${libnames}) @@ -310,3 +314,24 @@ macro(add_custom_libcxx name prefix) DEPENDS ${LIBCXX_DEPS} ) endmacro() + +function(rt_externalize_debuginfo name) + if(NOT COMPILER_RT_EXTERNALIZE_DEBUGINFO) + return() + endif() + + if(APPLE) + if(CMAKE_CXX_FLAGS MATCHES "-flto" + OR CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE} MATCHES "-flto") + + set(lto_object ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${name}-lto.o) + set_target_properties(${name} PROPERTIES + LINK_FLAGS "-Wl,-object_path_lto -Wl,${lto_object}") + endif() + add_custom_command(TARGET ${name} POST_BUILD + COMMAND xcrun dsymutil $<TARGET_FILE:${name}> + COMMAND xcrun strip -Sl $<TARGET_FILE:${name}>) + else() + message(FATAL_ERROR "COMPILER_RT_EXTERNALIZE_DEBUGINFO isn't implemented for non-darwin platforms!") + endif() +endfunction() |