]> granicus.if.org Git - llvm/commitdiff
[CMake] Support externalizing debug info on non-Darwin platforms
authorPetr Hosek <phosek@chromium.org>
Fri, 17 Feb 2017 19:29:12 +0000 (19:29 +0000)
committerPetr Hosek <phosek@chromium.org>
Fri, 17 Feb 2017 19:29:12 +0000 (19:29 +0000)
On other platorms, we use objcopy to export the debug info.

Differential Revision: https://reviews.llvm.org/D28575

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295481 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/AddLLVM.cmake

index cb4171c9bc8825a1c8ef88a812c42d27d2d0cb3a..7f7608cff33d3e0c683272656fc4bd9d5fa6592f 100644 (file)
@@ -1387,7 +1387,11 @@ function(llvm_externalize_debuginfo name)
   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)
@@ -1403,7 +1407,11 @@ function(llvm_externalize_debuginfo name)
       ${strip_command}
       )
   else()
-    message(FATAL_ERROR "LLVM_EXTERNALIZE_DEBUGINFO isn't implemented for non-darwin platforms!")
+    add_custom_command(TARGET ${name} POST_BUILD
+      COMMAND objcopy --only-keep-debug $<TARGET_FILE:${name}> $<TARGET_FILE:${name}>.debug
+      ${strip_command} -R .gnu_debuglink
+      COMMAND objcopy --add-gnu-debuglink=$<TARGET_FILE:${name}>.debug $<TARGET_FILE:${name}>
+      )
   endif()
 endfunction()