[PATCH] D111740: Align LLVM_EXTERNALIZE_DEBUGINFO behaviours on Linux w/ Darwin
Jo Shields via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 13 10:10:14 PDT 2021
directhex created this revision.
Herald added a subscriber: mgorny.
directhex requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Despite what it says in the documentation[1], LLVM_EXTERNALIZE_DEBUGINFO is not only for Darwin, and has been functional on Linux since 2017[2].
However, It is hardcoded to emit ${name}.debug in the same directory, whereas macOS allows overriding both the extension and the output dir.
This commit adds support for LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION and LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR on Linux.
[1] https://www.llvm.org/docs/CMake.html#llvm-related-variables
[2] https://reviews.llvm.org/D28575
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D111740
Files:
llvm/cmake/modules/AddLLVM.cmake
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -2007,10 +2007,29 @@
${strip_command}
)
else()
+ if(LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION)
+ set(file_ext ${LLVM_EXTERNALIZE_DEBUGINFO_EXTENSION})
+ else()
+ set(file_ext debug)
+ endif()
+
+ set(output_name "$<TARGET_FILE_NAME:${name}>.${file_ext}")
+
+ if(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR)
+ set(output_path "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}")
+ # If an output dir is specified, it must be manually mkdir'd on Linux,
+ # as that directory needs to exist before we can pipe to a file in it.
+ add_custom_command(TARGET ${name} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}
+ )
+ else()
+ set(output_path "${output_name}")
+ endif()
+
add_custom_command(TARGET ${name} POST_BUILD
- COMMAND ${CMAKE_OBJCOPY} --only-keep-debug $<TARGET_FILE:${name}> $<TARGET_FILE:${name}>.debug
+ COMMAND ${CMAKE_OBJCOPY} --only-keep-debug $<TARGET_FILE:${name}> ${output_path}
${strip_command} -R .gnu_debuglink
- COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=$<TARGET_FILE:${name}>.debug $<TARGET_FILE:${name}>
+ COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${output_path} $<TARGET_FILE:${name}>
)
endif()
endfunction()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111740.379449.patch
Type: text/x-patch
Size: 1496 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211013/33ac9bef/attachment.bin>
More information about the llvm-commits
mailing list