diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm index 999ac1875e..a6d40c7f9e 100644 --- a/gnu/packages/embedded.scm +++ b/gnu/packages/embedded.scm @@ -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"))))) diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index c1c125764f..765ab794ff 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -3,7 +3,7 @@ ;;; Copyright © 2014, 2015, 2018 Mark H Weaver ;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2021 Ricardo Wurmus ;;; Copyright © 2015, 2023 Andreas Enge -;;; Copyright © 2015-2018, 2020-2024 Efraim Flashner +;;; Copyright © 2015-2018, 2020-2025 Efraim Flashner ;;; Copyright © 2016 Carlos Sánchez de La Lama ;;; Copyright © 2018 Tobias Geerinckx-Rice ;;; Copyright © 2018, 2020, 2022 Marius Bakke @@ -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 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.") ;; . ("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").