summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2018-08-22 16:22:36 +0200
committerMarius Bakke <mbakke@fastmail.com>2018-08-22 18:01:09 +0200
commitbf91e6835d21e3bd7b49bb85b40f61389604c6f7 (patch)
tree5983cbd00e146fa2b7d0e9639f92dfc215c920a3
parentfdb222033c7bf4580bea0158840e9bb7905a00bc (diff)
downloadguix-bf91e6835d21e3bd7b49bb85b40f61389604c6f7.tar.gz
build-system/meson: Strip RUNPATH and remove PatchELF traces.
* guix/build-system/meson.scm (%meson-build-system-modules): Don't
import (guix build rpath).
* guix/build/meson-build-system.scm (fix-runpath): Rename to ...
(shrink-runpath): ... this.  Update docstring.  Remove AUGMENT-RPATH calls and
related code.
(%standard-phases): Add 'shrink-runpath'.
-rw-r--r--guix/build-system/meson.scm1
-rw-r--r--guix/build/meson-build-system.scm52
2 files changed, 7 insertions, 46 deletions
diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm
index fddf899092..8d49020454 100644
--- a/guix/build-system/meson.scm
+++ b/guix/build-system/meson.scm
@@ -41,7 +41,6 @@
 (define %meson-build-system-modules
   ;; Build-side modules imported by default.
   `((guix build meson-build-system)
-    (guix build rpath)
     ;; The modules from glib-or-gtk contains the modules from gnu-build-system,
     ;; so there is no need to import that too.
     ,@%glib-or-gtk-build-system-modules))
diff --git a/guix/build/meson-build-system.scm b/guix/build/meson-build-system.scm
index f6b8b49801..d0975fcab0 100644
--- a/guix/build/meson-build-system.scm
+++ b/guix/build/meson-build-system.scm
@@ -22,7 +22,6 @@
   #:use-module ((guix build gnu-build-system) #:prefix gnu:)
   #:use-module ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
   #:use-module (guix build utils)
-  #:use-module (guix build rpath)
   #:use-module (guix build gremlin)
   #:use-module (guix elf)
   #:use-module (ice-9 match)
@@ -78,42 +77,13 @@
 (define* (install #:rest args)
   (invoke "ninja" "install"))
 
-(define* (fix-runpath #:key (elf-directories '("lib" "lib64" "libexec"
-                                               "bin" "sbin"))
-                      outputs #:allow-other-keys)
-  "Try to make sure all ELF files in ELF-DIRECTORIES are able to find their
-local dependencies in their RUNPATH, by searching for the needed libraries in
-the directories of the package, and adding them to the RUNPATH if needed.
-Also shrink the RUNPATH to what is needed,
+(define* (shrink-runpath #:key (elf-directories '("lib" "lib64" "libexec"
+                                                  "bin" "sbin"))
+                         outputs #:allow-other-keys)
+  "Go through all ELF files from ELF-DIRECTORIES and shrink the RUNPATH
 since a lot of directories are left over from the build phase of meson,
 for example libraries only needed for the tests."
 
-  ;; Find the directories (if any) that contains DEP-NAME.  The directories
-  ;; searched are the ones that ELF-FILES are in.
-  (define (find-deps dep-name elf-files)
-    (map dirname (filter (lambda (file)
-                           (string=? dep-name (basename file)))
-                         elf-files)))
-
-  ;; Return a list of libraries that FILE needs.
-  (define (file-needed file)
-    (let* ((elf (call-with-input-file file
-                  (compose parse-elf get-bytevector-all)))
-           (dyninfo (elf-dynamic-info elf)))
-      (if dyninfo
-          (elf-dynamic-info-needed dyninfo)
-          '())))
-
-
-  ;; If FILE needs any libs that are part of ELF-FILES, the RUNPATH
-  ;; is modified accordingly.
-  (define (handle-file file elf-files)
-    (let* ((dep-dirs (concatenate (map (lambda (dep-name)
-                                         (find-deps dep-name elf-files))
-                                       (file-needed file)))))
-      (unless (null? dep-dirs)
-        (augment-rpath file (string-join dep-dirs ":")))))
-
   (define handle-output
     (match-lambda
       ((output . directory)
@@ -129,10 +99,7 @@ for example libraries only needed for the tests."
               (elf-list (concatenate (map (lambda (dir)
                                             (find-files dir elf-pred))
                                           existing-elf-dirs))))
-         (for-each (lambda (elf-file)
-                     (strip-runpath elf-file)
-                     (handle-file elf-file elf-list))
-                   elf-list)))))
+         (for-each strip-runpath elf-list)))))
   (for-each handle-output outputs)
   #t)
 
@@ -144,13 +111,8 @@ for example libraries only needed for the tests."
     (replace 'configure configure)
     (replace 'build build)
     (replace 'check check)
-    ;; XXX: We used to have 'fix-runpath' here, but it appears no longer
-    ;; necessary with newer Meson.  However on 'core-updates' there is a
-    ;; useful 'strip-runpath' procedure to ensure no bogus directories in
-    ;; RUNPATH (remember that we tell Meson to not touch RUNPATH in
-    ;; (@ (gnu packages build-tools) meson-for-build)), so it should be
-    ;; re-added there sans the augment-rpath calls (which are not needed).
-    (replace 'install install)))
+    (replace 'install install)
+    (add-after 'strip 'shrink-runpath shrink-runpath)))
 
 (define* (meson-build #:key inputs phases
                       #:allow-other-keys #:rest args)