From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Nieuwenhuizen Subject: Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers. Date: Mon, 25 Apr 2016 13:28:55 +0200 Message-ID: <87wpnmgc5k.fsf@drakenvlieg.flower> References: <87vb492l7s.fsf@drakenvlieg.flower> <877fgio11v.fsf@elephly.net> <87r3eq2y2s.fsf@drakenvlieg.flower> <8760w2nzl4.fsf@elephly.net> <87d1q8lb7j.fsf@drakenvlieg.flower> <87k2k99l7w.fsf@gnu.org> <87d1pssnwl.fsf@drakenvlieg.flower> <871t614pk6.fsf@gnu.org> <87bn4yhurl.fsf_-_@drakenvlieg.flower> <87vb36x9ac.fsf@igalia.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aulxx-0007T8-Ga for guix-devel@gnu.org; Mon, 25 Apr 2016 15:14:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aulxu-0002w6-4g for guix-devel@gnu.org; Mon, 25 Apr 2016 15:14:41 -0400 In-Reply-To: <87vb36x9ac.fsf@igalia.com> (Andy Wingo's message of "Mon, 25 Apr 2016 12:38:51 +0200") References: <87vb492l7s.fsf@drakenvlieg.flower> <877fgio11v.fsf@elephly.net> <87r3eq2y2s.fsf@drakenvlieg.flower> <8760w2nzl4.fsf@elephly.net> <87d1q8lb7j.fsf@drakenvlieg.flower> <87k2k99l7w.fsf@gnu.org> <87d1pssnwl.fsf@drakenvlieg.flower> <871t614pk6.fsf@gnu.org> <87bn4yhurl.fsf_-_@drakenvlieg.flower> <87vb36x9ac.fsf@igalia.com> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Andy Wingo Cc: guix-devel@gnu.org --=-=-= Content-Type: text/plain Andy Wingo writes: >> + (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 > ^^ > > Bad indentation here; it should be indented like let* Argh, sorry this all wrong, a rebase goof-up; only fixed this on wip-hurd+mingw branch. It was meant as (fixed in attached patch) (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))) What about indentation, I blindly trust Emacs... > However given this, both "value" and "path" should succeed without > error... Yes... >> + (native-path >> + (and path >> + (list->search-path-as-string >> + (remove cross? path) ":")))) > > And this is a repeat? Perhaps you meant to replace the and-let* block, > or to remove this one? I would lean towards not using and-let* fwiw :) Yes... Why do you not prefer the and-let*, how would you write it? > For one-armed ifs, please use "when" or "unless". Tx :) Ok. Thanks! Greetings, Jan --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-gnu-cross-Use-CROSS_-_INCLUDE_PATH-for-system-header.patch Content-Transfer-Encoding: quoted-printable >From f2842ce5e35c0d984fc18912088bb81f9bac38f5 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 17 Apr 2016 18:20:05 +0200 Subject: [PATCH 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system header= s. * gnu/packages/patches/gcc-cross-environment-variables.patch: Also use CROS= S_ 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 | 70 +++++++++++------- .../patches/gcc-cross-environment-variables.patch | 86 +++++++++++++++---= ---- 2 files changed, 104 insertions(+), 52 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 8bd599c..2e1bcf8 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 =C2=A9 2013, 2014, 2015, 2016 Ludovic Court=C3=A8s ;;; Copyright =C2=A9 2014, 2015 Mark H Weaver +;;; Copyright =C2=A9 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 @@ -168,34 +170,38 @@ may be either a libc package or #f.)" (lambda* (#:key inputs #:allow-other-keys) ;; Add the cross Linux headers to CROSS_CPATH, and remov= e them ;; from CPATH. - (let ((libc (assoc-ref inputs "libc")) + (let ((libc (assoc-ref inputs libc)) (linux (assoc-ref inputs "xlinux-headers"))) (define (cross? x) ;; 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->l= ist + 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)))))))) =20 (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 tha= t 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"))=20=20=20=20=20= =20=20=20=20=20=20=20=20=20 #t)) ,phases)))) =20 diff --git a/gnu/packages/patches/gcc-cross-environment-variables.patch b/g= nu/packages/patches/gcc-cross-environment-variables.patch index 0bd0be5..a2b94cb 100644 --- a/gnu/packages/patches/gcc-cross-environment-variables.patch +++ b/gnu/packages/patches/gcc-cross-environment-variables.patch @@ -1,9 +1,48 @@ -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. S= ee + the discussion at =20 ---- 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/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, + } +=20 + temp =3D getenv (LIBRARY_PATH_ENV); +- if (temp && *cross_compile =3D=3D '0') ++ if (temp) + { + const char *startp, *endp; + char *nstore =3D (char *) alloca (strlen (temp) + 3); +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[] =3D +- { "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 =3D cpp_get_options (pfile); + size_t idx =3D (cpp_opts->objc ? 2: 0); +=20 +@@ -473,7 +473,7 @@ register_include_chains (cpp_reader *pfile, const char= *sysroot, =20=20 /* CPATH and language-dependent environment variables may add to the include chain. */ @@ -12,37 +51,30 @@ at . add_env_var_paths (lang_env_vars[idx], SYSTEM); =20=20 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" =20=20 +#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; =20=20 putenv (xstrdup ("COMPILER_PATH=3D")); - putenv (xstrdup ("LIBRARY_PATH=3D")); -+ putenv (xstrdup (LIBRARY_PATH_ENV "=3D")); ++ putenv (xstrdup ("LIBRARY_PATH_ENV=3D")); =20=20 while ((f =3D file_pop ()) !=3D NULL) { +--=20 +2.1.4 =20 ---- 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 - } -=20 - temp =3D getenv (LIBRARY_PATH_ENV); -- if (temp && *cross_compile =3D=3D '0') -+ if (temp) - { - const char *startp, *endp; - char *nstore =3D (char *) alloca (strlen (temp) + 3); --=20 2.7.3 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.nl= =20=20 --=-=-=--