[PATCH] Makerules/Makeconfig: Add rtlddir-build for the libc.so loader reference

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue Jul 14 18:33:00 GMT 2026



On 11/07/26 19:20, Tiago Dinis wrote:
> 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.
> 
> Reviewed-by: (none yet)

I think it should be ok, it is another undocumented knob that users will
need to set before configure (or modify after it). But it seems to be way
allow glibc to work on some usual ways.

> ---
>  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 $@
>  



More information about the Libc-alpha mailing list