git: e3c550db8222 - stable/13 - src.libnames.mk: Include dependencies when bootstrapping from non-FreeBSD

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Tue, 25 Jan 2022 01:39:57 UTC
The branch stable/13 has been updated by jrtc27:

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

commit e3c550db8222276f4cf52640e5a07791c3db972e
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2021-12-06 18:53:48 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2022-01-24 23:59:09 +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
    
    (cherry picked from commit f0a6ab51e6da3e385856873b1c1c57a13f1c7eb3)
---
 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 8fd7547630a3..98f50c22532b 100644
--- a/share/mk/src.libnames.mk
+++ b/share/mk/src.libnames.mk
@@ -456,8 +456,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}}