Add an UNDEFINED_VERSION option

When enabled (current default) link with --undefined-version to allow
symbol maps to contain symbols not defined by libraries.  When disabled,
link with --no-undefined-version to disallow these bugs.

WITHOUT_UNDEFINED_VERSION is currently broken.  Once it is fixed it
should be made the default and this option should likely be removed.

Reviewed by:	dim, emaste
Differential Revision:	https://reviews.freebsd.org/D44169
This commit is contained in:
Brooks Davis 2024-03-01 23:21:46 +00:00
parent c5246cb7b0
commit 2956f5885c
4 changed files with 13 additions and 5 deletions

View file

@ -1,5 +1,5 @@
.\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.
.Dd February 17, 2024
.Dd March 1, 2024
.Dt SRC.CONF 5
.Os
.Sh NAME
@ -1726,6 +1726,9 @@ and that the runtime support library is available
Do not build
.Xr unbound 8
and related programs.
.It Va WITHOUT_UNDEFINED_VERSION
Link libraries with --no-undefined-version to ensure all symbols are
provided.
.It Va WITHOUT_UNIFIED_OBJDIR
Use the historical object directory format for
.Xr build 7

View file

@ -260,10 +260,12 @@ SHLIB_NAME_FULL=${SHLIB_NAME}
${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
# Ideally we'd always enable --no-undefined-version (default for lld >= 16),
# but we have several symbols in our version maps that may or may not exist,
# depending on compile-time defines and that needs to be handled first.
.if ${MK_UNDEFINED_VERSION} == "no"
LDFLAGS+= -Wl,--no-undefined-version
.else
LDFLAGS+= -Wl,--undefined-version
.endif
.endif

View file

@ -68,6 +68,7 @@ __DEFAULT_YES_OPTIONS = \
SSP \
TESTS \
TOOLCHAIN \
UNDEFINED_VERSION \
WARNS \
WERROR

View file

@ -0,0 +1,2 @@
Link libraries with --no-undefined-version to ensure all symbols are
provided.