[PATCH] D28575: [CMake] Support externalizing debug info on non-Darwin platforms

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 11 12:53:40 PST 2017


phosek created this revision.
phosek added a reviewer: beanz.
phosek added a subscriber: llvm-commits.
phosek set the repository for this revision to rL LLVM.
Herald added subscribers: aprantl, mgorny.

On other platorms, we use objcopy to export the debug info.


Repository:
  rL LLVM

https://reviews.llvm.org/D28575

Files:
  cmake/modules/AddLLVM.cmake


Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -1389,10 +1389,18 @@
   endif()
 
   if(NOT LLVM_EXTERNALIZE_DEBUGINFO_SKIP_STRIP)
-    set(strip_command COMMAND xcrun strip -Sxl $<TARGET_FILE:${name}>)
+    if(APPLE)
+      set(strip_command COMMAND xcrun strip -Sxl $<TARGET_FILE:${name}>)
+    else()
+      set(strip_command COMMAND strip -gx $<TARGET_FILE:${name}>)
+    endif()
   endif()
 
   if(APPLE)
+    if(NOT LLVM_EXTERNALIZE_DEBUGINFO_SKIP_STRIP)
+      set(strip_command COMMAND xcrun strip -Sxl $<TARGET_FILE:${name}>)
+    endif()
+
     if(CMAKE_CXX_FLAGS MATCHES "-flto"
       OR CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE} MATCHES "-flto")
 
@@ -1405,7 +1413,14 @@
       ${strip_command}
       )
   else()
-    message(FATAL_ERROR "LLVM_EXTERNALIZE_DEBUGINFO isn't implemented for non-darwin platforms!")
+    if(NOT LLVM_EXTERNALIZE_DEBUGINFO_SKIP_STRIP)
+      set(strip_command COMMAND strip -gx $<TARGET_FILE:${name}>)
+    endif()
+
+    add_custom_command(TARGET ${name} POST_BUILD
+      COMMAND objcopy --only-keep-debug $<TARGET_FILE:${name}> $<TARGET_FILE:${name}>.dbg
+      ${strip_command}
+      )
   endif()
 endfunction()
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28575.84010.patch
Type: text/x-patch
Size: 1287 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170111/2d4e889f/attachment.bin>


More information about the llvm-commits mailing list