Subject: bug#20102: Problem with ld.so RUNPATH on armhf

From: Mark H Weaver <[email-masked]>
Date: Wed, 08 Apr 2015 11:21:45 -0400

[email-masked] (Ludovic Courtès) writes:

> Mark H Weaver <[email-masked]> skribis:
>
> The difference between ‘glibc-final’ and (@ (gnu packages base) glibc)
> (used to build glibc-utf8-locales) is that the latter is built with
> ‘gcc-final’, and ‘gcc-final’ always passes “-rpath $libc/lib” when
> linking a shared object, as seen above.
>
> However, when linking ld.so, -nostdlib is used, so IIUC the “lib” spec
> is ignored, so the -rpath flag isn’t passed.
>
> At least that’s what happens on x86_64: I interrupted the (@ (gnu
> packages base) glibc) build on x86_64 and ran the command manually:
>
> ludo@pluto /tmp/nix-build-glibc-2.21.drv-0/build/elf$ strace -s 345 -f -o ,,s gcc --verbose   -nostdlib -nostartfiles -shared -o /tmp/nix-build-glibc-2.21.drv-0/build/elf/ld.so.new		\
> 	  -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs 	\
> 	  /tmp/nix-build-glibc-2.21.drv-0/build/elf/librtld.os -Wl,--version-script=/tmp/nix-build-glibc-2.21.drv-0/build/ld.map		\
> 	  -Wl,-soname=ld-linux-x86-64.so.2			\
> 	  -Wl,-defsym=_begin=0
>
>> > > > Using built-in specs.
> COLLECT_GCC=gcc
> COLLECT_LTO_WRAPPER=/gnu/store/4sqgnc9bc1kmn058yp4xnj4vpydmfzpq-gcc-4.8.4/libexec/gcc/x86_64-unknown-linux-gnu/4.8.4/lto-wrapper
> Target: x86_64-unknown-linux-gnu
> Configured with: 
> Thread model: posix
> gcc version 4.8.4 (GCC) 
> COMPILER_PATH=/gnu/store/4sqgnc9bc1kmn058yp4xnj4vpydmfzpq-gcc-4.8.4/libexec/gcc/x86_64-unknown-linux-gnu/4.8.4/:/gnu/store/4sqgnc9bc1kmn058yp4xnj4vpydmfzpq-gcc-4.8.4/libexec/gcc/x86_64-unknown-linux-gnu/4.8.4/:/gnu/store/4sqgnc9bc1kmn058yp4xnj4vpydmfzpq-gcc-4.8.4/libexec/gcc/x86_64-unknown-linux-gnu/:/gnu/store/h132igxl2lkj3sbfcbknn2rd493j7d1l-gcc-4.8.4-lib/lib/gcc/x86_64-unknown-linux-gnu/4.8.4/:/gnu/store/h132igxl2lkj3sbfcbknn2rd493j7d1l-gcc-4.8.4-lib/lib/gcc/x86_64-unknown-linux-gnu/
> COLLECT_GCC_OPTIONS='-v' '-nostdlib' '-nostartfiles' '-shared' '-o' '/tmp/nix-build-glibc-2.21.drv-0/build/elf/ld.so.new' '-mtune=generic' '-march=x86-64'
>
> The strace log shows that ld is not passed the -rpath flags that appear
> in the “lib” spec:
>
>
> Could you try the same on armhf?

I've done so.  Here's the transcript:

--8<---------------cut here---------------start------------->8---
mhw@novena:/tmp/nix-build-glibc-2.21.drv-0$ source environment-variables 
mhw@novena:/tmp/nix-build-glibc-2.21.drv-0/build$ cd /tmp/nix-build-glibc-2.21.drv-0/build/elf/
mhw@novena:/tmp/nix-build-glibc-2.21.drv-0/build/elf$ /usr/bin/strace -s 345 -f -o ,,s gcc --verbose   -nostdlib -nostartfiles -shared -o /tmp/nix-build-glibc-2.21.drv-0/build/elf/ld.so.new		\
	  -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs 	\
	  /tmp/nix-build-glibc-2.21.drv-0/build/elf/librtld.os -Wl,--version-script=/tmp/nix-build-glibc-2.21.drv-0/build/ld.map		\
	  -Wl,-soname=ld-linux-armhf.so.3			\
	  -Wl,-defsym=_begin=0
> > > > Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/gnu/store/qchkhdj4nn4aqs8rrbbyybrj2sarjs3j-gcc-4.8.4/libexec/gcc/armv7l-unknown-linux-gnueabihf/4.8.4/lto-wrapper
Target: armv7l-unknown-linux-gnueabihf
Configured with: 
Thread model: posix
gcc version 4.8.4 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-nostdlib' '-nostartfiles' '-shared' '-o' '/tmp/nix-build-glibc-2.21.drv-0/build/elf/ld.so.new' '-march=armv7-a' '-mfloat-abi=hard' '-mfpu=vfpv3-d16' '-mthumb' '-mtls-dialect=gnu'
mhw@novena:/tmp/nix-build-glibc-2.21.drv-0/build/elf$
--8<---------------cut here---------------end--------------->8---

and here's the corresponding line in the strace log:

--8<---------------cut here---------------start------------->8---
--8<---------------cut here---------------end--------------->8---

    Thanks!
      Mark