git: 04393db00313 - stable/13 - Bump lld LINKER_FREEBSD_VERSION for reproducibility fix

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Tue, 08 Oct 2024 08:45:25 UTC
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=04393db0031382a3b2d7de037e862b33e3ea4bbe

commit 04393db0031382a3b2d7de037e862b33e3ea4bbe
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-09-22 17:12:01 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2024-10-08 08:37:09 +0000

    Bump lld LINKER_FREEBSD_VERSION for reproducibility fix
    
    The upstream fix to make lld output for our EFI loaders reproducible
    again was committed in 54521a2ff93a. Bump lld's LINKER_FREEBSD_VERSION
    to be able to check this in the EFI loader Makefile.
    
    MFC after:      3 days
    
    (cherry picked from commit f97c7fdc59d252cc8611968ffac541d4b8342b8b)
---
 lib/clang/include/lld/Common/Version.inc | 2 +-
 stand/efi/loader/Makefile                | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/clang/include/lld/Common/Version.inc b/lib/clang/include/lld/Common/Version.inc
index 20f5fbe6e124..2e9f3e4e6330 100644
--- a/lib/clang/include/lld/Common/Version.inc
+++ b/lib/clang/include/lld/Common/Version.inc
@@ -1,4 +1,4 @@
 // Local identifier in __FreeBSD_version style
-#define LLD_FREEBSD_VERSION 1400006
+#define LLD_FREEBSD_VERSION 1400007
 
 #define LLD_VERSION_STRING "18.1.6 (FreeBSD llvmorg-18.1.6-0-g1118c2e05e67-" __XSTRING(LLD_FREEBSD_VERSION) ")"
diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile
index c5503da655f9..a2cb643dd4c4 100644
--- a/stand/efi/loader/Makefile
+++ b/stand/efi/loader/Makefile
@@ -105,10 +105,17 @@ LDFLAGS+=	-Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -pie
 LDFLAGS+=	-Wl,--no-dynamic-linker
 .endif
 
+.include <bsd.linker.mk>
+
+.if ${LINKER_TYPE} == "lld" && \
+    (${LINKER_FREEBSD_VERSION} < 1400007 || \
+    (${LINKER_FREEBSD_VERSION} >= 1500000 && \
+    ${LINKER_FREEBSD_VERSION} < 1500001))
 # When lld is using multiple threads, which it does by default, it can
 # result in non-reproducible output with the custom linker script. Work
 # around this by disabling threading.
-LDFLAGS.lld+=	-Wl,--threads=1
+LDFLAGS+=	-Wl,--threads=1
+.endif
 
 CLEANFILES+=	${LOADER}.efi