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.
This commit is contained in:
Mathieu Othacehe 2020-03-14 11:39:52 +01:00
parent 2e9c43aa9a
commit 53de3e74fa
No known key found for this signature in database
GPG key ID: 8354763531769CA6
3 changed files with 1083 additions and 22 deletions

View file

@ -14,7 +14,7 @@
# Copyright © 2016, 2017, 2018, 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
# Copyright © 2017, 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
# Copyright © 2017, 2018 Clément Lassieur <clement@lassieur.org>
# Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
# Copyright © 2017, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
# Copyright © 2017, 2018, 2019 Gábor Boskovits <boskovits@gmail.com>
# Copyright © 2018 Amirouche Boubekki <amirouche@hypermove.net>
# Copyright © 2018, 2019, 2020 Oleg Pykhalov <go.wigust@gmail.com>
@ -918,6 +918,7 @@ dist_patch_DATA = \
%D%/packages/patches/gcc-6-source-date-epoch-2.patch \
%D%/packages/patches/gcc-7-cross-mingw.patch \
%D%/packages/patches/gcc-7-cross-environment-variables.patch \
%D%/packages/patches/gcc-7-cross-toolexeclibdir.patch \
%D%/packages/patches/gcc-8-cross-environment-variables.patch \
%D%/packages/patches/gcc-8-strmov-store-file-names.patch \
%D%/packages/patches/gcc-9-asan-fix-limits-include.patch \

View file

@ -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 @@ (define (cross-gcc-arguments target xgcc libc)
"--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 @@ (define (cross-gcc-patches xgcc target)
(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 @@ (define* (cross-gcc target
(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))))
(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))))
;; For simplicity, use a single output. Otherwise libgcc_s & co. are not
;; found by default, etc.
(outputs '("out"))
(outputs '("out" "lib"))
(arguments
`(#:implicit-inputs? #f

File diff suppressed because it is too large Load diff