git: aa6748692085 - stable/13 - Suppress lld 16 errors about undefined symbols in version maps

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

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

commit aa6748692085d8e5ac7a0640f8da8a31fd357f73
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:22:55 +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 71c3dab011ef..684a3df108fa 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -256,6 +256,13 @@ SHLIB_NAME_FULL=${SHLIB_NAME}
 .if !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)