[glibc] Makerules/Makeconfig: Add rtlddir-build for the libc.so loader reference
Adhemerval Zanella via Glibc-cvs <[email protected]>
| Newsgroups | gmane.comp.lib.glibc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a1e333203ac2d9f90bf9fbc09b4f43f1d16efef5 commit a1e333203ac2d9f90bf9fbc09b4f43f1d16efef5 Author: Tiago Dinis <[email protected]> Date: Sat Jul 11 23:20:53 2026 +0100 Makerules/Makeconfig: Add rtlddir-build for the libc.so loader reference The libc.so linker script generated by "make install" references the dynamic linker via an AS_NEEDED entry so the linker can resolve it while building against libc. Previously this used \$(rtlddir), which is also the path compiled into ld-linux as its self-identification string (-DRTLD in elf/Makefile) and used for the PT_INTERP of glibc's own binaries (installed-rtld-LDFLAGS in Makeconfig). These two uses legitimately differ when glibc is built to run on a different environment with a different filesystem structure than the build system: the loader is installed under the build tree, but the resulting binaries must reference it via the runtime path of the target environment. Setting \$(rtlddir) to that runtime path makes libc.so point at a loader that is not present at build time, breaking linking against libc and later consumers such as binutils. Introduce \$(rtlddir-build), defaulting to \$(rtlddir), and use it for the libc.so AS_NEEDED entry so it tracks where the loader is actually installed. \$(rtlddir) keeps driving the runtime path (self-identification and PT_INTERP). This is a no-op for the default configuration, where rtlddir-build == rtlddir == slibdir. Reviewed-by: Adhemerval Zanella <[email protected]> Diff: --- Makeconfig | 9 +++++++++ Makerules | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Makeconfig b/Makeconfig index e7dbd9fb9e..135a98b697 100644 --- a/Makeconfig +++ b/Makeconfig @@ -165,6 +165,15 @@ rtlddir = $(slibdir) endif inst_rtlddir = $(install_root)$(rtlddir) +# Directory referenced by the libc.so linker script (AS_NEEDED entry) for +# the dynamic linker at build time. This points at the location where the +# loader is actually installed so the linker can resolve it while building +# against libc. It defaults to rtlddir (where it differs, the loader is +# installed in rtlddir-build but identified/loaded at runtime via rtlddir). +ifndef rtlddir-build +rtlddir-build = $(rtlddir) +endif + # Prefix to put on files installed in $(libdir). For libraries `libNAME.a', # the prefix is spliced between `lib' and the name, so the linker switch # `-l$(libprefix)NAME' finds the library; for other files the prefix is diff --git a/Makerules b/Makerules index be51154bae..c0ade8b30c 100644 --- a/Makerules +++ b/Makerules @@ -1049,7 +1049,7 @@ $(inst_libdir)/libc.so: $(common-objpfx)format.lds \ cat $<; \ echo 'GROUP ( $(slibdir)/libc.so$(libc.so-version)' \ '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)$(libc-name))'\ - ' AS_NEEDED (' $(rtlddir)/$(rtld-installed-name) ') )' \ + ' AS_NEEDED (' $(rtlddir-build)/$(rtld-installed-name) ') )' \ ) > [email protected] mv -f [email protected] $@