The branch main has been updated by brooks:

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

commit fd4cdc438b7740007b06ea97431cc724e9aae185
Author:     Brooks Davis <bro...@freebsd.org>
AuthorDate: 2025-08-08 09:30:16 +0000
Commit:     Brooks Davis <bro...@freebsd.org>
CommitDate: 2025-08-08 09:30:16 +0000

    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
---
 libexec/rtld-elf/Makefile               | 4 ++++
 libexec/rtld-elf/rtld-libc/Makefile.inc | 6 +++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libexec/rtld-elf/Makefile b/libexec/rtld-elf/Makefile
index 0dbd2b8aa935..b6ff7681e658 100644
--- a/libexec/rtld-elf/Makefile
+++ b/libexec/rtld-elf/Makefile
@@ -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}
diff --git a/libexec/rtld-elf/rtld-libc/Makefile.inc 
b/libexec/rtld-elf/rtld-libc/Makefile.inc
index b16f84f398d0..a10bd562a7ce 100644
--- a/libexec/rtld-elf/rtld-libc/Makefile.inc
+++ b/libexec/rtld-elf/rtld-libc/Makefile.inc
@@ -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}

Reply via email to