~ruther/guix-local

d32153f736bd655b4c06d32a405062531c908077 — Efraim Flashner 1 year, 2 months ago fd76ee0
gnu: gcc-4.7: Break out into its own package.

* gnu/packages/gcc.scm (gcc-4.7): Rename to gcc-base.
(gcc-4.7): New package, inherit from gcc-base.
[source]: Add snippet to fix building with newer glibc.
[arguments]: Add phase to adjust the C++ include path when not
cross-building.
[supported-systems]: Update supported systems.
(gcc-4.8, gcc-4.9, gcc-6): Inherit from gcc-base.
(base-gcc)[supported-systems]: Remove field.
* gnu/packages/embedded.scm (make-propeller-gcc-4): Inherit from
gcc-base.

Change-Id: I843049420e2afcf1ea342e87eaa9ac46576e4307
Signed-off-by: Efraim Flashner <efraim@flashner.co.il>
2 files changed, 67 insertions(+), 10 deletions(-)

M gnu/packages/embedded.scm
M gnu/packages/gcc.scm
M gnu/packages/embedded.scm => gnu/packages/embedded.scm +1 -1
@@ 1142,7 1142,7 @@ with a layered architecture of JTAG interface and TAP support.")
                  (patch-flags (list "-p1" "--directory=gcc"))
                  (patches
                   (append
                    (origin-patches (package-source gcc-4.7))
                    (origin-patches (package-source gcc-base))
                    (search-patches
                     "gcc-4.6-gnu-inline.patch"
                     "gcc-cross-environment-variables.patch")))))

M gnu/packages/gcc.scm => gnu/packages/gcc.scm +66 -9
@@ 3,7 3,7 @@
;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2021 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2015, 2023 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2015-2018, 2020-2024 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2015-2018, 2020-2025 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2016 Carlos Sánchez de La Lama <csanchezdll@gmail.com>
;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
;;; Copyright © 2018, 2020, 2022 Marius Bakke <marius@gnu.org>


@@ 110,7 110,7 @@ where the OS part is overloaded to denote a specific ABI---into GCC
         ;; TODO: Add `arm.*-gnueabi', etc.
         '())))

(define-public gcc-4.7
(define-public gcc-base
  (let* ((stripped? #t)      ;whether to strip the compiler, not the libraries
         (maybe-target-tools
          (lambda ()


@@ 413,11 413,68 @@ exec \"$@\" \
for several languages, including C, C++, Objective-C, Fortran, Java, Ada, and
Go.  It also includes runtime support libraries for these languages.")
       (license gpl3+)
       (supported-systems (delete "aarch64-linux" %supported-systems))
       (home-page "https://gcc.gnu.org/")))))

(define-public gcc-4.7
  (package (inherit gcc-base)
    (version "4.7.4")
    (source (origin
              (method url-fetch)
              (uri (string-append "mirror://gnu/gcc/gcc-"
                                  version "/gcc-" version ".tar.bz2"))
              (sha256
               (base32
                "10k2k71kxgay283ylbbhhs51cl55zn2q38vj5pk4k950qdnirrlj"))
              (patches (search-patches "gcc-4-compile-with-gcc-5.patch"
                                       "gcc-fix-texi2pod.patch"))
              (modules '((guix build utils)))
              ;; This is required for building with glibc-2.26.
              ;; https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81712
              (snippet
               '(for-each
                 (lambda (dir)
                   (substitute* (string-append "libgcc/config/"
                                               dir "/linux-unwind.h")
                     (("struct ucontext") "ucontext_t")))
                 '("alpha" "bfin" "i386" "m68k"
                   "pa" "sh" "tilepro" "xtensa")))))
    (arguments
     ;; Since 'arguments' is a function of the package's version, define
     ;; 'parent' such that the 'arguments' thunk gets to see the right
     ;; version.
     (let ((parent (package
                     (inherit gcc-base)
                     (version (package-version this-package)))))
       (if (%current-target-system)
           (package-arguments parent)
           ;; For native builds of some GCC versions the C++ include path needs to
           ;; be adjusted so it does not interfere with GCC's own build processes.
           (substitute-keyword-arguments (package-arguments parent)
             ((#:modules modules %default-gnu-modules)
              `((srfi srfi-1)
                ,@modules))
             ((#:phases phases)
              `(modify-phases ,phases
                 (add-after 'set-paths 'adjust-CPLUS_INCLUDE_PATH
                   (lambda* (#:key inputs #:allow-other-keys)
                     (let ((libc (assoc-ref inputs "libc"))
                           (gcc (assoc-ref inputs  "gcc")))
                       (setenv "CPLUS_INCLUDE_PATH"
                               (string-join (fold delete
                                                  (string-split (getenv "CPLUS_INCLUDE_PATH")
                                                                #\:)
                                                  (list (string-append libc "/include")
                                                        (string-append gcc "/include/c++")))
                                            ":"))
                       (format #t
                               "environment variable `CPLUS_INCLUDE_PATH' changed to ~a~%"
                               (getenv "CPLUS_INCLUDE_PATH")))))))))))
    (supported-systems (fold delete %supported-systems
                             '("aarch64-linux" "riscv64-linux"
                               "powerpc64le-linux" "x86_64-gnu")))))

(define-public gcc-4.8
  (package (inherit gcc-4.7)
  (package (inherit gcc-base)
    (version "4.8.5")
    (source (origin
              (method url-fetch)


@@ 446,7 503,7 @@ Go.  It also includes runtime support libraries for these languages.")
     ;; 'parent' such that the 'arguments' thunk gets to see the right
     ;; version.
     (let ((parent (package
                     (inherit gcc-4.7)
                     (inherit gcc-base)
                     (version (package-version this-package)))))
       (if (%current-target-system)
           (package-arguments parent)


@@ 474,7 531,7 @@ Go.  It also includes runtime support libraries for these languages.")
                               (getenv "CPLUS_INCLUDE_PATH")))))))))))
    (supported-systems %supported-systems)
    (inputs
     (modify-inputs (package-inputs gcc-4.7)
     (modify-inputs (package-inputs gcc-base)
       (prepend isl-0.11 cloog)))))

(define-public gcc-4.9


@@ 550,7 607,7 @@ Go.  It also includes runtime support libraries for these languages.")
              (modules '((guix build utils)))
              (snippet gcc-canadian-cross-objdump-snippet)))
    (inputs
     (modify-inputs (package-inputs gcc-4.7)
     (modify-inputs (package-inputs gcc-base)
       (prepend ;; GCC5 needs <isl/band.h> which is removed in later versions.
                isl-0.18)))))



@@ 573,7 630,7 @@ Go.  It also includes runtime support libraries for these languages.")
                                       "gcc-5.0-libvtv-runpath.patch"))))

    ;; GCC 4.9 and 5 has a workaround that is not needed for GCC 6 and later.
    (arguments (package-arguments gcc-4.7))
    (arguments (package-arguments gcc-base))

    (inputs
     `(("isl" ,isl)


@@ 583,7 640,7 @@ Go.  It also includes runtime support libraries for these languages.")
       ;; <https://bugs.gnu.org/42392>.
       ("libstdc++" ,(make-libstdc++-headers this-package))

       ,@(package-inputs gcc-4.7)))))
       ,@(package-inputs gcc-base)))))

(define %gcc-7.5-aarch64-micro-architectures
  ;; Suitable '-march' values for GCC 7.5 (info "(gcc) AArch64 Options").