summaryrefslogtreecommitdiff
path: root/cmake/Modules
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2015-12-03 20:08:22 +0000
committerChris Bieneman <beanz@apple.com>2015-12-03 20:08:22 +0000
commit1d908be023afec71d0c770c1397304738d07b257 (patch)
tree6b4e460d3806ce565d7e0bb147356194d3c5fe21 /cmake/Modules
parente9daa5252d3608e686b3a92770fb9fa52526ff96 (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.cmake25
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()