From af9fa5754a1c85cc22ae3056945f841acdf1d72d Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 26 Apr 2016 10:51:52 +0200 Subject: [PATCH 01/10] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. * gnu/packages/patches/gcc-cross-environment-variables.patch: Also use CROSS_ variants: CROSS_C_INCLUDE_PATH, CROSS_CPLUS_INCLUDE_PATH, CROSS_OBJC_INCLUDE_PATH, CROSS_OBJCPLUS_INCLUDE_PATH to be used for system libraries, see https://lists.gnu.org/archive/html/guix-devel/2016-04/msg00620.html. * gnu/packages/cross-base.scm (cross-gcc, cross-gcc-arguments, cross-libc): Use CROSS_*_INCLUDE_PATH (WAS: CPATH). --- gnu/packages/cross-base.scm | 68 +++++++++++++-------- .../patches/gcc-cross-environment-variables.patch | 70 ++++++++++++++++------ 2 files changed, 95 insertions(+), 43 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 8bd599c..c5bf66f 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès ;;; Copyright © 2014, 2015 Mark H Weaver +;;; Copyright © 2016 Jan Nieuwenhuizen ;;; ;;; This file is part of GNU Guix. ;;; @@ -31,6 +32,7 @@ #:use-module (guix build-system trivial) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) + #:use-module (ice-9 and-let-star) #:use-module (ice-9 match) #:export (cross-binutils cross-libc @@ -174,28 +176,32 @@ may be either a libc package or #f.)" ;; Return #t if X is a cross-libc or cross Linux. (or (string-prefix? libc x) (string-prefix? linux x))) - - (setenv "CROSS_CPATH" - (string-append libc "/include:" - linux "/include")) + (let ((cpath (string-append + libc "/include" + ":" linux "/include"))) + (for-each (cut setenv <> cpath) + '("CROSS_C_INCLUDE_PATH" + "CROSS_CPLUS_INCLUDE_PATH" + "CROSS_OBJC_INCLUDE_PATH" + "CROSS_OBJCPLUS_INCLUDE_PATH"))) (setenv "CROSS_LIBRARY_PATH" (string-append libc "/lib")) - - (let ((cpath (search-path-as-string->list - (getenv "C_INCLUDE_PATH"))) - (libpath (search-path-as-string->list - (getenv "LIBRARY_PATH")))) - (setenv "CPATH" - (list->search-path-as-string - (remove cross? cpath) ":")) - (for-each unsetenv - '("C_INCLUDE_PATH" "CPLUS_INCLUDE_PATH")) - (setenv "LIBRARY_PATH" - (list->search-path-as-string - (remove cross? libpath) ":")) - #t))) - ,phases) - phases))))))) + (setenv "CPP" (string-append gcc "/bin/cpp")) + (for-each (lambda (var) + (and-let* ((value (getenv var)) + (path (search-path-as-string->list + value)) + (native-path + (list->search-path-as-string + (remove cross? path) ":"))) + (setenv var native-path))) + '("C_INCLUDE_PATH" + "CPLUS_INCLUDE_PATH" + "OBJC_INCLUDE_PATH" + "OBJCPLUS_INCLUDE_PATH" + "LIBRARY_PATH")))) + ,phases)) + (else phases)))))))) (define (cross-gcc-patches target) "Return GCC patches needed for TARGET." @@ -228,6 +234,7 @@ GCC that does not target a libc; otherwise, target that libc." `(#:implicit-inputs? #f #:modules ((guix build gnu-build-system) (guix build utils) + (ice-9 and-let-star) (ice-9 regex) (srfi srfi-1) (srfi srfi-26)) @@ -261,7 +268,16 @@ GCC that does not target a libc; otherwise, target that libc." ;; Only search target inputs, not host inputs. (search-paths (list (search-path-specification - (variable "CROSS_CPATH") + (variable "CROSS_C_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CROSS_CPLUS_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CROSS_OBJC_INCLUDE_PATH") + (files '("include"))) + (search-path-specification + (variable "CROSS_OBJCPLUS_INCLUDE_PATH") (files '("include"))) (search-path-specification (variable "CROSS_LIBRARY_PATH") @@ -316,9 +332,13 @@ XBINUTILS and the cross tool chain." `(alist-cons-before 'configure 'set-cross-linux-headers-path (lambda* (#:key inputs #:allow-other-keys) - (let ((linux (assoc-ref inputs "linux-headers"))) - (setenv "CROSS_CPATH" - (string-append linux "/include")) + (let* ((linux (assoc-ref inputs "linux-headers")) + (cpath (string-append linux "/include"))) + (for-each (cut setenv <> cpath) + '("CROSS_C_INCLUDE_PATH" + "CROSS_CPLUS_INCLUDE_PATH" + "CROSS_OBJC_INCLUDE_PATH" + "CROSS_OBJCPLUS_INCLUDE_PATH")) #t)) ,phases)))) diff --git a/gnu/packages/patches/gcc-cross-environment-variables.patch b/gnu/packages/patches/gcc-cross-environment-variables.patch index 0bd0be5..7bf4222 100644 --- a/gnu/packages/patches/gcc-cross-environment-variables.patch +++ b/gnu/packages/patches/gcc-cross-environment-variables.patch @@ -1,9 +1,35 @@ -Search path environment variables for cross-compilers. See the discussion -at . +From a1d8c3d926cb43e51a2b4838ad5cca9c2510fbbb Mon Sep 17 00:00:00 2001 +From: Jan Nieuwenhuizen +Date: Sat, 16 Apr 2016 10:08:16 +0200 +Subject: [PATCH] Search path environment variables for cross-compilers. See + the discussion at ---- gcc-4.7.2/gcc/incpath.c 2012-01-27 00:34:58.000000000 +0100 -+++ gcc-4.7.2/gcc/incpath.c 2013-02-12 10:11:27.000000000 +0100 -@@ -452,7 +452,7 @@ register_include_chains (cpp_reader *pfi +and + + +--- + gcc/gcc.c | 2 +- + gcc/incpath.c | 6 +++--- + gcc/system.h | 2 ++ + gcc/tlink.c | 2 +- + 4 files changed, 7 insertions(+), 5 deletions(-) + +diff --git a/gcc/incpath.c b/gcc/incpath.c +index f495c0a..ba12249 100644 +--- a/gcc/incpath.c ++++ b/gcc/incpath.c +@@ -461,8 +461,8 @@ register_include_chains (cpp_reader *pfile, const char *sysroot, + int stdinc, int cxx_stdinc, int verbose) + { + static const char *const lang_env_vars[] = +- { "C_INCLUDE_PATH", "CPLUS_INCLUDE_PATH", +- "OBJC_INCLUDE_PATH", "OBJCPLUS_INCLUDE_PATH" }; ++ { "CROSS_C_INCLUDE_PATH", "CROSS_CPLUS_INCLUDE_PATH", ++ "CROSS_OBJC_INCLUDE_PATH", "CROSS_OBJCPLUS_INCLUDE_PATH" }; + cpp_options *cpp_opts = cpp_get_options (pfile); + size_t idx = (cpp_opts->objc ? 2: 0); + +@@ -473,7 +473,7 @@ register_include_chains (cpp_reader *pfile, const char *sysroot, /* CPATH and language-dependent environment variables may add to the include chain. */ @@ -12,20 +38,22 @@ at . add_env_var_paths (lang_env_vars[idx], SYSTEM); target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc); - ---- gcc-4.7.2/gcc/system.h 2012-02-17 00:16:28.000000000 +0100 -+++ gcc-4.7.2/gcc/system.h 2013-02-12 10:22:17.000000000 +0100 -@@ -1023,4 +1023,6 @@ helper_const_non_const_cast (const char - #define DEBUG_VARIABLE - #endif +diff --git a/gcc/system.h b/gcc/system.h +index 42bc509..af3b9ad 100644 +--- a/gcc/system.h ++++ b/gcc/system.h +@@ -1063,4 +1063,6 @@ helper_const_non_const_cast (const char *p) + /* Get definitions of HOST_WIDE_INT and HOST_WIDEST_INT. */ + #include "hwint.h" +#define LIBRARY_PATH_ENV "CROSS_LIBRARY_PATH" + #endif /* ! GCC_SYSTEM_H */ - ---- gcc-4.7.2/gcc/tlink.c 2012-02-11 09:50:23.000000000 +0100 -+++ gcc-4.7.2/gcc/tlink.c 2013-05-23 22:06:19.000000000 +0200 -@@ -461,7 +461,7 @@ recompile_files (void) +diff --git a/gcc/tlink.c b/gcc/tlink.c +index bc358b8..ad6242f 100644 +--- a/gcc/tlink.c ++++ b/gcc/tlink.c +@@ -458,7 +458,7 @@ recompile_files (void) file *f; putenv (xstrdup ("COMPILER_PATH=")); @@ -34,10 +62,11 @@ at . while ((f = file_pop ()) != NULL) { - ---- gcc-4.7.3/gcc/gcc.c 2013-03-08 08:25:09.000000000 +0100 -+++ gcc-4.7.3/gcc/gcc.c 2013-05-24 08:58:16.000000000 +0200 -@@ -3726,7 +3726,7 @@ process_command (unsigned int decoded_op +diff --git a/gcc/gcc.c b/gcc/gcc.c +index adbf0c4..70448c6 100644 +--- a/gcc/gcc.c ++++ b/gcc/gcc.c +@@ -3853,7 +3853,7 @@ process_command (unsigned int decoded_options_count, } temp = getenv (LIBRARY_PATH_ENV); @@ -46,3 +75,6 @@ at . { const char *startp, *endp; char *nstore = (char *) alloca (strlen (temp) + 3); +-- +2.1.4 + -- 2.7.3