diff --git a/config_host.mk.in b/config_host.mk.in index 31590d50ea1d..3f52596779bc 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -336,6 +336,7 @@ export HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR=@HAVE_CLANG_DEBUG_INFO_KIND_CONSTR export HAVE_CXX20_ATOMIC_REF=@HAVE_CXX20_ATOMIC_REF@ export HAVE_DLLEXPORTINLINES=@HAVE_DLLEXPORTINLINES@ export HAVE_EXTERNAL_DWARF=@HAVE_EXTERNAL_DWARF@ +export HAVE_LINK_DEBUG_FASTLINK=@HAVE_LINK_DEBUG_FASTLINK@ export HAVE_LO_CLANG_DLLEXPORTINLINES=@HAVE_LO_CLANG_DLLEXPORTINLINES@ export HAVE_GCC_AVX=@HAVE_GCC_AVX@ export HAVE_GCC_BUILTIN_ATOMIC=@HAVE_GCC_BUILTIN_ATOMIC@ diff --git a/configure.ac b/configure.ac index 0a7a3b858525..ad31249528eb 100644 --- a/configure.ac +++ b/configure.ac @@ -5215,6 +5215,33 @@ fi AC_SUBST(USE_LD) AC_SUBST(LD) +dnl =================================================================== +dnl Check whether the linker supports -debug:fastlink, which links debug +dnl builds faster. MSVC link.exe does; lld-link currently does not and would +dnl warn on every link, falling back to -debug:full. Probe the selected linker +dnl rather than hardcoding "lld has no fastlink", so a future lld-link that +dnl gains support starts using it automatically. +dnl =================================================================== +HAVE_LINK_DEBUG_FASTLINK= +if test "$_os" = "WINNT"; then + AC_MSG_CHECKING([whether the linker supports -debug:fastlink]) + if test -z "$LLD_LINK"; then + dnl MSVC link.exe supports it natively + HAVE_LINK_DEBUG_FASTLINK=TRUE + elif "$LLD_LINK" -debug:fastlink conftest-nonexistent.obj 2>&1 | grep -iq "debug:fastlink.*debug:full"; then + dnl the fallback warning means fastlink is not supported + HAVE_LINK_DEBUG_FASTLINK= + else + HAVE_LINK_DEBUG_FASTLINK=TRUE + fi + if test -n "$HAVE_LINK_DEBUG_FASTLINK"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi +fi +AC_SUBST(HAVE_LINK_DEBUG_FASTLINK) + HAVE_LD_BSYMBOLIC_FUNCTIONS= if test "$GCC" = "yes" -a "$_os" != Emscripten ; then AC_MSG_CHECKING([for -Bsymbolic-functions linker support]) diff --git a/solenv/gbuild/platform/com_MSC_class.mk b/solenv/gbuild/platform/com_MSC_class.mk index 6e3a6da1a578..212a682ee86f 100644 --- a/solenv/gbuild/platform/com_MSC_class.mk +++ b/solenv/gbuild/platform/com_MSC_class.mk @@ -335,7 +335,7 @@ gb_Windows_PE_TARGETTYPEFLAGS := \ ifeq ($(ENABLE_DBGUTIL),TRUE) # fastlink is faster but pdb files reference .obj files # but don't do that for setup_native DLLs: this produces make error 139 in some configurations -gb_Windows_PE_TARGETTYPEFLAGS_DEBUGINFO = $(if $(filter -U_DLL,$(1)),-debug,-debug:fastlink) +gb_Windows_PE_TARGETTYPEFLAGS_DEBUGINFO = $(if $(filter -U_DLL,$(1)),-debug,-debug$(if $(HAVE_LINK_DEBUG_FASTLINK),:fastlink)) else gb_Windows_PE_TARGETTYPEFLAGS_DEBUGINFO = -debug endif