git: d5ee36dbb272 - stable/12 - Suppress lld 16 errors about undefined symbols in version maps

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sat, 29 Apr 2023 07:37:33 UTC
The branch stable/12 has been updated by dim:

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

commit d5ee36dbb27222e9b3bd57c5ffc5cff5667c2e2e
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-04-17 16:00:20 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-04-29 07:24:32 +0000

    Suppress lld 16 errors about undefined symbols in version maps
    
    lld >= 16 turned on --no-undefined-version by default, which results in
    errors whenever symbols are mentioned in version maps, but are not
    actually defined in the binary.
    
    Since we have quite a few instances of symbols that are defined or not,
    depending on various compile-time settings, suppress this lld check for
    the time being.
    
    MFC after:      1 week
    
    (cherry picked from commit 2ba84b4bcdd6012e8cfbf8a0d060a4438623a638)
---
 share/mk/bsd.lib.mk | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index 69b64200e47f..c472a4add8f6 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -223,6 +223,13 @@ SHLIB_NAME_FULL=${SHLIB_NAME}
 .if ${MK_SYMVER} == "yes" && !empty(VERSION_MAP)
 ${SHLIB_NAME_FULL}:	${VERSION_MAP}
 LDFLAGS+=	-Wl,--version-script=${VERSION_MAP}
+
+# lld >= 16 turned on --no-undefined-version by default, but we have several
+# symbols in our version maps that may or may not exist, depending on
+# compile-time defines.
+.if ${LINKER_TYPE} == "lld" && ${LINKER_VERSION} >= 160000
+LDFLAGS+=	-Wl,--undefined-version
+.endif
 .endif
 
 .if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME)