diff options
| -rw-r--r-- | compiler-rt/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | compiler-rt/cmake/Modules/AddCompilerRT.cmake | 25 | 
2 files changed, 27 insertions, 0 deletions
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index 9b6b2ea43d6..5f8b4d1bd26 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -189,6 +189,8 @@ else()  endif()  option(COMPILER_RT_DEBUG "Build runtimes with full debug info" OFF) +option(COMPILER_RT_EXTERNALIZE_DEBUGINFO +  "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)  # COMPILER_RT_DEBUG_PYBOOL is used by lit.common.configured.in.  pythonize_bool(COMPILER_RT_DEBUG) diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake index cee0af935e9..5db7eb04800 100644 --- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ b/compiler-rt/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()  | 

