rtld: fix dependencies for rtld-libc

Previously we (appropriately, but incorrectly) attempted to depend on
LIBC_NOSSP_PIC and LIBSYS_PIC for rtld_libc.a.  Unfortunately,
variables in dependency lists are expanded at parse time and those
variables are defined in bsd.libnames.mk which *must* be included by
bsd.{lib,prog}.mk.  As such, they were undefined and thus expanded to
the empty string resulting in no dependency with predictable and highly
confusing results.

Move the declaration of these dependencies to after the include of
bsd.prog.mk and add comments on both side in hopes of keeping any future
dependencies in sync.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D51790
This commit is contained in:
Brooks Davis
2025-08-08 10:30:16 +01:00
parent 4c6c27d3fb
commit fd4cdc438b
2 changed files with 9 additions and 1 deletions
+4
View File
@@ -128,3 +128,7 @@ ${PROG_FULL}: ${VERSION_MAP}
# and are therefore not identical to the ones from the system headers.
CFLAGS+= -Wno-redundant-decls
.endif
# Add dependencies on libc and libsys archives after bsd.prog.mk
# includes bsd.libnames.mk so they are defined.
rtld_libc.a: ${LIBC_NOSSP_PIC} ${LIBSYS_PIC}
+5 -1
View File
@@ -96,7 +96,11 @@ CLEANFILES+=${_obj}.pico
# We insert all the .o files from libc_nossp_pic.a into a new rtld_libc.a file
# to ensure that only .o files that are actually used end up being included.
rtld_libc.a: ${LIBC_NOSSP_PIC} ${LIBSYS_PIC} ${SRCTOP}/libexec/rtld-elf/rtld-libc/Makefile.inc
#
# XXX: we add dependencies on the source libraries in ../Makefile after
# bsd.prog.mk includes bsd.libnames.mk since variables in dependencies are
# expanded when parsed.
rtld_libc.a: ${SRCTOP}/libexec/rtld-elf/rtld-libc/Makefile.inc
@rm -f ${.TARGET}
${AR} x ${LIBC_NOSSP_PIC} ${_rtld_libc_objs}
${AR} x ${LIBSYS_PIC} ${_rtld_libsys_objs}