diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -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 @@ 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 diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -260,10 +260,12 @@ ${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 diff --git a/share/mk/bsd.opts.mk b/share/mk/bsd.opts.mk --- a/share/mk/bsd.opts.mk +++ b/share/mk/bsd.opts.mk @@ -68,6 +68,7 @@ SSP \ TESTS \ TOOLCHAIN \ + UNDEFINED_VERSION \ WARNS \ WERROR diff --git a/tools/build/options/WITHOUT_UNDEFINED_VERSION b/tools/build/options/WITHOUT_UNDEFINED_VERSION new file mode 100644 --- /dev/null +++ b/tools/build/options/WITHOUT_UNDEFINED_VERSION @@ -0,0 +1,2 @@ +Link libraries with --no-undefined-version to ensure all symbols are +provided.