unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Mark H Weaver <mhw@netris.org>
Cc: 20102@debbugs.gnu.org
Subject: bug#20102: Problem with ld.so RUNPATH on armhf
Date: Thu, 09 Apr 2015 00:33:14 +0200	[thread overview]
Message-ID: <87y4m2z1w5.fsf@gnu.org> (raw)
In-Reply-To: <87twwqv50y.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Wed, 08 Apr 2015 20:39:09 +0200")

[-- Attachment #1: Type: text/plain, Size: 815 bytes --]

ludo@gnu.org (Ludovic Courtès) skribis:

> 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.

I’m forgetting another possibility: fix ld-wrapper so that it doesn’t
add “-rpath $(dirname ld.so)” when it encounters “-dynamic-linker ld.so”.

This patch does that:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 3360 bytes --]

diff --git a/gnu/packages/ld-wrapper.in b/gnu/packages/ld-wrapper.in
index 094018d..125edee 100644
--- a/gnu/packages/ld-wrapper.in
+++ b/gnu/packages/ld-wrapper.in
@@ -142,34 +142,45 @@ exec @GUILE@ -c "(load-compiled \"@SELF@.go\") (apply $main (cdr (command-line))
 (define (library-files-linked args)
   ;; Return the file names of shared libraries explicitly linked against via
   ;; `-l' or with an absolute file name in ARGS.
-  (define path+files
+  (define path+files+args
     (fold (lambda (argument result)
             (match result
-              ((library-path . library-files)
+              ((library-path library-files ("-dynamic-linker" . rest))
+               ;; When passed '-dynamic-linker ld.so', ignore 'ld.so'.
+               ;; See <http://bugs.gnu.org/20102>.
+               (list library-path
+                     library-files
+                     (cons* argument "-dynamic-linker" rest)))
+              ((library-path library-files previous-args)
                (cond ((string-prefix? "-L" argument) ;augment the search path
-                      (cons (append library-path
+                      (list (append library-path
                                     (list (string-drop argument 2)))
-                            library-files))
+                            library-files
+                            (cons argument previous-args)))
                      ((string-prefix? "-l" argument) ;add library
                       (let* ((lib  (string-append "lib"
                                                   (string-drop argument 2)
                                                   ".so"))
                              (full (search-path library-path lib)))
+                        (list library-path
                               (if full
-                            (cons library-path
-                                  (cons full library-files))
-                            result)))
+                                  (cons full library-files)
+                                  library-files)
+                              (cons argument previous-args))))
                      ((and (string-prefix? %store-directory argument)
                            (shared-library? argument)) ;add library
-                      (cons library-path
-                            (cons argument library-files)))
+                      (list library-path
+                            (cons argument library-files)
+                            (cons argument previous-args)))
                      (else
-                      result)))))
-          (cons '() '())
+                      (list library-path
+                            library-files
+                            (cons argument previous-args)))))))
+          (list '() '() '())
           args))
 
-  (match path+files
-    ((path . files)
+  (match path+files+args
+    ((path files arguments)
      (reverse files))))
 
 (define (rpath-arguments library-files)
@@ -202,6 +213,8 @@ impure library ~s~%"
          (args (append args (rpath-arguments libs))))
     (when %debug?
       (format (current-error-port)
+              "ld-wrapper: libraries linked: ~s~%" libs)
+      (format (current-error-port)
               "ld-wrapper: invoking `~a' with ~s~%"
               %real-ld args))
     (apply execl %real-ld (basename %real-ld) args)))

[-- Attachment #3: Type: text/plain, Size: 108 bytes --]


Could you check whether it solves the problem?

(Tested on x86_64, no regressions AFAICS.)

Ludo’.

  reply	other threads:[~2015-04-08 22:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-13 18:56 bug#20102: Problem with ld.so RUNPATH on armhf Mark H Weaver
2015-04-04 21:58 ` Ludovic Courtès
2015-04-05  4:42   ` Mark H Weaver
2015-04-06 20:24     ` Ludovic Courtès
2015-04-06 21:02       ` Mark H Weaver
2015-04-08  9:52         ` Ludovic Courtès
2015-04-08 15:21           ` Mark H Weaver
2015-04-08 15:26             ` Mark H Weaver
2015-04-08 15:48               ` Ludovic Courtès
2015-04-08 15:50             ` Mark H Weaver
2015-04-08 18:39             ` Ludovic Courtès
2015-04-08 22:33               ` Ludovic Courtès [this message]
2015-04-09  6:04               ` Mark H Weaver
2015-04-09  6:57                 ` Ludovic Courtès
2015-04-09  8:18                 ` Ludovic Courtès
2015-06-13 15:12 ` Mark H Weaver
2015-06-13 23:36   ` Ludovic Courtès
2015-07-14 13:32     ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y4m2z1w5.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=20102@debbugs.gnu.org \
    --cc=mhw@netris.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).