[PATCH] D84127: Make LLVM_ENABLE_LTO function with multi-arch values for CMAKE_OSX_ARCHITECTURES
Daniel Sanders via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 3 15:02:31 PDT 2020
dsanders updated this revision to Diff 282738.
dsanders added a comment.
Last one our own testing hit: Fix the case where lack of debug info means we didn't extract dsyms
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84127/new/
https://reviews.llvm.org/D84127
Files:
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/scripts/move_if_exists.cmake
Index: llvm/cmake/scripts/move_if_exists.cmake
===================================================================
--- /dev/null
+++ llvm/cmake/scripts/move_if_exists.cmake
@@ -0,0 +1,3 @@
+if(EXISTS "${FROM}")
+ execute_process(COMMAND ${CMAKE_COMMAND} -E rename "${FROM}" "${TO}")
+endif()
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1970,27 +1970,37 @@
set(file_ext dSYM)
endif()
- set(output_name "$<TARGET_FILE_NAME:${name}>.${file_ext}")
-
+ # As long as we compile at least one file from source code, clang will
+ # invoke dsymutil on the temporary objects after lipo'ing all the slices
+ # together.
+ # This is a workaround to a clang bug where dsymutil is not invoked for
+ # every case where debug info is present and temporary objects are being
+ # linked. See https://bugs.llvm.org/show_bug.cgi?id=46841 for more
+ # information.
+ set(empty_src
+ ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${name}-empty.cpp)
+ file(WRITE "${empty_src}" "extern int dummy;\n")
+ set_property(TARGET ${name} APPEND_STRING PROPERTY
+ LINK_FLAGS " ${empty_src}")
if(LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR)
- set(output_path "-o=${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}")
- else()
- set(output_path "-o=${output_name}")
- endif()
-
- 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_property(TARGET ${name} APPEND_STRING PROPERTY
- LINK_FLAGS " -Wl,-object_path_lto,${lto_object}")
- endif()
- if(NOT CMAKE_DSYMUTIL)
- set(CMAKE_DSYMUTIL xcrun dsymutil)
+ # clang can currently only emit dSYM's to the same directory as the output
+ # binary. Workaround this by moving it after the build.
+ set(output_name "$<TARGET_FILE_NAME:${name}>.${file_ext}")
+ set(output_path "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}/${output_name}")
+ add_custom_command(TARGET ${name} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E make_directory "${LLVM_EXTERNALIZE_DEBUGINFO_OUTPUT_DIR}"
+ # Remove any old versions if present
+ COMMAND ${CMAKE_COMMAND} -E rm "-rf" "${output_path}"
+ # Move the dSYM clang emitted next to the output binary where we want it
+ # to be.
+ COMMAND ${CMAKE_COMMAND}
+ -DFROM="$<TARGET_FILE:${name}>.${file_ext}"
+ -DTO="${output_path}"
+ -P ${LLVM_SOURCE_DIR}/cmake/scripts/move_if_exists.cmake
+ )
endif()
add_custom_command(TARGET ${name} POST_BUILD
- COMMAND ${CMAKE_DSYMUTIL} ${output_path} $<TARGET_FILE:${name}>
- ${strip_command}
+ COMMAND ${strip_command}
)
else()
add_custom_command(TARGET ${name} POST_BUILD
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84127.282738.patch
Type: text/x-patch
Size: 3004 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200803/d17be9ce/attachment.bin>
More information about the llvm-commits
mailing list