bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Ludovic Courtès
Subject: bug#20102: Problem with ld.so RUNPATH on armhf
Date: Thu, 09 Apr 2015 00:33:14 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

address@hidden (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:

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 \"@address@hidden") 
(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)))
Could you check whether it solves the problem?

(Tested on x86_64, no regressions AFAICS.)

Ludo’.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]