guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crosscompiling C++ for powerpc64le fails


From: Marius Bakke
Subject: Re: Crosscompiling C++ for powerpc64le fails
Date: Thu, 06 Jun 2019 20:35:53 +0200
User-agent: Notmuch/0.28.4 (https://notmuchmail.org) Emacs/26.2 (x86_64-pc-linux-gnu)

Ludovic Courtès <address@hidden> writes:

> Hi Marius,
>
> Marius Bakke <address@hidden> skribis:
>
>> Ludovic Courtès <address@hidden> writes:
>
> [...]
>
>>> The issue that Tobias reports reminds me of the CPATH vs. C_INCLUDE_PATH
>>> issue that was causing troubles with newer GCCs, and that I think Marius
>>> addressed in ‘core-updates’ (?).  Marius, does that ring a bell?
>>
>> Unfortunately there are still issues with cross-compiling C++ on
>> 'core-updates'.  For 'C', the workaround was to go back to "CROSS_CPATH"
>> instead of "CROSS_C_INCLUDE_PATH", like with native builds.
>
> That should also address C++, since CPATH (and CROSS_CPATH) are for all
> language front-ends, no just C, no?

Indeed.  The cross-compilation problems are unrelated.

>> For native builds on core-updates, GCC7 occasionally fails if the libc
>> or kernel headers are not on C_INCUDE_PATH (see e.g. f90d6c3).  It could
>> be that cross builds need a similar workaround, but I have not found the
>> magic incantation yet.
>
> How can it be that kernel headers are not on C_INCLUDE_PATH (or CPATH)?

Sorry, this was a red herring.  :-)
(Kernel headers are of course on CPATH because they are propagated from
glibc, but adding them on C_INCLUDE_PATH works around some corner cases
because GCC disables warnings for such headers, which is expected by
some build scripts.)

I expected the problem with GCC not finding target libc headers to be a
matter of getting it on CROSS_CPLUS_INCLUDE_PATH, just like we had to
set C_INCLUDE_PATH for GCC 7's build processes to find libc.

But, looking at this issue with a fresh mind I managed to locate the
problem, and a one-liner fix:

From dcdedf8d8460a032c0333f6050626a41b39ff461 Mon Sep 17 00:00:00 2001
From: Marius Bakke <address@hidden>
Date: Thu, 6 Jun 2019 19:33:05 +0200
Subject: [PATCH] gnu: cross-base: Fix C++ cross-compilation problems with GCC
 7.

* gnu/packages/cross-base.scm (cross-gcc-arguments)[#:configure-flags]: Add
"--with-sysroot=/".
---
 gnu/packages/cross-base.scm | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 9fcf3bd780..0bd0cb3987 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -120,7 +120,15 @@ base compiler and using LIBC (which may be either a libc 
package or #f.)"
                        ,@(if libc
                              `( ;; Disable libcilkrts because it is not
                                 ;; ported to GNU/Hurd.
-                               "--disable-libcilkrts")
+                               "--disable-libcilkrts"
+                               ;; When building a cross compiler, 
--with-sysroot is
+                               ;; implicitly set to "$gcc_tooldir/sys-root".  
This does
+                               ;; not work for us, because 
--with-native-system-header-dir
+                               ;; is searched for relative to this location.  
Thus, we set
+                               ;; it to "/" so GCC is able to find the target 
libc headers.
+                               ;; This is safe because in practice GCC uses 
CROSS_CPATH
+                               ;; & co to separate target and host libraries.
+                               "--with-sysroot=/")
                              `( ;; Disable features not needed at this stage.
                                "--disable-shared" "--enable-static"
                                "--enable-languages=c,c++"
-- 
2.21.0

WDYT?

Cross-compiling bootstrap-tarballs still does not work, but I think we
just need to reinstate some known workarounds...  Will look into it the
coming days so we can get this branch rolling :-)

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]