[PATCH] D103287: Pass -gcodeview-ghash when using clang-cl and lld-link
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 27 14:35:51 PDT 2021
rnk created this revision.
rnk added reviewers: aganea, hans.
Herald added a subscriber: mgorny.
rnk requested review of this revision.
Herald added a project: LLVM.
This precomputes some hashes that LLD uses for type merging to speed up
linking when PDBs are enabled. Only do this if any kind of /DEBUG flag
is passed to the linker. -gcodeview-ghash is orthogonal to /Z7, -g, -g1,
or -gmlt, so it is safe to set it independently from those flags. It
will not increase debug info emission.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D103287
Files:
llvm/cmake/modules/HandleLLVMOptions.cmake
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -474,6 +474,23 @@
CMAKE_SHARED_LINKER_FLAGS)
endif()
+ # Get all linker flags in upper case form so we can search them.
+ set(all_linker_flags_uppercase
+ "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}")
+ string(TOUPPER "${all_linker_flags_uppercase}" all_linker_flags_uppercase)
+
+ if (CLANG_CL AND LINKER_IS_LLD)
+ # If we are using clang-cl with lld-link and /debug is present in any of the
+ # linker flag variables, pass -gcodeview-ghash to the compiler to speed up
+ # linking. This flag is orthogonal from /Zi, /Z7, and other flags that
+ # enable debug info emission, and only has an effect if those are also in
+ # use.
+ string(FIND "${all_linker_flags_uppercase}" "/DEBUG" linker_flag_idx)
+ if (${linker_flag_idx} GREATER -1)
+ append("-gcodeview-ghash" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+ endif()
+ endif()
+
# Disable string literal const->non-const type conversion.
# "When specified, the compiler requires strict const-qualification
# conformance for pointers initialized by using string literals."
@@ -499,13 +516,7 @@
if (SUPPORTS_BREPRO)
# Check if /INCREMENTAL is passed to the linker and complain that it
# won't work with /Brepro.
- string(TOUPPER "${CMAKE_EXE_LINKER_FLAGS}" upper_exe_flags)
- string(TOUPPER "${CMAKE_MODULE_LINKER_FLAGS}" upper_module_flags)
- string(TOUPPER "${CMAKE_SHARED_LINKER_FLAGS}" upper_shared_flags)
-
- string(FIND "${upper_exe_flags} ${upper_module_flags} ${upper_shared_flags}"
- "/INCREMENTAL" linker_flag_idx)
-
+ string(FIND "${all_linker_flags_uppercase}" "/INCREMENTAL" linker_flag_idx)
if (${linker_flag_idx} GREATER -1)
message(WARNING "/Brepro not compatible with /INCREMENTAL linking - builds will be non-deterministic")
else()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103287.348391.patch
Type: text/x-patch
Size: 2079 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210527/c91fdfe6/attachment.bin>
More information about the llvm-commits
mailing list