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

From: [email-masked] (Ludovic Courtès)
Date: Wed, 08 Apr 2015 20:39:09 +0200

Mark H Weaver <[email-masked]> skribis:

Indeed, here’s what happens when passing it through ld-wrapper:

--8<---------------cut here---------------start------------->8---
ld: unrecognised emulation mode: armelf_linux_eabi
--8<---------------cut here---------------end--------------->8---

Conversely, when “replaying” the command that’s used on x86_64, -rpath
is not added:

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

With a bit of additional debug, I can print the value of ‘libs’ in the
‘ld-wrapper’ procedure:

--8<---------------cut here---------------start------------->8---
;;; (libs ("/gnu/store/fbdjazgwy3zyx8qc5z4ag0j78k2d7raw-glibc-2.21/lib/ld-linux-armhf.so.3"))
--8<---------------cut here---------------end--------------->8---

This one comes from the -dynamic-linker flag, which is not passed on
x86_64.

I believe this extra -dynamic-linker flag comes from a bogus ‘link’ spec
on ARM, solved by this:

--- gcc-4.8.4/gcc/config/arm/linux-elf.h.orig	2015-04-08 20:31:20.376900478 +0200
+++ gcc-4.8.4/gcc/config/arm/linux-elf.h	2015-04-08 20:31:36.437014437 +0200
@@ -65,7 +65,7 @@
    %{symbolic:-Bsymbolic} \
    %{!static: \
      %{rdynamic:-export-dynamic} \
-     -dynamic-linker " GNU_USER_DYNAMIC_LINKER "} \
+     %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
    -X \
    %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
    SUBTARGET_EXTRA_LINK_SPEC

That way it would match GNU_USER_TARGET_LINK_SPEC in i386/gnu-user.h,
where -dynamic-linker appears within %{!static ... %{!shared ...}}.

So, could you do:

  (define patched-gcc
    (package
      (inherit gcc-4.8)
      (sources (origin (inherit (package-source gcc-4.8))
                 (patches ...)))))

build it, and then use it in the failed glibc build tree to rebuild
ld.so?

There are ways we could have worked around it, for instance by adding:

  (setenv "GUIX_LD_WRAPPER_DISABLE_RPATH" "yes")

in the glibc recipe.

But I think it’s better to understand what’s going on.

Thanks,
Ludo’.