summary refs log tree commit diff
path: root/gnu/packages/cross-base.scm
diff options
context:
space:
mode:
authorMathieu Othacehe <m.othacehe@gmail.com>2020-03-14 11:39:52 +0100
committerMathieu Othacehe <m.othacehe@gmail.com>2020-03-24 13:55:10 +0100
commit53de3e74fac862bc07de160e8e226372de213dd1 (patch)
tree886b2053117b1d66524d07b2099c7924e5dad6d6 /gnu/packages/cross-base.scm
parent2e9c43aa9adac2bd6bcf92373d1cf9f322afa5a3 (diff)
downloadguix-53de3e74fac862bc07de160e8e226372de213dd1.tar.gz
gnu: cross-gcc: Add a "lib" output.
Add a "lib" output to cross-gcc. This requires an upstream GCC patch adding
support for --with-toolexeclibdir configure option. This option allows to
install cross-built GCC libraries in a specific location.

This also fixes the computation of TOOLDIR_BASE_PREFIX, that fails when
/gnu/store/... directories are involved.

* gnu/packages/patches/gcc-7-cross-toolexeclibdir.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/cross-base.scm (cross-gcc)[source]: Apply it,
[outputs]: add a "lib" output,
(cross-gcc-snippet): fix TOOLDIR_BASE_PREFIX.
Diffstat (limited to 'gnu/packages/cross-base.scm')
-rw-r--r--gnu/packages/cross-base.scm63
1 files changed, 41 insertions, 22 deletions
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 667d1f786a..6f72653762 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2019, 2020 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2019 Carl Dong <contact@carldong.me>
+;;; Copyright © 2020 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -162,6 +163,13 @@ base compiler and using LIBC (which may be either a libc package or #f.)"
                                "--disable-libsanitizer"
                                 ))
 
+                       ;; Install cross-built libraries such as libgcc_s.so in
+                       ;; the "lib" output.
+                       ,@(if libc
+                             `((string-append "--with-toolexeclibdir="
+                                              (assoc-ref %outputs "lib")
+                                              "/" ,target "/lib"))
+                             '())
                        ;; For a newlib (non-glibc) target
                        ,@(if (cross-newlib? target)
                              '("--with-newlib")
@@ -196,12 +204,19 @@ base compiler and using LIBC (which may be either a libc package or #f.)"
 
 (define (cross-gcc-snippet target)
   "Return GCC snippet needed for TARGET."
-  (cond ((target-mingw? target)
-         '(begin
-            (copy-recursively "libstdc++-v3/config/os/mingw32-w64"
-                              "libstdc++-v3/config/os/newlib")
-            #t))
-        (else #f)))
+  `(begin
+     ,@(if (target-mingw? target)
+           '((copy-recursively "libstdc++-v3/config/os/mingw32-w64"
+                               "libstdc++-v3/config/os/newlib"))
+           '())
+     ;; TOOLDIR_BASE_PREFIX is erroneous when using a separate "lib"
+     ;; output. Specify it correctly, otherwise GCC won't find its shared
+     ;; libraries installed in the "lib" output.  See:
+     ;; https://lists.gnu.org/archive/html/bug-guix/2020-03/msg00196.html.
+     (substitute* "gcc/Makefile.in"
+       (("-DTOOLDIR_BASE_PREFIX=[^ ]*")
+        "-DTOOLDIR_BASE_PREFIX=\\\"../../../../\\\""))
+     #t))
 
 (define* (cross-gcc target
                     #:key
@@ -216,22 +231,26 @@ target that libc."
     (name (string-append "gcc-cross-"
                          (if libc "" "sans-libc-")
                          target))
-    (source (origin (inherit (package-source xgcc))
-              (patches
-               (append
-                (origin-patches (package-source xgcc))
-                (cons (cond
-                       ((version>=? (package-version xgcc) "8.0") (search-patch "gcc-8-cross-environment-variables.patch"))
-                       ((version>=? (package-version xgcc) "6.0") (search-patch "gcc-6-cross-environment-variables.patch"))
-                       (else  (search-patch "gcc-cross-environment-variables.patch")))
-                      (cross-gcc-patches xgcc target))))
-              (modules '((guix build utils)))
-              (snippet
-               (cross-gcc-snippet target))))
-
-    ;; For simplicity, use a single output.  Otherwise libgcc_s & co. are not
-    ;; found by default, etc.
-    (outputs '("out"))
+    (source
+     (origin
+       (inherit (package-source xgcc))
+       (patches
+        (append
+         (origin-patches (package-source xgcc))
+         (append (cond
+                  ((version>=? (package-version xgcc) "8.0")
+                   (search-patches "gcc-8-cross-environment-variables.patch"))
+                  ((version>=? (package-version xgcc) "6.0")
+                   (search-patches "gcc-7-cross-toolexeclibdir.patch"
+                                   "gcc-6-cross-environment-variables.patch"))
+                  (else
+                   (search-patches "gcc-cross-environment-variables.patch")))
+                 (cross-gcc-patches xgcc target))))
+       (modules '((guix build utils)))
+       (snippet
+        (cross-gcc-snippet target))))
+
+    (outputs '("out" "lib"))
 
     (arguments
      `(#:implicit-inputs? #f