[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system heade
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
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
>From f2842ce5e35c0d984fc18912088bb81f9bac38f5 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Sun, 17 Apr 2016 18:20:05 +0200
Subject: [PATCH 1/9] 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 | 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 © 2013, 2014, 2015, 2016 Ludovic Courtès <address@hidden>
;;; Copyright © 2014, 2015 Mark H Weaver <address@hidden>
+;;; Copyright © 2016 Jan Nieuwenhuizen <address@hidden>
;;;
;;; 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 remove
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->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..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 <http://gcc.gnu.org/ml/gcc/2013-02/msg00124.html>.
+From a1d8c3d926cb43e51a2b4838ad5cca9c2510fbbb Mon Sep 17 00:00:00 2001
+From: Jan Nieuwenhuizen <address@hidden>
+Date: Sat, 16 Apr 2016 10:08:16 +0200
+Subject: [PATCH] Search path environment variables for cross-compilers. See
+ the discussion at <http://gcc.gnu.org/ml/gcc/2013-02/msg00124.html>
---- 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
+
+<https://lists.gnu.org/archive/html/guix-devel/2016-04/msg00533.html>
+---
+ 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,
+ }
+
+ temp = getenv (LIBRARY_PATH_ENV);
+- if (temp && *cross_compile == '0')
++ if (temp)
+ {
+ const char *startp, *endp;
+ char *nstore = (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[] =
+- { "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,37 +51,30 @@ at <http://gcc.gnu.org/ml/gcc/2013-02/msg00124.html>.
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="));
- putenv (xstrdup ("LIBRARY_PATH="));
-+ putenv (xstrdup (LIBRARY_PATH_ENV "="));
++ putenv (xstrdup ("LIBRARY_PATH_ENV="));
while ((f = file_pop ()) != NULL)
{
+--
+2.1.4
---- 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
- }
-
- temp = getenv (LIBRARY_PATH_ENV);
-- if (temp && *cross_compile == '0')
-+ if (temp)
- {
- const char *startp, *endp;
- char *nstore = (char *) alloca (strlen (temp) + 3);
--
2.7.3
--
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.nl
- Re: rfc/rfh: i686-w64-mingw32 cross target, Jan Nieuwenhuizen, 2016/04/02
- Re: rfc/rfh: i686-w64-mingw32 cross target, Ludovic Courtès, 2016/04/07
- Re: rfc/rfh: i686-w64-mingw32 cross target, Jan Nieuwenhuizen, 2016/04/14
- Re: rfc/rfh: i686-w64-mingw32 cross target, Ludovic Courtès, 2016/04/19
- [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers., Jan Nieuwenhuizen, 2016/04/25
- Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers., Andy Wingo, 2016/04/25
- Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers.,
Jan Nieuwenhuizen <=
- Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers., Andy Wingo, 2016/04/26
- Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers., Jan Nieuwenhuizen, 2016/04/26
- Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers., Jan Nieuwenhuizen, 2016/04/26
- Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers., Jan Nieuwenhuizen, 2016/04/25
- Re: [PATCH v4 1/9] gnu: cross: Use CROSS_*_INCLUDE_PATH for system headers., Andy Wingo, 2016/04/26