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

From: [email-masked] (Ludovic Courtès)
Date: Sun, 14 Jun 2015 01:36:00 +0200

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

> In March 2015, Mark H Weaver <[email-masked]> wrote:

[...]

>> Inconsistency detected by ld.so: get-dynamic-info.h: 142: elf_get_dynamic_info: Assertion `info[29] == ((void *)0)' failed!
>
> The same problem has resurfaced on armhf on the current core-updates
> branch.  More precisely, this is a merge of core-updates (16cae79),
> master (1e44cf8), and openssl-update (0515580).
>
> There's one difference: I can successfully run "guix build -K
> glibc-utf8-locales", but if I try to build any profile, it fails while
> building another package named "glibc-utf8-locales", with precisely the
> same error message above.  Otherwise, I managed to build every package
> in my profile, which includes some substantial software.

It happens on x86_64 as well.  Namely, the glibc that is built with
glibc-final and gcc-final has extra RUNPATH entries:

--8<---------------cut here---------------start------------->8---
$ ./pre-inst-env guix build -e '(@ (gnu packages base) glibc)' -K
[...]
/gnu/store/pxi61vv6qj325y3zs5qpcy2shykgxdar-glibc-2.21
/gnu/store/m3qidd4gx7ry3wxagsrd9cwlykq90yi7-glibc-2.21-debug
$ /gnu/store/pxi61vv6qj325y3zs5qpcy2shykgxdar-glibc-2.21/bin/gencat 
Inconsistency detected by ld.so: get-dynamic-info.h: 142: elf_get_dynamic_info: Assertion `info[29] == ((void *)0)' failed!
$ objdump -x /gnu/store/pxi61vv6qj325y3zs5qpcy2shykgxdar-glibc-2.21/bin/gencat |grep PATH
  RUNPATH              /gnu/store/2bq2qaaajar2f3dbxrrwssxfrfi0k9zr-gcc-4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2
--8<---------------cut here---------------end--------------->8---

After a bit of investigation, I found that the problem came from:

  -plugin /gnu/store/2bq2qaaajar2f3dbxrrwssxfrfi0k9zr-gcc-4.9.2/libexec/gcc/x86_64-unknown-linux-gnu/4.9.2/liblto_plugin.so.0

which led ld-wrapper to add a -rpath flag for that directory.

I’m testing the patch below and will commit tomorrow if everything goes
well.

Thanks,
Ludo’.

--- a/gnu/packages/ld-wrapper.in
+++ b/gnu/packages/ld-wrapper.in
@@ -143,12 +143,16 @@ exec @GUILE@ -c "(load-compiled \"@SELF@.go\") (apply $main (cdr (command-line))
   (define path+files+args
     (fold (lambda (argument result)
             (match result
-              ((library-path library-files ("-dynamic-linker" . rest))
-               ;; When passed '-dynamic-linker ld.so', ignore 'ld.so'.
-               ;; See <http://bugs.gnu.org/20102>.
+              ((library-path library-files
+                             ((and flag
+                                   (or "-dynamic-linker" "-plugin"))
+                              . rest))
+               ;; When passed '-dynamic-linker ld.so', ignore 'ld.so'; when
+               ;; passed '-plugin liblto_plugin.so', ignore
+               ;; 'liblto_plugin.so'.  See <http://bugs.gnu.org/20102>.
                (list library-path
                      library-files
-                     (cons* argument "-dynamic-linker" rest)))
+                     (cons* argument flag rest)))
               ((library-path library-files previous-args)
                (cond ((string-prefix? "-L" argument) ;augment the search path
                       (list (append library-path