aboutsummaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2023-03-03 22:37:40 +0100
committerLudovic Courtès <ludo@gnu.org>2023-03-03 22:37:40 +0100
commit0aed5bf5120bd434e53be0cea3f96547f95837d6 (patch)
treed1abc3a4c54f8dbc79fe663c394bf1d4adde595d /gnu
parentf073a850c9aef581dfc03694db23bdc4f170bc1a (diff)
downloadguix-0aed5bf5120bd434e53be0cea3f96547f95837d6.tar
guix-0aed5bf5120bd434e53be0cea3f96547f95837d6.tar.gz
gnu: gcc@4.9, gcc@5.5: Build with '-std=c++11'.
These two compilers would fail to build with GCC 11.3.0 because it defaults to C++17, which triggers some incompatibilities. * gnu/packages/gcc.scm (gcc-4.7)[arguments]: Augment #:configure-flags for 4.9 and 5.0. (gcc-4.9)[arguments]: Define 'parent' so that (package-arguments parent) correctly evaluates the version-dependent parts.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/packages/gcc.scm65
1 files changed, 40 insertions, 25 deletions
diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index 6f7bebb6a7..d002545f8f 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -182,7 +182,16 @@ where the OS part is overloaded to denote a specific ABI---into GCC
(arguments
`(#:out-of-source? #t
- #:configure-flags ,(configure-flags)
+ #:configure-flags ,(let ((flags (configure-flags))
+ (version (package-version this-package)))
+ ;; GCC 4.9 and 5.0 requires C++11 but GCC
+ ;; 11.3.0 defaults to C++17, which is partly
+ ;; incompatible. Force C++11.
+ (if (or (version-prefix? "4.9" version)
+ (version-prefix? "5" version))
+ `(cons "CXX=g++ -std=c++11" ,flags)
+ flags))
+
#:make-flags
;; None of the flags below are needed when doing a Canadian cross.
;; TODO: Simplify this.
@@ -439,30 +448,36 @@ Go. It also includes runtime support libraries for these languages.")
(native-inputs (list perl ;for manpages
texinfo))
(arguments
- (if (%current-target-system)
- (package-arguments gcc-4.8)
- ;; For native builds of GCC 4.9 and GCC 5, the C++ include path needs
- ;; to be adjusted so it does not interfere with GCC's own build processes.
- (substitute-keyword-arguments (package-arguments gcc-4.8)
- ((#:modules modules %gnu-build-system-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"))))))))))))
+ ;; 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-4.8)
+ (version (package-version this-package)))))
+ (if (%current-target-system)
+ (package-arguments parent)
+ ;; For native builds of GCC 4.9 and GCC 5, 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 %gnu-build-system-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")))))))))))))
(define gcc-canadian-cross-objdump-snippet
;; Fix 'libcc1/configure' error when cross-compiling GCC. Without that,