* [bug#28444] [PATCH 0/3] Add meson-build-system
@ 2017-09-13 12:48 Peter Mikkelsen
2017-09-13 12:50 ` [bug#28444] [PATCH 1/3] gnu: meson: Update to 0.42.0 Peter Mikkelsen
0 siblings, 1 reply; 15+ messages in thread
From: Peter Mikkelsen @ 2017-09-13 12:48 UTC (permalink / raw)
To: 28444
The following patches updates meson, adds a special version of meson to
be used in the build system, and then adds the build system. It does not
support cross compilation yet, but I might add it in the future.
Happy hacking!
Peter Mikkelsen (3):
gnu: meson: Update to 0.42.0.
gnu: Add meson-for-build.
build-system: Add 'meson-build-system'.
Makefile.am | 2 +
doc/guix.texi | 55 +++++++
gnu/local.mk | 1 +
gnu/packages/build-tools.scm | 20 ++-
gnu/packages/patches/meson-for-build-rpath.patch | 24 +++
guix/build-system/meson.scm | 178 +++++++++++++++++++++++
guix/build/meson-build-system.scm | 144 ++++++++++++++++++
7 files changed, 422 insertions(+), 2 deletions(-)
create mode 100644 gnu/packages/patches/meson-for-build-rpath.patch
create mode 100644 guix/build-system/meson.scm
create mode 100644 guix/build/meson-build-system.scm
--
2.14.1
^ permalink raw reply [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 1/3] gnu: meson: Update to 0.42.0.
2017-09-13 12:48 [bug#28444] [PATCH 0/3] Add meson-build-system Peter Mikkelsen
@ 2017-09-13 12:50 ` Peter Mikkelsen
2017-09-13 12:50 ` [bug#28444] [PATCH 2/3] gnu: Add meson-for-build Peter Mikkelsen
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Peter Mikkelsen @ 2017-09-13 12:50 UTC (permalink / raw)
To: 28444
* gnu/packages/build-tools.scm (meson): Update to 0.42.0.
[propagated-inputs]: Add python.
---
gnu/packages/build-tools.scm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index 353c9c8ef..5cc0da55d 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -70,7 +70,7 @@ makes a few sacrifices to acquire fast full and incremental build times.")
(define-public meson
(package
(name "meson")
- (version "0.41.1")
+ (version "0.42.0")
(source (origin
(method url-fetch)
(uri (string-append "https://github.com/mesonbuild/meson/"
@@ -78,9 +78,10 @@ makes a few sacrifices to acquire fast full and incremental build times.")
(file-name (string-append name "-" version ".tar.gz"))
(sha256
(base32
- "12ygjh1dxi8z06nl704rfb6zj0m2zjqp279nymfgzfgy5zq032d4"))))
+ "0vyp9rkymzzzilhnf04ryszslyp9a0y0wf4agyijd4w5lcnqlcbc"))))
(build-system python-build-system)
(inputs `(("ninja", ninja)))
+ (propagated-inputs `(("python" ,python)))
(home-page "https://mesonbuild.com/")
(synopsis "Build system designed to be fast and user-friendly")
(description
--
2.14.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 2/3] gnu: Add meson-for-build.
2017-09-13 12:50 ` [bug#28444] [PATCH 1/3] gnu: meson: Update to 0.42.0 Peter Mikkelsen
@ 2017-09-13 12:50 ` Peter Mikkelsen
2017-09-15 20:57 ` Ludovic Courtès
2017-09-13 12:50 ` [bug#28444] [PATCH 3/3] build-system: Add 'meson-build-system' Peter Mikkelsen
2017-09-15 20:53 ` [bug#28444] [PATCH 1/3] gnu: meson: Update to 0.42.0 Ludovic Courtès
2 siblings, 1 reply; 15+ messages in thread
From: Peter Mikkelsen @ 2017-09-13 12:50 UTC (permalink / raw)
To: 28444
* gnu/packages/build-tools.scm (meson-for-build): New variable.
* gnu/packages/patches/meson-for-build-rpath.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
---
gnu/local.mk | 1 +
gnu/packages/build-tools.scm | 15 +++++++++++++++
gnu/packages/patches/meson-for-build-rpath.patch | 24 ++++++++++++++++++++++++
3 files changed, 40 insertions(+)
create mode 100644 gnu/packages/patches/meson-for-build-rpath.patch
diff --git a/gnu/local.mk b/gnu/local.mk
index c1bc39110..cbf98b6e1 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -852,6 +852,7 @@ dist_patch_DATA = \
%D%/packages/patches/mcrypt-CVE-2012-4527.patch \
%D%/packages/patches/mesa-skip-disk-cache-test.patch \
%D%/packages/patches/mesa-wayland-egl-symbols-check-mips.patch \
+ %D%/packages/patches/meson-for-build-rpath.patch \
%D%/packages/patches/metabat-fix-compilation.patch \
%D%/packages/patches/mhash-keygen-test-segfault.patch \
%D%/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch \
diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index 5cc0da55d..a5e416db7 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -93,6 +93,21 @@ files}, are written in a custom domain-specific language (DSL) that resembles
Python.")
(license license:asl2.0)))
+(define-public meson-for-build
+ (package
+ (inherit meson)
+ (name "meson-for-build")
+ (version "0.42.0")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "https://github.com/mesonbuild/meson/"
+ "archive/" version ".tar.gz"))
+ (file-name (string-append name "-" version ".tar.gz"))
+ (sha256
+ (base32
+ "0vyp9rkymzzzilhnf04ryszslyp9a0y0wf4agyijd4w5lcnqlcbc"))
+ (patches (search-patches "meson-for-build-rpath.patch"))))))
+
(define-public premake4
(package
(name "premake")
diff --git a/gnu/packages/patches/meson-for-build-rpath.patch b/gnu/packages/patches/meson-for-build-rpath.patch
new file mode 100644
index 000000000..4e20c9aed
--- /dev/null
+++ b/gnu/packages/patches/meson-for-build-rpath.patch
@@ -0,0 +1,24 @@
+This patch removes a part of meson that clears the rpath upon installation.
+This will only be applied to a special version of meson, used for the
+meson-build-system.
+
+Patch by Peter Mikkelsen <petermikkelsen10@gmail.com>
+
+--- meson-0.42.0/mesonbuild/scripts/meson_install.py.orig 2017-09-09 01:49:39.147374148 +0200
++++ meson-0.42.0/mesonbuild/scripts/meson_install.py 2017-09-09 01:51:01.209134717 +0200
+@@ -345,15 +345,6 @@
+ print("Symlink creation does not work on this platform. "
+ "Skipping all symlinking.")
+ printed_symlink_error = True
+- if is_elf_platform() and os.path.isfile(outname):
+- try:
+- e = depfixer.Elf(outname, False)
+- e.fix_rpath(install_rpath)
+- except SystemExit as e:
+- if isinstance(e.code, int) and e.code == 0:
+- pass
+- else:
+- raise
+
+ def run(args):
+ global install_log_file
--
2.14.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 3/3] build-system: Add 'meson-build-system'.
2017-09-13 12:50 ` [bug#28444] [PATCH 1/3] gnu: meson: Update to 0.42.0 Peter Mikkelsen
2017-09-13 12:50 ` [bug#28444] [PATCH 2/3] gnu: Add meson-for-build Peter Mikkelsen
@ 2017-09-13 12:50 ` Peter Mikkelsen
2017-09-15 21:07 ` Ludovic Courtès
2017-09-15 20:53 ` [bug#28444] [PATCH 1/3] gnu: meson: Update to 0.42.0 Ludovic Courtès
2 siblings, 1 reply; 15+ messages in thread
From: Peter Mikkelsen @ 2017-09-13 12:50 UTC (permalink / raw)
To: 28444
* Makefile.am (MODULES): Add 'guix/build-system/meson.scm' and
'guix/build/meson-build-system.scm'.
* guix/build-system/meson.scm: New file.
* guix/build/meson-build-system.scm: New file.
* doc/guix.texi (Build Systems): Add 'meson-build-system'.
---
Makefile.am | 2 +
doc/guix.texi | 55 ++++++++++++
guix/build-system/meson.scm | 178 ++++++++++++++++++++++++++++++++++++++
guix/build/meson-build-system.scm | 144 ++++++++++++++++++++++++++++++
4 files changed, 379 insertions(+)
create mode 100644 guix/build-system/meson.scm
create mode 100644 guix/build/meson-build-system.scm
diff --git a/Makefile.am b/Makefile.am
index 4c2e77d19..adeb6e621 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -79,6 +79,7 @@ MODULES = \
guix/build-system/dub.scm \
guix/build-system/emacs.scm \
guix/build-system/font.scm \
+ guix/build-system/meson.scm \
guix/build-system/minify.scm \
guix/build-system/asdf.scm \
guix/build-system/glib-or-gtk.scm \
@@ -106,6 +107,7 @@ MODULES = \
guix/build/cmake-build-system.scm \
guix/build/dub-build-system.scm \
guix/build/emacs-build-system.scm \
+ guix/build/meson-build-system.scm \
guix/build/minify-build-system.scm \
guix/build/font-build-system.scm \
guix/build/asdf-build-system.scm \
diff --git a/doc/guix.texi b/doc/guix.texi
index 063369122..16bb20b4a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -3811,6 +3811,61 @@ need to be copied into place. It copies font files to standard
locations in the output directory.
@end defvr
+@defvr {Scheme Variable} meson-build-system
+This variable is exported by @code{(guix build-system meson)}. It
+implements the build procedure for packages that use
+@url{http://mesonbuild.com, meson} as their build system.
+
+It adds both @code{meson} and @code{ninja} to the set of inputs, and they
+can be changed with the parameters @code{#:meson} and @code{#:ninja} if needed.
+The default @code{meson} is @code{meson-for-build} which is special because
+it doesn't clear the @code{RUNPATH} of binaries and libraries when they are
+installed.
+
+The build-system is an extension of @var{gnu-build-system}, but with the
+following phases changed to some specific for meson:
+
+@table @code
+
+@item configure
+The phase runs @code{meson} with the flags specified in
+@code{#:configure-flags}. The flag @code{--build-type} is always set to
+@code{plain} unless something else is specified in @code{#:build-type}.
+
+@item build
+The phase runs @code{ninja} to build the package in parallel by default, but
+this can be changed with @code{#:parallel-build?}.
+
+@item check
+The phase runs @code{ninja} with the target specified in @code{#:test-target},
+which is @var{``test''} by default.
+
+@item install
+The phase runs @code{ninja install} and can not be changed.
+@end table
+
+Apart from that, the build system also adds the following phases:
+
+@table @code
+
+@item fix-runpath
+This phase tries to locate the local directories in the package being build,
+which has libraries that some of the binaries need. If any are found, they will
+be added to the programs @code{RUNPATH}. It is needed because
+@code{meson-for-build} keeps the @code{RUNPATH} of binaries and libraries from
+when they are build, but often that is not the @code{RUNPATH} we want.
+Therefor it is also shrinked to the minimum needed by the program.
+
+@item glib-or-gtk-wrap
+This phase is the phase provided by @var{glib-or-gtk-build-system}, and it
+is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
+
+@item glib-or-gtk-compile-schemas
+This phase is the phase provided by @var{glib-or-gtk-build-system}, and it
+is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
+@end table
+@end defvr
+
Lastly, for packages that do not need anything as sophisticated, a
``trivial'' build system is provided. It is trivial in the sense that
it provides basically no support: it does not pull any implicit inputs,
diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm
new file mode 100644
index 000000000..d66ec760a
--- /dev/null
+++ b/guix/build-system/meson.scm
@@ -0,0 +1,178 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build-system meson)
+ #:use-module (guix store)
+ #:use-module (guix utils)
+ #:use-module (guix derivations)
+ #:use-module (guix search-paths)
+ #:use-module (guix build-system)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix build-system glib-or-gtk)
+ #:use-module (guix packages)
+ #:use-module (ice-9 match)
+ #:export (%meson-build-system-modules
+ meson-build-system))
+
+;; Commentary:
+;;
+;; Standard build procedure for packages using Meson. This is implemented as an
+;; extension of `gnu-build-system', with the option to turn on the glib/gtk
+;; phases from `glib-or-gtk-build-system'.
+;;
+;; Code:
+
+(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))
+
+(define (default-ninja)
+ "Return the default ninja package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((module (resolve-interface '(gnu packages ninja))))
+ (module-ref module 'ninja)))
+
+(define (default-meson)
+ "Return the default meson package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((module (resolve-interface '(gnu packages build-tools))))
+ (module-ref module 'meson-for-build)))
+
+(define (default-patchelf)
+ "Return the default patchelf package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((module (resolve-interface '(gnu packages elf))))
+ (module-ref module 'patchelf)))
+
+(define* (lower name
+ #:key source inputs native-inputs outputs system target
+ (meson (default-meson))
+ (ninja (default-ninja))
+ (glib-or-gtk #f)
+ #:allow-other-keys
+ #:rest arguments)
+ "Return a bag for NAME."
+ (define private-keywords
+ `(#:source #:meson #:ninja #:inputs #:native-inputs #:outputs #:target))
+
+ (and (not target) ;; TODO: add support for cross-compilation.
+ (bag
+ (name name)
+ (system system)
+ (build-inputs `(("meson" ,meson)
+ ("ninja" ,ninja)
+ ;; Add patchelf for (guix build rpath) to work.
+ ("patchelf" ,(default-patchelf))
+ ,@native-inputs))
+ (host-inputs `(,@(if source
+ `(("source" ,source))
+ '())
+ ,@inputs
+ ;; Keep the standard inputs of 'gnu-build-system'.
+ ,@(standard-packages)))
+ (outputs outputs)
+ (build meson-build)
+ (arguments (strip-keyword-arguments private-keywords arguments)))))
+
+(define* (meson-build store name inputs
+ #:key (guile #f)
+ (outputs '("out"))
+ (configure-flags ''())
+ (search-paths '())
+ (build-type "plain")
+ (tests? #t)
+ (test-target "test")
+ (glib-or-gtk? #f)
+ (parallel-build? #t)
+ (parallel-tests? #f)
+ (validate-runpath? #t)
+ (patch-shebangs? #t)
+ (strip-binaries? #t)
+ (strip-flags ''("--strip-debug"))
+ (strip-directories ''("lib" "lib64" "libexec"
+ "bin" "sbin"))
+ (elf-directories ''("lib" "lib64" "libexec"
+ "bin" "sbin"))
+ (phases '(@ (guix build meson-build-system)
+ %standard-phases))
+ (system (%current-system))
+ (imported-modules %meson-build-system-modules)
+ (modules '((guix build meson-build-system)
+ (guix build utils))))
+ "Build SOURCE using MESON, and with INPUTS, assuming that SOURCE
+has a 'meson.build' file."
+ (define builder
+ `(let ((build-phases (if ,glib-or-gtk?
+ ,phases
+ (modify-phases ,phases
+ (delete 'glib-or-gtk-compile-schemas)
+ (delete 'glib-or-gtk-wrap)))))
+ (use-modules ,@modules)
+ (meson-build #:source ,(match (assoc-ref inputs "source")
+ (((? derivation? source))
+ (derivation->output-path source))
+ ((source)
+ source)
+ (source
+ source))
+ #:system ,system
+ #:outputs %outputs
+ #:inputs %build-inputs
+ #:search-paths ',(map search-path-specification->sexp
+ search-paths)
+ #:phases build-phases
+ #:configure-flags ,configure-flags
+ #:build-type ,build-type
+ #:tests? ,tests?
+ #:test-target ,test-target
+ #:parallel-build? ,parallel-build?
+ #:parallel-tests? ,parallel-tests?
+ #:validate-runpath? ,validate-runpath?
+ #:patch-shebangs? ,patch-shebangs?
+ #:strip-binaries? ,strip-binaries?
+ #:strip-flags ,strip-flags
+ #:strip-directories ,strip-directories
+ #:elf-directories ,elf-directories)))
+
+ (define guile-for-build
+ (match guile
+ ((? package?)
+ (package-derivation store guile system #:graft? #f))
+ (#f ; the default
+ (let* ((distro (resolve-interface '(gnu packages commencement)))
+ (guile (module-ref distro 'guile-final)))
+ (package-derivation store guile system #:graft? #f)))))
+
+ (build-expression->derivation store name builder
+ #:system system
+ #:inputs inputs
+ #:modules imported-modules
+ #:outputs outputs
+ #:guile-for-build guile-for-build))
+
+(define meson-build-system
+ (build-system
+ (name 'meson)
+ (description "The standard Meson build system")
+ (lower lower)))
+
+;;; meson.scm ends here
diff --git a/guix/build/meson-build-system.scm b/guix/build/meson-build-system.scm
new file mode 100644
index 000000000..1e544f569
--- /dev/null
+++ b/guix/build/meson-build-system.scm
@@ -0,0 +1,144 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build meson-build-system)
+ #: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)
+ #:use-module (rnrs io ports)
+ #:export (%standard-phases
+ %glib-or-gtk-phases
+ meson-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the standard meson build procedure.
+;;
+;; Code:
+
+(define* (configure #:key outputs configure-flags build-type
+ #:allow-other-keys)
+ "Configure the given package"
+ (let* ((out (assoc-ref outputs "out"))
+ (source-dir (getcwd))
+ (build-dir "../build")
+ (prefix (assoc-ref outputs "out"))
+ (args `(,(string-append "--prefix=" prefix)
+ ,(string-append "--buildtype=" build-type)
+ ,@configure-flags
+ ,source-dir)))
+ (mkdir build-dir)
+ (chdir build-dir)
+ (zero? (apply system* "meson" args))))
+
+(define* (build #:key parallel-build?
+ #:allow-other-keys)
+ "Build a given meson package."
+ (zero? (apply system* "ninja"
+ (if parallel-build?
+ `("-j" ,(number->string (parallel-job-count)))
+ '("-j" "1")))))
+
+(define* (check #:key test-target parallel-tests? tests?
+ #:allow-other-keys)
+ (unless parallel-tests?
+ (setenv "MESON_TESTTHREADS" "1"))
+ (if tests?
+ (zero? (system* "ninja" test-target))
+ (begin
+ (format #t "test suite not run~%")
+ #t)))
+
+(define* (install #:rest args)
+ (zero? (system* "ninja" "install")))
+
+(define* (fix-runpath #:key elf-directories outputs
+ #:allow-other-keys)
+ "Try to make sure all ELF files in ELF-DIRECTORIES are able to find their
+local dependencies in their RUNPATH. Also shrink the RUNPATH to what is needed,
+since alot of directories are left over from meson."
+
+ (define (find-deps dep-name elf-files)
+ "Find the directories (if any) that contains DEP-NAME. The directories
+searched are the ones that ELF-FILES are in."
+ (let* ((matches (filter (lambda (file)
+ (string=? dep-name (basename file)))
+ elf-files)))
+ (map dirname matches)))
+
+ (define (file-needed file)
+ "Return a list of libraries that FILE needs."
+ (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)
+ '())))
+
+ (define (handle-file file elf-files)
+ "If FILE needs any libs that are part of ELF-FILES, the RUNPATH
+is modified accordingly."
+ (let* ((dep-dirs (apply append (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)
+ (let* ((elf-dirnames (map (lambda (subdir)
+ (string-append directory "/" subdir))
+ elf-directories))
+ (excisting-elf-dirs (filter (lambda (dir)
+ (and (file-exists? dir)
+ (file-is-directory? dir)))
+ elf-dirnames))
+ (elf-pred (lambda (name stat)
+ (elf-file? name)))
+ (elf-list (apply append (map (lambda (dir)
+ (find-files dir elf-pred))
+ excisting-elf-dirs))))
+ (for-each (lambda (elf-file)
+ (system* "patchelf" "--shrink-rpath" elf-file)
+ (handle-file elf-file elf-list))
+ elf-list)))))
+ (for-each handle-output outputs)
+ #t)
+
+(define %standard-phases
+ ;; The standard-phases of glib-or-gtk contains a superset of the phases
+ ;; from the gnu-build-system. If the glib-or-gtk? key is #f (the default)
+ ;; then the extra phases will be removed again in (guix build-system meson).
+ (modify-phases glib-or-gtk:%standard-phases
+ (replace 'configure configure)
+ (replace 'build build)
+ (replace 'check check)
+ (replace 'install install)
+ (add-after 'strip 'fix-runpath fix-runpath)))
+
+(define* (meson-build #:key inputs phases
+ #:allow-other-keys #:rest args)
+ "Build the given package, applying all of PHASES in order."
+ (apply gnu:gnu-build #:inputs inputs #:phases phases args))
+
+;;; meson-build-system.scm ends here
--
2.14.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 1/3] gnu: meson: Update to 0.42.0.
2017-09-13 12:50 ` [bug#28444] [PATCH 1/3] gnu: meson: Update to 0.42.0 Peter Mikkelsen
2017-09-13 12:50 ` [bug#28444] [PATCH 2/3] gnu: Add meson-for-build Peter Mikkelsen
2017-09-13 12:50 ` [bug#28444] [PATCH 3/3] build-system: Add 'meson-build-system' Peter Mikkelsen
@ 2017-09-15 20:53 ` Ludovic Courtès
2 siblings, 0 replies; 15+ messages in thread
From: Ludovic Courtès @ 2017-09-15 20:53 UTC (permalink / raw)
To: Peter Mikkelsen; +Cc: 28444
Peter Mikkelsen <petermikkelsen10@gmail.com> skribis:
> * gnu/packages/build-tools.scm (meson): Update to 0.42.0.
> [propagated-inputs]: Add python.
Applied!
^ permalink raw reply [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 2/3] gnu: Add meson-for-build.
2017-09-13 12:50 ` [bug#28444] [PATCH 2/3] gnu: Add meson-for-build Peter Mikkelsen
@ 2017-09-15 20:57 ` Ludovic Courtès
2017-09-15 21:00 ` Peter Mikkelsen
0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2017-09-15 20:57 UTC (permalink / raw)
To: Peter Mikkelsen; +Cc: 28444
[-- Attachment #1: Type: text/plain, Size: 384 bytes --]
Peter Mikkelsen <petermikkelsen10@gmail.com> skribis:
> * gnu/packages/build-tools.scm (meson-for-build): New variable.
> * gnu/packages/patches/meson-for-build-rpath.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Register it.
Applied!
I’ve marked it as “hidden” so that it doesn’t show up in UIs (patch
below). Let me know if you think that’s not OK!
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 629 bytes --]
diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index a5e416db7..c535f5240 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -106,7 +106,10 @@ Python.")
(sha256
(base32
"0vyp9rkymzzzilhnf04ryszslyp9a0y0wf4agyijd4w5lcnqlcbc"))
- (patches (search-patches "meson-for-build-rpath.patch"))))))
+ (patches (search-patches "meson-for-build-rpath.patch"))))
+
+ ;; People should probably install "meson", not "meson-for-build".
+ (properties `((hidden? . #t)))))
(define-public premake4
(package
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 2/3] gnu: Add meson-for-build.
2017-09-15 20:57 ` Ludovic Courtès
@ 2017-09-15 21:00 ` Peter Mikkelsen
0 siblings, 0 replies; 15+ messages in thread
From: Peter Mikkelsen @ 2017-09-15 21:00 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 28444
[-- Attachment #1: Type: text/plain, Size: 540 bytes --]
Den 15. sep. 2017 22.57 skrev "Ludovic Courtès" <ludo@gnu.org>:
Peter Mikkelsen <petermikkelsen10@gmail.com> skribis:
> * gnu/packages/build-tools.scm (meson-for-build): New variable.
> * gnu/packages/patches/meson-for-build-rpath.patch: New file.
> * gnu/local.mk (dist_patch_DATA): Register it.
Applied!
I’ve marked it as “hidden” so that it doesn’t show up in UIs (patch
below). Let me know if you think that’s not OK!
I didn't know that was possible, but it seems like the right thing to do,
thanks :)
[-- Attachment #2: Type: text/html, Size: 1075 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 3/3] build-system: Add 'meson-build-system'.
2017-09-13 12:50 ` [bug#28444] [PATCH 3/3] build-system: Add 'meson-build-system' Peter Mikkelsen
@ 2017-09-15 21:07 ` Ludovic Courtès
2017-09-16 11:08 ` Peter Mikkelsen
0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2017-09-15 21:07 UTC (permalink / raw)
To: Peter Mikkelsen; +Cc: 28444
Peter Mikkelsen <petermikkelsen10@gmail.com> skribis:
> * Makefile.am (MODULES): Add 'guix/build-system/meson.scm' and
> 'guix/build/meson-build-system.scm'.
> * guix/build-system/meson.scm: New file.
> * guix/build/meson-build-system.scm: New file.
> * doc/guix.texi (Build Systems): Add 'meson-build-system'.
Overall LGTM! I have minor questions and comments:
> +(define* (configure #:key outputs configure-flags build-type
> + #:allow-other-keys)
> + "Configure the given package"
Make sure to add a period at the end of sentences. :-)
> +(define* (fix-runpath #:key elf-directories outputs
> + #:allow-other-keys)
ELF-DIRECTORIES should default to a list, probably the empty list (here
it defaults to #f, which cannot work.)
> + "Try to make sure all ELF files in ELF-DIRECTORIES are able to find their
> +local dependencies in their RUNPATH. Also shrink the RUNPATH to what is needed,
> +since alot of directories are left over from meson."
“a lot”
According to this description, half of it corresponds to the
‘validate-runpath’ phase, no?
The second half is the shrink-RUNPATH thing, but can you clarify why it
is needed? Which directories in RUNPATH are “left over from meson”?
> + (define (find-deps dep-name elf-files)
> + "Find the directories (if any) that contains DEP-NAME. The directories
> +searched are the ones that ELF-FILES are in."
> + (let* ((matches (filter (lambda (file)
> + (string=? dep-name (basename file)))
> + elf-files)))
> + (map dirname matches)))
Avoid local variable ‘matches’, to keep it concise. Also, for inner
‘define’s, use a comment instead of a docstring (the docstring would be
inaccessible.)
> + (define (file-needed file)
> + "Return a list of libraries that FILE needs."
> + (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)
> + '())))
> +
> + (define (handle-file file elf-files)
> + "If FILE needs any libs that are part of ELF-FILES, the RUNPATH
> +is modified accordingly."
> + (let* ((dep-dirs (apply append (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
> + (elf-list (apply append (map (lambda (dir)
> + (find-files dir elf-pred))
> + excisting-elf-dirs))))
(apply append lstlst) = (concatenate lstlst)
That’s it! Could you comment and send an updated patch?
Thanks for working on it, looks like it’s going to be useful very soon!
Ludo’.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 3/3] build-system: Add 'meson-build-system'.
2017-09-15 21:07 ` Ludovic Courtès
@ 2017-09-16 11:08 ` Peter Mikkelsen
2017-09-16 16:11 ` bug#28444: " Ludovic Courtès
0 siblings, 1 reply; 15+ messages in thread
From: Peter Mikkelsen @ 2017-09-16 11:08 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 28444
[-- Attachment #1: Type: text/plain, Size: 3912 bytes --]
2017-09-15 23:07 GMT+02:00 Ludovic Courtès <ludo@gnu.org>:
>
> Peter Mikkelsen <petermikkelsen10@gmail.com> skribis:
>
> > * Makefile.am (MODULES): Add 'guix/build-system/meson.scm' and
> > 'guix/build/meson-build-system.scm'.
> > * guix/build-system/meson.scm: New file.
> > * guix/build/meson-build-system.scm: New file.
> > * doc/guix.texi (Build Systems): Add 'meson-build-system'.
>
> Overall LGTM! I have minor questions and comments:
>
> > +(define* (configure #:key outputs configure-flags build-type
> > + #:allow-other-keys)
> > + "Configure the given package"
>
> Make sure to add a period at the end of sentences. :-)
Oops, will do :)
>
> > +(define* (fix-runpath #:key elf-directories outputs
> > + #:allow-other-keys)
>
> ELF-DIRECTORIES should default to a list, probably the empty list (here
> it defaults to #f, which cannot work.)
I thought it was enough giving it a default value in
guix/build-system/meson.scm, but allright, I have added it here.
>
> > + "Try to make sure all ELF files in ELF-DIRECTORIES are able to find their
> > +local dependencies in their RUNPATH. Also shrink the RUNPATH to what is needed,
> > +since alot of directories are left over from meson."
>
> “a lot”
>
> According to this description, half of it corresponds to the
> ‘validate-runpath’ phase, no?
To my understanding 'validate-runpath' just checks and complains, but
this phase checks if it can find any dependencies in directories that
are local to the package, and if it can, it adds them to the runpath.
I have tried to update the description :)
>
> The second half is the shrink-RUNPATH thing, but can you clarify why it
> is needed? Which directories in RUNPATH are “left over from meson”?
I also tried giving an example of that in the new description.
>
> > + (define (find-deps dep-name elf-files)
> > + "Find the directories (if any) that contains DEP-NAME. The directories
> > +searched are the ones that ELF-FILES are in."
> > + (let* ((matches (filter (lambda (file)
> > + (string=? dep-name (basename file)))
> > + elf-files)))
> > + (map dirname matches)))
>
> Avoid local variable ‘matches’, to keep it concise. Also, for inner
> ‘define’s, use a comment instead of a docstring (the docstring would be
> inaccessible.)
>
OK.
> > + (define (file-needed file)
> > + "Return a list of libraries that FILE needs."
> > + (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)
> > + '())))
> > +
> > + (define (handle-file file elf-files)
> > + "If FILE needs any libs that are part of ELF-FILES, the RUNPATH
> > +is modified accordingly."
> > + (let* ((dep-dirs (apply append (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
> > + (elf-list (apply append (map (lambda (dir)
> > + (find-files dir elf-pred))
> > + excisting-elf-dirs))))
>
> (apply append lstlst) = (concatenate lstlst)
>
I assume it is the 'concatenate' from (srfi srfi-1), so I have added
it to the imports
> That’s it! Could you comment and send an updated patch?
>
> Thanks for working on it, looks like it’s going to be useful very soon!
>
> Ludo’.
Updated patch attached, thanks for reviewing!
Peter
[-- Attachment #2: 0001-build-system-Add-meson-build-system.patch --]
[-- Type: text/x-patch, Size: 18373 bytes --]
From 8185c2a154c7473d3b50351246cc83b792ec6a57 Mon Sep 17 00:00:00 2001
From: Peter Mikkelsen <petermikkelsen10@gmail.com>
Date: Wed, 13 Sep 2017 14:37:39 +0200
Subject: [PATCH] build-system: Add 'meson-build-system'.
* Makefile.am (MODULES): Add 'guix/build-system/meson.scm' and
'guix/build/meson-build-system.scm'.
* guix/build-system/meson.scm: New file.
* guix/build/meson-build-system.scm: New file.
* doc/guix.texi (Build Systems): Add 'meson-build-system'.
---
Makefile.am | 2 +
doc/guix.texi | 55 ++++++++++++
guix/build-system/meson.scm | 178 ++++++++++++++++++++++++++++++++++++++
guix/build/meson-build-system.scm | 149 +++++++++++++++++++++++++++++++
4 files changed, 384 insertions(+)
create mode 100644 guix/build-system/meson.scm
create mode 100644 guix/build/meson-build-system.scm
diff --git a/Makefile.am b/Makefile.am
index 4c2e77d19..adeb6e621 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -79,6 +79,7 @@ MODULES = \
guix/build-system/dub.scm \
guix/build-system/emacs.scm \
guix/build-system/font.scm \
+ guix/build-system/meson.scm \
guix/build-system/minify.scm \
guix/build-system/asdf.scm \
guix/build-system/glib-or-gtk.scm \
@@ -106,6 +107,7 @@ MODULES = \
guix/build/cmake-build-system.scm \
guix/build/dub-build-system.scm \
guix/build/emacs-build-system.scm \
+ guix/build/meson-build-system.scm \
guix/build/minify-build-system.scm \
guix/build/font-build-system.scm \
guix/build/asdf-build-system.scm \
diff --git a/doc/guix.texi b/doc/guix.texi
index 063369122..16bb20b4a 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -3811,6 +3811,61 @@ need to be copied into place. It copies font files to standard
locations in the output directory.
@end defvr
+@defvr {Scheme Variable} meson-build-system
+This variable is exported by @code{(guix build-system meson)}. It
+implements the build procedure for packages that use
+@url{http://mesonbuild.com, meson} as their build system.
+
+It adds both @code{meson} and @code{ninja} to the set of inputs, and they
+can be changed with the parameters @code{#:meson} and @code{#:ninja} if needed.
+The default @code{meson} is @code{meson-for-build} which is special because
+it doesn't clear the @code{RUNPATH} of binaries and libraries when they are
+installed.
+
+The build-system is an extension of @var{gnu-build-system}, but with the
+following phases changed to some specific for meson:
+
+@table @code
+
+@item configure
+The phase runs @code{meson} with the flags specified in
+@code{#:configure-flags}. The flag @code{--build-type} is always set to
+@code{plain} unless something else is specified in @code{#:build-type}.
+
+@item build
+The phase runs @code{ninja} to build the package in parallel by default, but
+this can be changed with @code{#:parallel-build?}.
+
+@item check
+The phase runs @code{ninja} with the target specified in @code{#:test-target},
+which is @var{``test''} by default.
+
+@item install
+The phase runs @code{ninja install} and can not be changed.
+@end table
+
+Apart from that, the build system also adds the following phases:
+
+@table @code
+
+@item fix-runpath
+This phase tries to locate the local directories in the package being build,
+which has libraries that some of the binaries need. If any are found, they will
+be added to the programs @code{RUNPATH}. It is needed because
+@code{meson-for-build} keeps the @code{RUNPATH} of binaries and libraries from
+when they are build, but often that is not the @code{RUNPATH} we want.
+Therefor it is also shrinked to the minimum needed by the program.
+
+@item glib-or-gtk-wrap
+This phase is the phase provided by @var{glib-or-gtk-build-system}, and it
+is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
+
+@item glib-or-gtk-compile-schemas
+This phase is the phase provided by @var{glib-or-gtk-build-system}, and it
+is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
+@end table
+@end defvr
+
Lastly, for packages that do not need anything as sophisticated, a
``trivial'' build system is provided. It is trivial in the sense that
it provides basically no support: it does not pull any implicit inputs,
diff --git a/guix/build-system/meson.scm b/guix/build-system/meson.scm
new file mode 100644
index 000000000..d66ec760a
--- /dev/null
+++ b/guix/build-system/meson.scm
@@ -0,0 +1,178 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build-system meson)
+ #:use-module (guix store)
+ #:use-module (guix utils)
+ #:use-module (guix derivations)
+ #:use-module (guix search-paths)
+ #:use-module (guix build-system)
+ #:use-module (guix build-system gnu)
+ #:use-module (guix build-system glib-or-gtk)
+ #:use-module (guix packages)
+ #:use-module (ice-9 match)
+ #:export (%meson-build-system-modules
+ meson-build-system))
+
+;; Commentary:
+;;
+;; Standard build procedure for packages using Meson. This is implemented as an
+;; extension of `gnu-build-system', with the option to turn on the glib/gtk
+;; phases from `glib-or-gtk-build-system'.
+;;
+;; Code:
+
+(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))
+
+(define (default-ninja)
+ "Return the default ninja package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((module (resolve-interface '(gnu packages ninja))))
+ (module-ref module 'ninja)))
+
+(define (default-meson)
+ "Return the default meson package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((module (resolve-interface '(gnu packages build-tools))))
+ (module-ref module 'meson-for-build)))
+
+(define (default-patchelf)
+ "Return the default patchelf package."
+ ;; Lazily resolve the binding to avoid a circular dependency.
+ (let ((module (resolve-interface '(gnu packages elf))))
+ (module-ref module 'patchelf)))
+
+(define* (lower name
+ #:key source inputs native-inputs outputs system target
+ (meson (default-meson))
+ (ninja (default-ninja))
+ (glib-or-gtk #f)
+ #:allow-other-keys
+ #:rest arguments)
+ "Return a bag for NAME."
+ (define private-keywords
+ `(#:source #:meson #:ninja #:inputs #:native-inputs #:outputs #:target))
+
+ (and (not target) ;; TODO: add support for cross-compilation.
+ (bag
+ (name name)
+ (system system)
+ (build-inputs `(("meson" ,meson)
+ ("ninja" ,ninja)
+ ;; Add patchelf for (guix build rpath) to work.
+ ("patchelf" ,(default-patchelf))
+ ,@native-inputs))
+ (host-inputs `(,@(if source
+ `(("source" ,source))
+ '())
+ ,@inputs
+ ;; Keep the standard inputs of 'gnu-build-system'.
+ ,@(standard-packages)))
+ (outputs outputs)
+ (build meson-build)
+ (arguments (strip-keyword-arguments private-keywords arguments)))))
+
+(define* (meson-build store name inputs
+ #:key (guile #f)
+ (outputs '("out"))
+ (configure-flags ''())
+ (search-paths '())
+ (build-type "plain")
+ (tests? #t)
+ (test-target "test")
+ (glib-or-gtk? #f)
+ (parallel-build? #t)
+ (parallel-tests? #f)
+ (validate-runpath? #t)
+ (patch-shebangs? #t)
+ (strip-binaries? #t)
+ (strip-flags ''("--strip-debug"))
+ (strip-directories ''("lib" "lib64" "libexec"
+ "bin" "sbin"))
+ (elf-directories ''("lib" "lib64" "libexec"
+ "bin" "sbin"))
+ (phases '(@ (guix build meson-build-system)
+ %standard-phases))
+ (system (%current-system))
+ (imported-modules %meson-build-system-modules)
+ (modules '((guix build meson-build-system)
+ (guix build utils))))
+ "Build SOURCE using MESON, and with INPUTS, assuming that SOURCE
+has a 'meson.build' file."
+ (define builder
+ `(let ((build-phases (if ,glib-or-gtk?
+ ,phases
+ (modify-phases ,phases
+ (delete 'glib-or-gtk-compile-schemas)
+ (delete 'glib-or-gtk-wrap)))))
+ (use-modules ,@modules)
+ (meson-build #:source ,(match (assoc-ref inputs "source")
+ (((? derivation? source))
+ (derivation->output-path source))
+ ((source)
+ source)
+ (source
+ source))
+ #:system ,system
+ #:outputs %outputs
+ #:inputs %build-inputs
+ #:search-paths ',(map search-path-specification->sexp
+ search-paths)
+ #:phases build-phases
+ #:configure-flags ,configure-flags
+ #:build-type ,build-type
+ #:tests? ,tests?
+ #:test-target ,test-target
+ #:parallel-build? ,parallel-build?
+ #:parallel-tests? ,parallel-tests?
+ #:validate-runpath? ,validate-runpath?
+ #:patch-shebangs? ,patch-shebangs?
+ #:strip-binaries? ,strip-binaries?
+ #:strip-flags ,strip-flags
+ #:strip-directories ,strip-directories
+ #:elf-directories ,elf-directories)))
+
+ (define guile-for-build
+ (match guile
+ ((? package?)
+ (package-derivation store guile system #:graft? #f))
+ (#f ; the default
+ (let* ((distro (resolve-interface '(gnu packages commencement)))
+ (guile (module-ref distro 'guile-final)))
+ (package-derivation store guile system #:graft? #f)))))
+
+ (build-expression->derivation store name builder
+ #:system system
+ #:inputs inputs
+ #:modules imported-modules
+ #:outputs outputs
+ #:guile-for-build guile-for-build))
+
+(define meson-build-system
+ (build-system
+ (name 'meson)
+ (description "The standard Meson build system")
+ (lower lower)))
+
+;;; meson.scm ends here
diff --git a/guix/build/meson-build-system.scm b/guix/build/meson-build-system.scm
new file mode 100644
index 000000000..51542974e
--- /dev/null
+++ b/guix/build/meson-build-system.scm
@@ -0,0 +1,149 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Peter Mikkelsen <petermikkelsen10@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build meson-build-system)
+ #: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)
+ #:use-module (rnrs io ports)
+ #:use-module (srfi srfi-1)
+ #:export (%standard-phases
+ %glib-or-gtk-phases
+ meson-build))
+
+;; Commentary:
+;;
+;; Builder-side code of the standard meson build procedure.
+;;
+;; Code:
+
+(define* (configure #:key outputs configure-flags build-type
+ #:allow-other-keys)
+ "Configure the given package."
+ (let* ((out (assoc-ref outputs "out"))
+ (source-dir (getcwd))
+ (build-dir "../build")
+ (prefix (assoc-ref outputs "out"))
+ (args `(,(string-append "--prefix=" prefix)
+ ,(string-append "--buildtype=" build-type)
+ ,@configure-flags
+ ,source-dir)))
+ (mkdir build-dir)
+ (chdir build-dir)
+ (zero? (apply system* "meson" args))))
+
+(define* (build #:key parallel-build?
+ #:allow-other-keys)
+ "Build a given meson package."
+ (zero? (apply system* "ninja"
+ (if parallel-build?
+ `("-j" ,(number->string (parallel-job-count)))
+ '("-j" "1")))))
+
+(define* (check #:key test-target parallel-tests? tests?
+ #:allow-other-keys)
+ (unless parallel-tests?
+ (setenv "MESON_TESTTHREADS" "1"))
+ (if tests?
+ (zero? (system* "ninja" test-target))
+ (begin
+ (format #t "test suite not run~%")
+ #t)))
+
+(define* (install #:rest args)
+ (zero? (system* "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,
+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)
+ (let* ((elf-dirnames (map (lambda (subdir)
+ (string-append directory "/" subdir))
+ elf-directories))
+ (excisting-elf-dirs (filter (lambda (dir)
+ (and (file-exists? dir)
+ (file-is-directory? dir)))
+ elf-dirnames))
+ (elf-pred (lambda (name stat)
+ (elf-file? name)))
+ (elf-list (concatenate (map (lambda (dir)
+ (find-files dir elf-pred))
+ excisting-elf-dirs))))
+ (for-each (lambda (elf-file)
+ (system* "patchelf" "--shrink-rpath" elf-file)
+ (handle-file elf-file elf-list))
+ elf-list)))))
+ (for-each handle-output outputs)
+ #t)
+
+(define %standard-phases
+ ;; The standard-phases of glib-or-gtk contains a superset of the phases
+ ;; from the gnu-build-system. If the glib-or-gtk? key is #f (the default)
+ ;; then the extra phases will be removed again in (guix build-system meson).
+ (modify-phases glib-or-gtk:%standard-phases
+ (replace 'configure configure)
+ (replace 'build build)
+ (replace 'check check)
+ (replace 'install install)
+ (add-after 'strip 'fix-runpath fix-runpath)))
+
+(define* (meson-build #:key inputs phases
+ #:allow-other-keys #:rest args)
+ "Build the given package, applying all of PHASES in order."
+ (apply gnu:gnu-build #:inputs inputs #:phases phases args))
+
+;;; meson-build-system.scm ends here
--
2.14.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* bug#28444: [PATCH 3/3] build-system: Add 'meson-build-system'.
2017-09-16 11:08 ` Peter Mikkelsen
@ 2017-09-16 16:11 ` Ludovic Courtès
2017-09-16 17:06 ` [bug#28444] " Peter Mikkelsen
0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2017-09-16 16:11 UTC (permalink / raw)
To: Peter Mikkelsen; +Cc: 28444-done
[-- Attachment #1: Type: text/plain, Size: 1377 bytes --]
Hi Peter,
Peter Mikkelsen <petermikkelsen10@gmail.com> skribis:
[...]
>> According to this description, half of it corresponds to the
>> ‘validate-runpath’ phase, no?
>
> To my understanding 'validate-runpath' just checks and complains, but
> this phase checks if it can find any dependencies in directories that
> are local to the package, and if it can, it adds them to the runpath.
> I have tried to update the description :)
I see. Out of curiosity, which libraries did you find to be present in
RUNPATH but not in NEEDED?
I’d consider it a Meson bug (or a bug in how the package uses Meson) if
test libraries are passed as -l when linking non-test binaries.
At any rate, we should implement ‘shrink-runpath’ in (guix build
gremlin) someday!
> From 8185c2a154c7473d3b50351246cc83b792ec6a57 Mon Sep 17 00:00:00 2001
> From: Peter Mikkelsen <petermikkelsen10@gmail.com>
> Date: Wed, 13 Sep 2017 14:37:39 +0200
> Subject: [PATCH] build-system: Add 'meson-build-system'.
>
> * Makefile.am (MODULES): Add 'guix/build-system/meson.scm' and
> 'guix/build/meson-build-system.scm'.
> * guix/build-system/meson.scm: New file.
> * guix/build/meson-build-system.scm: New file.
> * doc/guix.texi (Build Systems): Add 'meson-build-system'.
Pushed with the changes below.
Thank you!
Now to upgrade GNOME? :-)
Ludo’.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 4302 bytes --]
diff --git a/doc/guix.texi b/doc/guix.texi
index 1fee21314..1356a357c 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -3814,16 +3814,16 @@ locations in the output directory.
@defvr {Scheme Variable} meson-build-system
This variable is exported by @code{(guix build-system meson)}. It
implements the build procedure for packages that use
-@url{http://mesonbuild.com, meson} as their build system.
+@url{http://mesonbuild.com, Meson} as their build system.
-It adds both @code{meson} and @code{ninja} to the set of inputs, and they
-can be changed with the parameters @code{#:meson} and @code{#:ninja} if needed.
-The default @code{meson} is @code{meson-for-build} which is special because
-it doesn't clear the @code{RUNPATH} of binaries and libraries when they are
-installed.
+It adds both Meson and @uref{https://ninja-build.org/, Ninja} to the set
+of inputs, and they can be changed with the parameters @code{#:meson}
+and @code{#:ninja} if needed. The default Meson is
+@code{meson-for-build}, which is special because it doesn't clear the
+@code{RUNPATH} of binaries and libraries when they are installed.
-The build-system is an extension of @var{gnu-build-system}, but with the
-following phases changed to some specific for meson:
+This build system is an extension of @var{gnu-build-system}, but with the
+following phases changed to some specific for Meson:
@table @code
@@ -3838,7 +3838,7 @@ this can be changed with @code{#:parallel-build?}.
@item check
The phase runs @code{ninja} with the target specified in @code{#:test-target},
-which is @var{``test''} by default.
+which is @code{"test"} by default.
@item install
The phase runs @code{ninja install} and can not be changed.
@@ -3857,11 +3857,11 @@ when they are build, but often that is not the @code{RUNPATH} we want.
Therefor it is also shrinked to the minimum needed by the program.
@item glib-or-gtk-wrap
-This phase is the phase provided by @var{glib-or-gtk-build-system}, and it
+This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
@item glib-or-gtk-compile-schemas
-This phase is the phase provided by @var{glib-or-gtk-build-system}, and it
+This phase is the phase provided by @code{glib-or-gtk-build-system}, and it
is not enabled by default. It can be enabled with @code{#:glib-or-gtk?}.
@end table
@end defvr
diff --git a/guix/build/meson-build-system.scm b/guix/build/meson-build-system.scm
index 51542974e..2b92240c5 100644
--- a/guix/build/meson-build-system.scm
+++ b/guix/build/meson-build-system.scm
@@ -27,7 +27,6 @@
#:use-module (rnrs io ports)
#:use-module (srfi srfi-1)
#:export (%standard-phases
- %glib-or-gtk-phases
meson-build))
;; Commentary:
@@ -61,8 +60,10 @@
(define* (check #:key test-target parallel-tests? tests?
#:allow-other-keys)
- (unless parallel-tests?
- (setenv "MESON_TESTTHREADS" "1"))
+ (setenv "MESON_TESTTHREADS"
+ (if parallel-tests?
+ (number->string (parallel-job-count))
+ "1"))
(if tests?
(zero? (system* "ninja" test-target))
(begin
@@ -114,7 +115,7 @@ for example libraries only needed for the tests."
(let* ((elf-dirnames (map (lambda (subdir)
(string-append directory "/" subdir))
elf-directories))
- (excisting-elf-dirs (filter (lambda (dir)
+ (existing-elf-dirs (filter (lambda (dir)
(and (file-exists? dir)
(file-is-directory? dir)))
elf-dirnames))
@@ -122,7 +123,7 @@ for example libraries only needed for the tests."
(elf-file? name)))
(elf-list (concatenate (map (lambda (dir)
(find-files dir elf-pred))
- excisting-elf-dirs))))
+ existing-elf-dirs))))
(for-each (lambda (elf-file)
(system* "patchelf" "--shrink-rpath" elf-file)
(handle-file elf-file elf-list))
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 3/3] build-system: Add 'meson-build-system'.
2017-09-16 16:11 ` bug#28444: " Ludovic Courtès
@ 2017-09-16 17:06 ` Peter Mikkelsen
2017-09-17 13:19 ` Ludovic Courtès
0 siblings, 1 reply; 15+ messages in thread
From: Peter Mikkelsen @ 2017-09-16 17:06 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 28444-done
2017-09-16 18:11 GMT+02:00 Ludovic Courtès <ludo@gnu.org>:
>
> Hi Peter,
>
> Peter Mikkelsen <petermikkelsen10@gmail.com> skribis:
>
>
> [...]
>
> >> According to this description, half of it corresponds to the
> >> ‘validate-runpath’ phase, no?
> >
> > To my understanding 'validate-runpath' just checks and complains, but
> > this phase checks if it can find any dependencies in directories that
> > are local to the package, and if it can, it adds them to the runpath.
> > I have tried to update the description :)
>
> I see. Out of curiosity, which libraries did you find to be present in
> RUNPATH but not in NEEDED?
>
I tried building a simple program, and using 'patchelf --print-needed'
i got this:
libuuid.so
libstdc++.so.6
libgcc_s.so.1
libc.so.6
and without the shrinking done, the runpath looks like this:
/gnu/store/8y6wd2rfi6p3gpxcz3p1gyzsbxwyc9ha-uuid-cpp-0.6.5.1/lib:$ORIGIN/:/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/../../..
and with, it looks like this:
/gnu/store/nqdf6kr5cqfqh9z5yprar1yyfqwprj4v-uuid-cpp-0.6.5.1/lib:$ORIGIN/:/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib
So the last part of the old runpath is removed, and looking at the
output of ldd, it seems like it was never needed:
linux-vdso.so.1 (0x00007ffd6cbe2000)
libuuid.so => /gnu/store/8y6wd2rfi6p3gpxcz3p1gyzsbxwyc9ha-uuid-cpp-0.6.5.1/lib/libuuid.so
(0x00007feae61bc000)
libstdc++.so.6 =>
/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/libstdc++.so.6
(0x00007feae5e42000)
libgcc_s.so.1 =>
/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/libgcc_s.so.1
(0x00007feae5c2b000)
libc.so.6 => /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libc.so.6
(0x00007feae588c000)
libm.so.6 => /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libm.so.6
(0x00007feae557a000)
/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/ld-linux-x86-64.so.2
(0x00007feae63c4000)
Now, I am not sure it is worth shrinking, but I just think it is a
little bit strange having unneeded directories in the runpath :)
While trying to build a gnome package, I noticed that the runpath was
huuuge before shrinking, but I don't have that package definition
anymore :/
We can see what happens when we update gnome :)
>
> I’d consider it a Meson bug (or a bug in how the package uses Meson) if
> test libraries are passed as -l when linking non-test binaries.
>
I don't know if this is what is happening, but on their side they
'fix' the runpath before install, which we don't.
If any problem arises I will be happy to give it a look, but in the
mean time, I think this will work :)
> At any rate, we should implement ‘shrink-runpath’ in (guix build
> gremlin) someday!
That would be awesome!
>
> > From 8185c2a154c7473d3b50351246cc83b792ec6a57 Mon Sep 17 00:00:00 2001
> > From: Peter Mikkelsen <petermikkelsen10@gmail.com>
> > Date: Wed, 13 Sep 2017 14:37:39 +0200
> > Subject: [PATCH] build-system: Add 'meson-build-system'.
> >
> > * Makefile.am (MODULES): Add 'guix/build-system/meson.scm' and
> > 'guix/build/meson-build-system.scm'.
> > * guix/build-system/meson.scm: New file.
> > * guix/build/meson-build-system.scm: New file.
> > * doc/guix.texi (Build Systems): Add 'meson-build-system'.
>
> Pushed with the changes below.
>
> Thank you!
>
> Now to upgrade GNOME? :-)
Yes :) I will finish some ongoing Haskell work before giving it a shot
>
> Ludo’.
>
Thanks,
Peter
^ permalink raw reply [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 3/3] build-system: Add 'meson-build-system'.
2017-09-16 17:06 ` [bug#28444] " Peter Mikkelsen
@ 2017-09-17 13:19 ` Ludovic Courtès
2017-09-17 13:24 ` Peter Mikkelsen
2017-09-17 14:01 ` Peter Mikkelsen
0 siblings, 2 replies; 15+ messages in thread
From: Ludovic Courtès @ 2017-09-17 13:19 UTC (permalink / raw)
To: Peter Mikkelsen; +Cc: 28444-done
Hi Peter,
Peter Mikkelsen <petermikkelsen10@gmail.com> skribis:
> and without the shrinking done, the runpath looks like this:
>
> /gnu/store/8y6wd2rfi6p3gpxcz3p1gyzsbxwyc9ha-uuid-cpp-0.6.5.1/lib:$ORIGIN/:/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/../../..
>
> and with, it looks like this:
>
> /gnu/store/nqdf6kr5cqfqh9z5yprar1yyfqwprj4v-uuid-cpp-0.6.5.1/lib:$ORIGIN/:/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib
>
> So the last part of the old runpath is removed, and looking at the
> output of ldd, it seems like it was never needed:
>
> linux-vdso.so.1 (0x00007ffd6cbe2000)
> libuuid.so => /gnu/store/8y6wd2rfi6p3gpxcz3p1gyzsbxwyc9ha-uuid-cpp-0.6.5.1/lib/libuuid.so
> (0x00007feae61bc000)
> libstdc++.so.6 =>
> /gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/libstdc++.so.6
> (0x00007feae5e42000)
> libgcc_s.so.1 =>
> /gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/libgcc_s.so.1
> (0x00007feae5c2b000)
> libc.so.6 => /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libc.so.6
> (0x00007feae588c000)
> libm.so.6 => /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libm.so.6
> (0x00007feae557a000)
> /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/ld-linux-x86-64.so.2
> (0x00007feae63c4000)
>
> Now, I am not sure it is worth shrinking, but I just think it is a
> little bit strange having unneeded directories in the runpath :)
The last element of the RUNPATH above comes from GCC or so. I can’t
hurt and you’ll probably find it on all the binaries we build; it’s not
related to Meson, I think.
So if that’s the only reason for ‘patchelf --shrink-runpath’, I would
argue it’s not a valid one. :-)
> While trying to build a gnome package, I noticed that the runpath was
> huuuge before shrinking, but I don't have that package definition
> anymore :/
Unless you find a more compelling example ;-) as you build packages with
‘meson-build-system’, I’d suggest we eventually revisit this issue and
get rid of ‘fix-runpath’. That would remove the dependency on PatchELF,
which is sometimes a bit fragile.
How does that sound?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 3/3] build-system: Add 'meson-build-system'.
2017-09-17 13:19 ` Ludovic Courtès
@ 2017-09-17 13:24 ` Peter Mikkelsen
2017-09-17 14:01 ` Peter Mikkelsen
1 sibling, 0 replies; 15+ messages in thread
From: Peter Mikkelsen @ 2017-09-17 13:24 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 28444-done
Hi Ludovic
2017-09-17 15:19 GMT+02:00 Ludovic Courtès <ludo@gnu.org>:
>
> Hi Peter,
>
> Peter Mikkelsen <petermikkelsen10@gmail.com> skribis:
>
> > and without the shrinking done, the runpath looks like this:
> >
> > /gnu/store/8y6wd2rfi6p3gpxcz3p1gyzsbxwyc9ha-uuid-cpp-0.6.5.1/lib:$ORIGIN/:/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/../../..
> >
> > and with, it looks like this:
> >
> > /gnu/store/nqdf6kr5cqfqh9z5yprar1yyfqwprj4v-uuid-cpp-0.6.5.1/lib:$ORIGIN/:/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib
> >
> > So the last part of the old runpath is removed, and looking at the
> > output of ldd, it seems like it was never needed:
> >
> > linux-vdso.so.1 (0x00007ffd6cbe2000)
> > libuuid.so => /gnu/store/8y6wd2rfi6p3gpxcz3p1gyzsbxwyc9ha-uuid-cpp-0.6.5.1/lib/libuuid.so
> > (0x00007feae61bc000)
> > libstdc++.so.6 =>
> > /gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/libstdc++.so.6
> > (0x00007feae5e42000)
> > libgcc_s.so.1 =>
> > /gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/libgcc_s.so.1
> > (0x00007feae5c2b000)
> > libc.so.6 => /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libc.so.6
> > (0x00007feae588c000)
> > libm.so.6 => /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libm.so.6
> > (0x00007feae557a000)
> > /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/ld-linux-x86-64.so.2
> > (0x00007feae63c4000)
> >
> > Now, I am not sure it is worth shrinking, but I just think it is a
> > little bit strange having unneeded directories in the runpath :)
>
> The last element of the RUNPATH above comes from GCC or so. I can’t
> hurt and you’ll probably find it on all the binaries we build; it’s not
> related to Meson, I think.
>
> So if that’s the only reason for ‘patchelf --shrink-runpath’, I would
> argue it’s not a valid one. :-)
>
> > While trying to build a gnome package, I noticed that the runpath was
> > huuuge before shrinking, but I don't have that package definition
> > anymore :/
>
> Unless you find a more compelling example ;-) as you build packages with
> ‘meson-build-system’, I’d suggest we eventually revisit this issue and
> get rid of ‘fix-runpath’. That would remove the dependency on PatchELF,
> which is sometimes a bit fragile.
>
> How does that sound?
>
That sounds good to me :)
> Thanks,
> Ludo’.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 3/3] build-system: Add 'meson-build-system'.
2017-09-17 13:19 ` Ludovic Courtès
2017-09-17 13:24 ` Peter Mikkelsen
@ 2017-09-17 14:01 ` Peter Mikkelsen
2017-09-17 19:21 ` Ludovic Courtès
1 sibling, 1 reply; 15+ messages in thread
From: Peter Mikkelsen @ 2017-09-17 14:01 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 28444-done
2017-09-17 15:19 GMT+02:00 Ludovic Courtès <ludo@gnu.org>:
> Hi Peter,
>
> Peter Mikkelsen <petermikkelsen10@gmail.com> skribis:
>
>> and without the shrinking done, the runpath looks like this:
>>
>> /gnu/store/8y6wd2rfi6p3gpxcz3p1gyzsbxwyc9ha-uuid-cpp-0.6.5.1/lib:$ORIGIN/:/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/../../..
>>
>> and with, it looks like this:
>>
>> /gnu/store/nqdf6kr5cqfqh9z5yprar1yyfqwprj4v-uuid-cpp-0.6.5.1/lib:$ORIGIN/:/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib
>>
>> So the last part of the old runpath is removed, and looking at the
>> output of ldd, it seems like it was never needed:
>>
>> linux-vdso.so.1 (0x00007ffd6cbe2000)
>> libuuid.so => /gnu/store/8y6wd2rfi6p3gpxcz3p1gyzsbxwyc9ha-uuid-cpp-0.6.5.1/lib/libuuid.so
>> (0x00007feae61bc000)
>> libstdc++.so.6 =>
>> /gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/libstdc++.so.6
>> (0x00007feae5e42000)
>> libgcc_s.so.1 =>
>> /gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/libgcc_s.so.1
>> (0x00007feae5c2b000)
>> libc.so.6 => /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libc.so.6
>> (0x00007feae588c000)
>> libm.so.6 => /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libm.so.6
>> (0x00007feae557a000)
>> /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/ld-linux-x86-64.so.2
>> (0x00007feae63c4000)
>>
>> Now, I am not sure it is worth shrinking, but I just think it is a
>> little bit strange having unneeded directories in the runpath :)
>
> The last element of the RUNPATH above comes from GCC or so. I can’t
> hurt and you’ll probably find it on all the binaries we build; it’s not
> related to Meson, I think.
>
> So if that’s the only reason for ‘patchelf --shrink-runpath’, I would
> argue it’s not a valid one. :-)
>
>> While trying to build a gnome package, I noticed that the runpath was
>> huuuge before shrinking, but I don't have that package definition
>> anymore :/
>
> Unless you find a more compelling example ;-) as you build packages with
> ‘meson-build-system’, I’d suggest we eventually revisit this issue and
> get rid of ‘fix-runpath’. That would remove the dependency on PatchELF,
> which is sometimes a bit fragile.
>
> How does that sound?
>
> Thanks,
> Ludo’.
I just tried building nautilus 3.26.0 and without the shrinking done,
the nautilus binary has the following rpath:
/gnu/store/xw2zvqd6q2gf2pj9y3xvgk4y2fnk5nna-nautilus-3.26.0/lib:$ORIGIN/../libnautilus-extension:/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib:/gnu/store/12zbd0c57gb79gyfx8xwqiv6pyj3i0q6-glib-2.52.2/lib:/gnu/store/b8lcaqx0rkfnd3xbvqy5lr879fyk5x3q-gtk+-3.22.15/lib:/gnu/store/ssgjajkyc4az3akaham2azyq7gs9cl37-pango-1.40.6/lib:/gnu/store/rcs3yji9vi2lmm22lmxk54jnhch2jry9-atk-2.24.0/lib:/gnu/store/1fzljsi7ksngzq2g66lcvwjadfxnplkh-cairo-1.14.8/lib:/gnu/store/w7rxc4g47k2i6f8zrxnlsvajm5vz4r68-gdk-pixbuf+svg-2.36.6/lib:/gnu/store/q0aya45mp1y1hk8i2wx4jgr0y81j8pi3-gnome-autoar-0.2.2/lib:/gnu/store/13980g3067dcx7hw6m766qlhagj1vfck-libarchive-3.3.1/lib:/gnu/store/kwzs8k97qy7avxxldnzavlii9zphh3d6-libxml2-2.9.4/lib:/gnu/store/h4vf97f7fxjzqwhds2xccmk4ahr1009q-gnome-desktop-3.24.2/lib:/gnu/store/np05q8mf1y9y4bk5y4ssj99m0dss2b1q-libx11-1.6.5/lib:/gnu/store/mw7hxaz7k5amabk8g2gr5akyrvvm1pmf-tracker-1.12.3/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/../../..
And with shrinking this:
/gnu/store/c0jkvchpxs3qfkai8cgz2d65xzhlhwb6-nautilus-3.26.0/lib:$ORIGIN/../libnautilus-extension:/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib:/gnu/store/12zbd0c57gb79gyfx8xwqiv6pyj3i0q6-glib-2.52.2/lib:/gnu/store/b8lcaqx0rkfnd3xbvqy5lr879fyk5x3q-gtk+-3.22.15/lib:/gnu/store/ssgjajkyc4az3akaham2azyq7gs9cl37-pango-1.40.6/lib:/gnu/store/rcs3yji9vi2lmm22lmxk54jnhch2jry9-atk-2.24.0/lib:/gnu/store/1fzljsi7ksngzq2g66lcvwjadfxnplkh-cairo-1.14.8/lib:/gnu/store/w7rxc4g47k2i6f8zrxnlsvajm5vz4r68-gdk-pixbuf+svg-2.36.6/lib:/gnu/store/q0aya45mp1y1hk8i2wx4jgr0y81j8pi3-gnome-autoar-0.2.2/lib:/gnu/store/h4vf97f7fxjzqwhds2xccmk4ahr1009q-gnome-desktop-3.24.2/lib:/gnu/store/np05q8mf1y9y4bk5y4ssj99m0dss2b1q-libx11-1.6.5/lib:/gnu/store/mw7hxaz7k5amabk8g2gr5akyrvvm1pmf-tracker-1.12.3/lib
This means that the following directories are unneeded but still in
the RUNPATH for some reason:
/gnu/store/13980g3067dcx7hw6m766qlhagj1vfck-libarchive-3.3.1/lib:/gnu/store/kwzs8k97qy7avxxldnzavlii9zphh3d6-libxml2-2.9.4/lib
:)
Peter
^ permalink raw reply [flat|nested] 15+ messages in thread
* [bug#28444] [PATCH 3/3] build-system: Add 'meson-build-system'.
2017-09-17 14:01 ` Peter Mikkelsen
@ 2017-09-17 19:21 ` Ludovic Courtès
0 siblings, 0 replies; 15+ messages in thread
From: Ludovic Courtès @ 2017-09-17 19:21 UTC (permalink / raw)
To: Peter Mikkelsen; +Cc: 28444-done
Heya,
Peter Mikkelsen <petermikkelsen10@gmail.com> skribis:
> I just tried building nautilus 3.26.0 and without the shrinking done,
> the nautilus binary has the following rpath:
>
> /gnu/store/xw2zvqd6q2gf2pj9y3xvgk4y2fnk5nna-nautilus-3.26.0/lib:$ORIGIN/../libnautilus-extension:/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib:/gnu/store/12zbd0c57gb79gyfx8xwqiv6pyj3i0q6-glib-2.52.2/lib:/gnu/store/b8lcaqx0rkfnd3xbvqy5lr879fyk5x3q-gtk+-3.22.15/lib:/gnu/store/ssgjajkyc4az3akaham2azyq7gs9cl37-pango-1.40.6/lib:/gnu/store/rcs3yji9vi2lmm22lmxk54jnhch2jry9-atk-2.24.0/lib:/gnu/store/1fzljsi7ksngzq2g66lcvwjadfxnplkh-cairo-1.14.8/lib:/gnu/store/w7rxc4g47k2i6f8zrxnlsvajm5vz4r68-gdk-pixbuf+svg-2.36.6/lib:/gnu/store/q0aya45mp1y1hk8i2wx4jgr0y81j8pi3-gnome-autoar-0.2.2/lib:/gnu/store/13980g3067dcx7hw6m766qlhagj1vfck-libarchive-3.3.1/lib:/gnu/store/kwzs8k97qy7avxxldnzavlii9zphh3d6-libxml2-2.9.4/lib:/gnu/store/h4vf97f7fxjzqwhds2xccmk4ahr1009q-gnome-desktop-3.24.2/lib:/gnu/store/np05q8mf1y9y4bk5y4ssj99m0dss2b1q-libx11-1.6.5/lib:/gnu/store/mw7hxaz7k5amabk8g2gr5akyrvvm1pmf-tracker-1.12.3/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/../../..
>
> And with shrinking this:
>
> /gnu/store/c0jkvchpxs3qfkai8cgz2d65xzhlhwb6-nautilus-3.26.0/lib:$ORIGIN/../libnautilus-extension:/gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib:/gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib:/gnu/store/12zbd0c57gb79gyfx8xwqiv6pyj3i0q6-glib-2.52.2/lib:/gnu/store/b8lcaqx0rkfnd3xbvqy5lr879fyk5x3q-gtk+-3.22.15/lib:/gnu/store/ssgjajkyc4az3akaham2azyq7gs9cl37-pango-1.40.6/lib:/gnu/store/rcs3yji9vi2lmm22lmxk54jnhch2jry9-atk-2.24.0/lib:/gnu/store/1fzljsi7ksngzq2g66lcvwjadfxnplkh-cairo-1.14.8/lib:/gnu/store/w7rxc4g47k2i6f8zrxnlsvajm5vz4r68-gdk-pixbuf+svg-2.36.6/lib:/gnu/store/q0aya45mp1y1hk8i2wx4jgr0y81j8pi3-gnome-autoar-0.2.2/lib:/gnu/store/h4vf97f7fxjzqwhds2xccmk4ahr1009q-gnome-desktop-3.24.2/lib:/gnu/store/np05q8mf1y9y4bk5y4ssj99m0dss2b1q-libx11-1.6.5/lib:/gnu/store/mw7hxaz7k5amabk8g2gr5akyrvvm1pmf-tracker-1.12.3/lib
>
> This means that the following directories are unneeded but still in
> the RUNPATH for some reason:
>
> /gnu/store/13980g3067dcx7hw6m766qlhagj1vfck-libarchive-3.3.1/lib:/gnu/store/kwzs8k97qy7avxxldnzavlii9zphh3d6-libxml2-2.9.4/lib
Interesting. Do you see in the build log where it comes from? There
are two ways an entry can be added to the RUNPATH: (1) via an explicit
“-Wl,-rpath” flag, or (2) via “-lfoo”, which ld-wrapper converts to
“-lfoo -Wl,-rpath=…”.
Thanks for investigating!
Ludo’.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2017-09-17 19:22 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-13 12:48 [bug#28444] [PATCH 0/3] Add meson-build-system Peter Mikkelsen
2017-09-13 12:50 ` [bug#28444] [PATCH 1/3] gnu: meson: Update to 0.42.0 Peter Mikkelsen
2017-09-13 12:50 ` [bug#28444] [PATCH 2/3] gnu: Add meson-for-build Peter Mikkelsen
2017-09-15 20:57 ` Ludovic Courtès
2017-09-15 21:00 ` Peter Mikkelsen
2017-09-13 12:50 ` [bug#28444] [PATCH 3/3] build-system: Add 'meson-build-system' Peter Mikkelsen
2017-09-15 21:07 ` Ludovic Courtès
2017-09-16 11:08 ` Peter Mikkelsen
2017-09-16 16:11 ` bug#28444: " Ludovic Courtès
2017-09-16 17:06 ` [bug#28444] " Peter Mikkelsen
2017-09-17 13:19 ` Ludovic Courtès
2017-09-17 13:24 ` Peter Mikkelsen
2017-09-17 14:01 ` Peter Mikkelsen
2017-09-17 19:21 ` Ludovic Courtès
2017-09-15 20:53 ` [bug#28444] [PATCH 1/3] gnu: meson: Update to 0.42.0 Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.