git: f0a6ab51e6da - main - src.libnames.mk: Include dependencies when bootstrapping from non-FreeBSD

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Mon, 06 Dec 2021 19:17:04 UTC
The branch main has been updated by jrtc27:

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

commit f0a6ab51e6da3e385856873b1c1c57a13f1c7eb3
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2021-12-06 18:53:48 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2021-12-06 19:16:27 +0000

    src.libnames.mk: Include dependencies when bootstrapping from non-FreeBSD
    
    When bootstrapping on FreeBSD we use -DNO_SHARED so this case is already
    handled correctly, but on non-FreeBSD we set NO_SHARED to no in
    Makefile.boot.pre as not all OSes have static libraries available. As a
    result, users of libdwarf fail to link during the cross tools stage due
    to the newly-introduced dependency of libdwarf on libz.
    
    This should perhaps be reworked to instead leave NO_SHARED as yes but
    have an override (either implicit in bsd.prog.mk, or explicit via a new
    variable) to turn off just the use of -static.
    
    MFC after:      1 week
---
 share/mk/src.libnames.mk | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk
index 4339b4f5bb50..bcaf07c88e9c 100644
--- a/share/mk/src.libnames.mk
+++ b/share/mk/src.libnames.mk
@@ -462,8 +462,12 @@ LDADD_${_l}?=	${LDADD_${_l}_L} -l${_l:S/${PIE_SUFFIX}//}${PIE_SUFFIX}
 LDADD_${_l}?=	${LDADD_${_l}_L} -l${_l}
 .endif
 # Add in all dependencies for static linkage.
+# Bootstrapping from non-FreeBSD needs special handling, since it overrides
+# NO_SHARED back to yes despite only building static versions of bootstrap
+# libraries (see tools/build/mk/Makefile.boot.pre).
 .if defined(_DP_${_l}) && (${_INTERNALLIBS:M${_l}} || \
-    (defined(NO_SHARED) && ${NO_SHARED:tl} != "no"))
+    (defined(NO_SHARED) && ${NO_SHARED:tl} != "no") || \
+    (defined(BOOTSTRAPPING) && ${.MAKE.OS} != "FreeBSD"))
 .for _d in ${_DP_${_l}}
 DPADD_${_l}+=	${DPADD_${_d}}
 LDADD_${_l}+=	${LDADD_${_d}}