[PATCH] Makerules/Makeconfig: Add rtlddir-build for the libc.so loader reference
Andreas K. Huettel
dilfridge@gentoo.org
Wed Jul 15 11:30:37 GMT 2026
Am Sonntag, 12. Juli 2026, 07:20:53 Japanische Normalzeit schrieb Tiago Dinis:
> From: Tiago Dinis <tiagodinis33@proton.me>
>
> 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.
>
Not urgent, after release (if it gets RB)
> Reviewed-by: (none yet)
> ---
> Makeconfig | 9 +++++++++
> Makerules | 2 +-
> 2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/Makeconfig b/Makeconfig
> index e7dbd9fb..135a98b6 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 6bef57ec..61b24131 100644
> --- a/Makerules
> +++ b/Makerules
> @@ -1024,7 +1024,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) ') )' \
> ) > $@.new
> mv -f $@.new $@
>
>
--
PD Dr. Andreas K. Hüttel
dilfridge@gentoo.org
Gentoo Linux developer
(council, comrel, toolchain, base-system, perl, libreoffice)
https://wiki.gentoo.org/wiki/User:Dilfridge
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 870 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20260715/5fa89600/attachment-0001.sig>
More information about the Libc-alpha
mailing list