diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm index 178ea20420..ed7bb5d682 100644 --- a/gnu/packages/gcc.scm +++ b/gnu/packages/gcc.scm @@ -293,8 +293,16 @@ (define-public gcc-4.7 %standard-phases)))) (native-search-paths + ;; Use the language-specific variables rather than 'CPATH' because they + ;; are equivalent to '-isystem' whereas 'CPATH' is equivalent to '-I'. + ;; The intent is to allow headers that are in the search path to be + ;; treated as "system headers" (headers exempt from warnings) just like + ;; the typical /usr/include headers on an FHS system. (list (search-path-specification - (variable "CPATH") + (variable "C_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CPLUS_INCLUDE_PATH") (files '("include"))) (search-path-specification (variable "LIBRARY_PATH") @@ -408,13 +416,18 @@ (define (make-libiberty gcc) (define-public libiberty (make-libiberty gcc)) -(define* (custom-gcc gcc name languages #:key (separate-lib-output? #t)) - "Return a custom version of GCC that supports LANGUAGES." +(define* (custom-gcc gcc name languages + #:optional + (search-paths (package-native-search-paths gcc)) + #:key (separate-lib-output? #t)) + "Return a custom version of GCC that supports LANGUAGES. Use SEARCH-PATHS +as the 'native-search-paths' field." (package (inherit gcc) (name name) (outputs (if separate-lib-output? (package-outputs gcc) (delete "lib" (package-outputs gcc)))) + (native-search-paths search-paths) (arguments (substitute-keyword-arguments `(#:modules ((guix build gnu-build-system) (guix build utils) @@ -428,20 +441,37 @@ (define* (custom-gcc gcc name languages #:key (separate-lib-output? #t)) (remove (cut string-match "--enable-languages.*" <>) ,flags))))))) +(define %generic-search-paths + ;; This is the language-neutral search path for GCC. Entries in $CPATH are + ;; not considered "system headers", which means GCC can raise warnings for + ;; issues in those headers. 'CPATH' is the only one that works for + ;; front-ends not in the C family. + (list (search-path-specification + (variable "CPATH") + (files '("include"))) + (search-path-specification + (variable "LIBRARY_PATH") + (files '("lib" "lib64"))))) + (define-public gfortran-4.8 - (custom-gcc gcc-4.8 "gfortran" '("fortran"))) + (custom-gcc gcc-4.8 "gfortran" '("fortran") + %generic-search-paths)) (define-public gfortran-4.9 - (custom-gcc gcc-4.9 "gfortran" '("fortran"))) + (custom-gcc gcc-4.9 "gfortran" '("fortran") + %generic-search-paths)) (define-public gfortran - (custom-gcc gcc "gfortran" '("fortran"))) + (custom-gcc gcc "gfortran" '("fortran") + %generic-search-paths)) (define-public gfortran-5 - (custom-gcc gcc-5 "gfortran" '("fortran"))) + (custom-gcc gcc-5 "gfortran" '("fortran") + %generic-search-paths)) (define-public gccgo-4.8 (custom-gcc gcc-4.8 "gccgo" '("go") + %generic-search-paths ;; Suppress the separate "lib" output, because otherwise the ;; "lib" and "out" outputs would refer to each other, creating ;; a cyclic dependency. @@ -468,6 +498,8 @@ (define-public gcj (native-inputs `(("dejagnu" ,dejagnu) ,@(package-native-inputs gcc))) + (native-search-paths %generic-search-paths) + ;; Suppress the separate "lib" output, because otherwise the ;; "lib" and "out" outputs would refer to each other, creating ;; a cyclic dependency. @@ -551,10 +583,22 @@ (define ecj-bootstrap "1k9lgm3qamf6zy534pa2zwskr8mpiqrngbv1vw9j4y1ghrdyf1lm")))) (define-public gcc-objc-4.8 - (custom-gcc gcc-4.8 "gcc-objc" '("objc"))) + (custom-gcc gcc-4.8 "gcc-objc" '("objc") + (list (search-path-specification + (variable "OBJC_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "LIBRARY_PATH") + (files '("lib" "lib64")))))) (define-public gcc-objc++-4.8 - (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++"))) + (custom-gcc gcc-4.8 "gcc-objc++" '("obj-c++") + (list (search-path-specification + (variable "OBJCPLUS_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "LIBRARY_PATH") + (files '("lib" "lib64")))))) (define (make-libstdc++-doc gcc) "Return a package with the libstdc++ documentation for GCC."