all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Crosscompiling C++ for powerpc64le fails
@ 2019-05-28 16:07 Tobias Platen
  2019-05-28 18:31 ` Danny Milosavljevic
  0 siblings, 1 reply; 7+ messages in thread
From: Tobias Platen @ 2019-05-28 16:07 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 289 bytes --]

Hello,

Im trying to cross compile basic GNU software such as bash and coreutils
for powerpc.

When building mpfr the build fails using the message above. I guess I
have to specify the include paths for glibc to the configure script,
since headers won't be found in /usr/include

Tobias



[-- Attachment #2: guix_stdlib_not_found.txt --]
[-- Type: text/plain, Size: 4328 bytes --]

configure:10515: checking C++ compiler powerpc64le-linux-g++  -m64  -O3
Test compile: 
configure:10529: powerpc64le-linux-g++  -m64  -O3 conftest.cc >&5
configure:10532: $? = 0
Test compile: namespace
configure:10569: powerpc64le-linux-g++  -m64  -O3 conftest.cc >&5
configure:10572: $? = 0
Test compile: std iostream
configure:10615: powerpc64le-linux-g++  -m64  -O3 conftest.cc >&5
In file included from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/ext/string_conversions.h:41:0,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/bits/basic_string.h:6361,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/string:52,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/bits/locale_classes.h:40,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/bits/ios_base.h:41,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/ios:42,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/ostream:38,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/iostream:39,
                 from conftest.cc:3:
/gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~
compilation terminated.
configure:10618: $? = 1
failed program was:
/* This test rejects g++ 2.7.2 which doesn't have <iostream>, only a
    pre-standard iostream.h. */
#include <iostream>

/* This test rejects OSF 5.1 Compaq C++ in its default pre-standard iostream
   mode, since that mode puts cout in the global namespace, not "std".  */
void someoutput (void) { std::cout << 123; }

int main (void) { return 0; }
configure:10644: result: no, std iostream
configure:10515: checking C++ compiler powerpc64le-linux-g++  -g -O2
Test compile: 
configure:10529: powerpc64le-linux-g++  -g -O2 conftest.cc >&5
configure:10532: $? = 0
Test compile: namespace
configure:10569: powerpc64le-linux-g++  -g -O2 conftest.cc >&5
configure:10572: $? = 0
Test compile: std iostream
configure:10615: powerpc64le-linux-g++  -g -O2 conftest.cc >&5
In file included from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/ext/string_conversions.h:41:0,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/bits/basic_string.h:6361,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/string:52,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/bits/locale_classes.h:40,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/bits/ios_base.h:41,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/ios:42,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/ostream:38,
                 from /gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/iostream:39,
                 from conftest.cc:3:
/gnu/store/l2gp3b9qfz2bwp0wcg7qz1xdgky8mfxr-gcc-cross-powerpc64le-linux-7.4.0/include/c++/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~
compilation terminated.
configure:10618: $? = 1
failed program was:
/* This test rejects g++ 2.7.2 which doesn't have <iostream>, only a
    pre-standard iostream.h. */
#include <iostream>

/* This test rejects OSF 5.1 Compaq C++ in its default pre-standard iostream
   mode, since that mode puts cout in the global namespace, not "std".  */
void someoutput (void) { std::cout << 123; }

int main (void) { return 0; }
configure:10644: result: no, std iostream
configure:10660: error: C++ compiler not available, see config.log for details


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Crosscompiling C++ for powerpc64le fails
  2019-05-28 16:07 Crosscompiling C++ for powerpc64le fails Tobias Platen
@ 2019-05-28 18:31 ` Danny Milosavljevic
  2019-05-29 10:10   ` Danny Milosavljevic
  0 siblings, 1 reply; 7+ messages in thread
From: Danny Milosavljevic @ 2019-05-28 18:31 UTC (permalink / raw)
  To: Tobias Platen; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1125 bytes --]

Hi Tobias,

On Tue, 28 May 2019 18:07:02 +0200
Tobias Platen <trisquel@platen-software.de> wrote:

> Im trying to cross compile basic GNU software such as bash and coreutils
> for powerpc.
> 
> When building mpfr the build fails using the message above. I guess I
> have to specify the include paths for glibc to the configure script,
> since headers won't be found in /usr/include

We have a special Guix-specific patch for gcc which makes it heed these
environment variables:

* CROSS_C_INCLUDE_PATH
* CROSS_CPLUS_INCLUDE_PATH
* CROSS_LIBRARY_PATH

Try printing and/or setting those.

gnu/packages/cross-base.scm already contains a SEARCH-PATHS form in CROSS-GCC
which sets up the environment variables CROSS_LIBRARY_PATH,
CROSS_C_INCLUDE_PATH, CROSS_CPLUS_INCLUDE_PATH, CROSS_OBJC_INCLUDE_PATH,
CROSS_OBJCPLUS_INCLUDE_PATH, so it should have worked--but didn't.

That still leaves the libc.  Not sure how it gets included in the environment
variables above.

See gnu/packages/admin.scm's sunxi-tools for a horrible workaround that
makes it work fine.

We should probably fix this problem.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Crosscompiling C++ for powerpc64le fails
  2019-05-28 18:31 ` Danny Milosavljevic
@ 2019-05-29 10:10   ` Danny Milosavljevic
  2019-05-31 21:54     ` Ludovic Courtès
  0 siblings, 1 reply; 7+ messages in thread
From: Danny Milosavljevic @ 2019-05-29 10:10 UTC (permalink / raw)
  To: Tobias Platen, guix-devel

[-- Attachment #1: Type: text/plain, Size: 1751 bytes --]

I've investigated a bit more:

Guix's gcc-4.7 passes

  (string-append "--with-native-system-header-dir=" libc "/include")
  where libc is (assoc-ref %build-inputs "libc")

.

However, further down, there is

                `(let* ((libc        (assoc-ref %build-inputs "libc"))
                       (libc-native (or (assoc-ref %build-inputs "libc-native")
                                        libc)))


which makes me think that "--with-native-system-header-dir=" should use
libc-native if the latter is present.

It would be possible to pass "--with-headers=" to gcc which would make it copy
the specified directory into the gcc installation directory and everything
would work without weird workarounds.

The gcc option "--with-headers=" is deprecated in favor of "--with-sysroot".

Also, the gcc manual says:

> "If the specified directory is a subdirectory of ${exec_prefix}, then it will
> be found relative to the GCC binaries if the installation tree is moved."

Not sure we want that.

The gcc manual says:

>If you specify the --with-native-system-header-dir=dirname option then the
>compiler will search that directory within dirname for native system headers
>rather than the default /usr/include. 

So I guess a quick workaround would be to specify "--with-headers=" libc for
cross-gcc.  That would make the resulting gcc much larger since it would copy
glibc into it.

The right fix would be to specify "--with-sysroot=" or to use our patch.

In any case, what guix master does with

 (string-append "--with-native-system-header-dir=" libc "/include")
  where libc is (assoc-ref %build-inputs "libc")

is seriously bad.  Should replace that by (or libc-native libc) in that order.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Crosscompiling C++ for powerpc64le fails
  2019-05-29 10:10   ` Danny Milosavljevic
@ 2019-05-31 21:54     ` Ludovic Courtès
  2019-06-03 18:30       ` Marius Bakke
  0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2019-05-31 21:54 UTC (permalink / raw)
  To: Danny Milosavljevic; +Cc: guix-devel

Hi Danny,

Danny Milosavljevic <dannym@scratchpost.org> skribis:

> I've investigated a bit more:
>
> Guix's gcc-4.7 passes
>
>   (string-append "--with-native-system-header-dir=" libc "/include")
>   where libc is (assoc-ref %build-inputs "libc")
>
> .
>
> However, further down, there is
>
>                 `(let* ((libc        (assoc-ref %build-inputs "libc"))
>                        (libc-native (or (assoc-ref %build-inputs "libc-native")
>                                         libc)))
>
>
> which makes me think that "--with-native-system-header-dir=" should use
> libc-native if the latter is present.
>
> It would be possible to pass "--with-headers=" to gcc which would make it copy
> the specified directory into the gcc installation directory and everything
> would work without weird workarounds.

You’re probably right, it would be worth giving it a try.

The weird thing is that:

  guix build mpfr --target=arm-linux-gnueabihf

works fine on current master, which uses GCC 5.5 for cross-compilation.

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?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Crosscompiling C++ for powerpc64le fails
  2019-05-31 21:54     ` Ludovic Courtès
@ 2019-06-03 18:30       ` Marius Bakke
  2019-06-05 13:04         ` Ludovic Courtès
  0 siblings, 1 reply; 7+ messages in thread
From: Marius Bakke @ 2019-06-03 18:30 UTC (permalink / raw)
  To: Ludovic Courtès, Danny Milosavljevic; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1816 bytes --]

Ludovic Courtès <ludo@gnu.org> writes:

> Hi Danny,
>
> Danny Milosavljevic <dannym@scratchpost.org> skribis:
>
>> I've investigated a bit more:
>>
>> Guix's gcc-4.7 passes
>>
>>   (string-append "--with-native-system-header-dir=" libc "/include")
>>   where libc is (assoc-ref %build-inputs "libc")
>>
>> .
>>
>> However, further down, there is
>>
>>                 `(let* ((libc        (assoc-ref %build-inputs "libc"))
>>                        (libc-native (or (assoc-ref %build-inputs "libc-native")
>>                                         libc)))
>>
>>
>> which makes me think that "--with-native-system-header-dir=" should use
>> libc-native if the latter is present.
>>
>> It would be possible to pass "--with-headers=" to gcc which would make it copy
>> the specified directory into the gcc installation directory and everything
>> would work without weird workarounds.
>
> You’re probably right, it would be worth giving it a try.
>
> The weird thing is that:
>
>   guix build mpfr --target=arm-linux-gnueabihf
>
> works fine on current master, which uses GCC 5.5 for cross-compilation.
>
> 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.

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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Crosscompiling C++ for powerpc64le fails
  2019-06-03 18:30       ` Marius Bakke
@ 2019-06-05 13:04         ` Ludovic Courtès
  2019-06-06 18:35           ` Marius Bakke
  0 siblings, 1 reply; 7+ messages in thread
From: Ludovic Courtès @ 2019-06-05 13:04 UTC (permalink / raw)
  To: Marius Bakke; +Cc: guix-devel

Hi Marius,

Marius Bakke <mbakke@fastmail.com> skribis:

> Ludovic Courtès <ludo@gnu.org> 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?

> 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)?

On core-updates, I see that ‘gcc-6’ changes ‘native-search-paths’ from
C_INCLUDE_PATH & co. to CPATH, and likewise, ‘cross-gcc’ sets
‘search-paths’ to CROSS_CPATH.  That looks consistent to me.

Ludo’.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Crosscompiling C++ for powerpc64le fails
  2019-06-05 13:04         ` Ludovic Courtès
@ 2019-06-06 18:35           ` Marius Bakke
  0 siblings, 0 replies; 7+ messages in thread
From: Marius Bakke @ 2019-06-06 18:35 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel


[-- Attachment #1.1: Type: text/plain, Size: 1714 bytes --]

Ludovic Courtès <ludo@gnu.org> writes:

> Hi Marius,
>
> Marius Bakke <mbakke@fastmail.com> skribis:
>
>> Ludovic Courtès <ludo@gnu.org> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-cross-base-Fix-C-cross-compilation-problems-with.patch --]
[-- Type: text/x-patch, Size: 1897 bytes --]

From dcdedf8d8460a032c0333f6050626a41b39ff461 Mon Sep 17 00:00:00 2001
From: Marius Bakke <mbakke@fastmail.com>
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


[-- Attachment #1.3: Type: text/plain, Size: 201 bytes --]


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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-06-06 18:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-28 16:07 Crosscompiling C++ for powerpc64le fails Tobias Platen
2019-05-28 18:31 ` Danny Milosavljevic
2019-05-29 10:10   ` Danny Milosavljevic
2019-05-31 21:54     ` Ludovic Courtès
2019-06-03 18:30       ` Marius Bakke
2019-06-05 13:04         ` Ludovic Courtès
2019-06-06 18:35           ` Marius Bakke

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.