public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Gcc build fails with test_real_width is negative
@ 2021-11-29 11:05 Mr Dini
  2021-11-29 12:00 ` Stefan Ring
  0 siblings, 1 reply; 10+ messages in thread
From: Mr Dini @ 2021-11-29 11:05 UTC (permalink / raw)
  To: gcc-help

Thank you for the quick reply. I have read meanwhile and found an explanation that in this case the wrong size is being cached and that's why the compilation fails. So I had the idea to grab an extremely old 32 bit ubuntu 16.04 chroot and seemingly if I build from there I get past the previous issue.

However I encounter another one: https://pastebin.com/raw/WnAHLk32

I noticed that the Makefile failing is under host-armv7a-linux-gnueabi/libgcc. If I manually edit this file to include the stdio.h file from my target sysroot I get past it, as the file exists here:

root@hal-9000:~/gcc-6.2.0# ls /opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi/usr/include/stdio.h
/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi/usr/include/stdio.h

However this libgcc build seemingly ignores what I have set in the environment, for example it wants to use armv7a-linux-gnueabi-cc instead of arm-webos-linux-gnueabi-gcc like I specified when I ran configure on the root of the project. Seemingly this libgcc dependency building ignores all config vars that has been set before. I am unsure why.

For example armv7a-linux-gnueabi-cc didn't even exist and so it errored first, I had to symlink the right file to that path.

I think the first step would be to debug why libgcc is not picking up the sysroot and CC configurations, but I tried to touch the Makefile manually to include the /opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi/usr/include path so it gets past the stdio.h not found error. Then it fails a tiny bit later:

https://pastebin.com/raw/D5DsQPid

Also, you mentioned I am not supposed to build within the source tree. How am I supposed to build then? outside of the gcc folder and by specifying "make -C folder"?

And last, but not least, I am quite a beginner here as you could probably tell. I have been trying to look for some pre-existing canadian cross build scripts for arm gcc but surprisingly I haven't found any. Do you happen to know one? I would love to take a look.

Thanks

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

* Re: Gcc build fails with test_real_width is negative
  2021-11-29 11:05 Gcc build fails with test_real_width is negative Mr Dini
@ 2021-11-29 12:00 ` Stefan Ring
  2021-11-29 12:12   ` Mr Dini
  2021-11-29 12:18   ` AW: " Stefan Franke
  0 siblings, 2 replies; 10+ messages in thread
From: Stefan Ring @ 2021-11-29 12:00 UTC (permalink / raw)
  To: gcc-help

On Mon, Nov 29, 2021 at 12:06 PM Mr Dini via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> Also, you mentioned I am not supposed to build within the source tree. How am I supposed to build then? outside of the gcc folder and by specifying "make -C folder"?

- cd to some directory, for example next to gcc-<xxx>
- ../gcc-<xxx>/configure [...]
- make [...]

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

* Re: Gcc build fails with test_real_width is negative
  2021-11-29 12:00 ` Stefan Ring
@ 2021-11-29 12:12   ` Mr Dini
  2021-11-29 12:18   ` AW: " Stefan Franke
  1 sibling, 0 replies; 10+ messages in thread
From: Mr Dini @ 2021-11-29 12:12 UTC (permalink / raw)
  To: gcc-help

Thank you, I have tried this method, however as expected it still fails at the stdio.h no such file or directory error (see my previous email).

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

* AW: Gcc build fails with test_real_width is negative
  2021-11-29 12:00 ` Stefan Ring
  2021-11-29 12:12   ` Mr Dini
@ 2021-11-29 12:18   ` Stefan Franke
  2021-11-29 19:40     ` Mr Dini
  1 sibling, 1 reply; 10+ messages in thread
From: Stefan Franke @ 2021-11-29 12:18 UTC (permalink / raw)
  To: gcc-help

> -----Ursprüngliche Nachricht-----
> Von: Gcc-help <gcc-help-bounces+bebbo=bejy.net@gcc.gnu.org> Im
> Auftrag von Stefan Ring via Gcc-help
> Gesendet: Montag, 29. November 2021 13:00
> An: gcc-help@gcc.gnu.org
> Betreff: Re: Gcc build fails with test_real_width is negative
> 
> On Mon, Nov 29, 2021 at 12:06 PM Mr Dini via Gcc-help <gcc-
> help@gcc.gnu.org> wrote:
> >
> > Also, you mentioned I am not supposed to build within the source tree.
> How am I supposed to build then? outside of the gcc folder and by specifying
> "make -C folder"?
> 
> - cd to some directory, for example next to gcc-<xxx>
> - ../gcc-<xxx>/configure [...]
> - make [...]

Using relative paths may break your build (e.g. using Cygwin).
Use an absolute path to be safe:

  $PWD/../gcc-<xxx>/configure [...]




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

* Re: Gcc build fails with test_real_width is negative
  2021-11-29 12:18   ` AW: " Stefan Franke
@ 2021-11-29 19:40     ` Mr Dini
  2021-12-02  9:20       ` Stefan Ring
  0 siblings, 1 reply; 10+ messages in thread
From: Mr Dini @ 2021-11-29 19:40 UTC (permalink / raw)
  To: gcc-help

I am sure this is not a common practice, but since I couldn't get gcc to compile and I am out of ideas as to why libgcc is not picking up the environment variables, I decided to share the chroot I am trying to build from.

The file can be found here: https://mega.nz/file/qqBB2QKZ#mQVV3Vqyre6MYtdGJlx2rNq7el8Aiimr6uv4aTZR97g

When I chroot I firstly run the command to populate the environment variables:

. /opt/webos-sdk-x86_64/1.0.g/environment-setup-armv7a-neon-webos-linux-gnueabi

Then execute the following commands to start the build process:

cd /root/gcc-build

CC="arm-webos-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=softfp --sysroot=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi" CXX="arm-webos-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=softfp --sysroot=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi" ../gcc-6.2.0/configure --prefix=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi --with-mpfr=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi --host=armv7a-linux-gnueabi --target=armv7a-linux-gnueabi --build=x86_64-linux-gnu

make -j8

Right now, the folder contains a state where it fails with stdio.h no such file or directory. If you skip the configure part and run make -j8 directly after setting the env vars, you can see what's going on.

I appreciate any feedback!

Thanks

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

* Re: Gcc build fails with test_real_width is negative
  2021-11-29 19:40     ` Mr Dini
@ 2021-12-02  9:20       ` Stefan Ring
  2021-12-02 21:22         ` Stefan Ring
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Ring @ 2021-12-02  9:20 UTC (permalink / raw)
  To: gcc-help

On Mon, Nov 29, 2021 at 8:40 PM Mr Dini via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> I am sure this is not a common practice, but since I couldn't get gcc to compile and I am out of ideas as to why libgcc is not picking up the environment variables, I decided to share the chroot I am trying to build from.
>
> The file can be found here: https://mega.nz/file/qqBB2QKZ#mQVV3Vqyre6MYtdGJlx2rNq7el8Aiimr6uv4aTZR97g
>
> When I chroot I firstly run the command to populate the environment variables:
>
> . /opt/webos-sdk-x86_64/1.0.g/environment-setup-armv7a-neon-webos-linux-gnueabi
>
> Then execute the following commands to start the build process:
>
> cd /root/gcc-build
>
> CC="arm-webos-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=softfp --sysroot=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi" CXX="arm-webos-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=softfp --sysroot=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi" ../gcc-6.2.0/configure --prefix=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi --with-mpfr=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi --host=armv7a-linux-gnueabi --target=armv7a-linux-gnueabi --build=x86_64-linux-gnu
>
> make -j8
>
> Right now, the folder contains a state where it fails with stdio.h no such file or directory. If you skip the configure part and run make -j8 directly after setting the env vars, you can see what's going on.
>
> I appreciate any feedback!
>
> Thanks

I tried it and also arrived at the missing <stdio.h>. I built a few
cross-native compilers a few years ago; I will look up how I did it.
But I seem to remember that you need to use --with-sysroot somewhere
because the problem is that in the build process, when the newly built
compiler is used to build libgcc, it does not know where to look for
the platform includes. Or at least use a different environment
variable for injecting the --sysroot argument. When I did it, I looked
at how crosstool-ng did it by looking at its build logs and adapting
them for building a native compiler.

I am a bit puzzled why you are running an x86_64 toolchain inside an
i686 chroot. But that is not the source of your problem, at least for
now.

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

* Re: Gcc build fails with test_real_width is negative
  2021-12-02  9:20       ` Stefan Ring
@ 2021-12-02 21:22         ` Stefan Ring
  0 siblings, 0 replies; 10+ messages in thread
From: Stefan Ring @ 2021-12-02 21:22 UTC (permalink / raw)
  To: gcc-help

On Thu, Dec 2, 2021 at 10:20 AM Stefan Ring <stefanrin@gmail.com> wrote:
>
> On Mon, Nov 29, 2021 at 8:40 PM Mr Dini via Gcc-help
> <gcc-help@gcc.gnu.org> wrote:
> >
> > I am sure this is not a common practice, but since I couldn't get gcc to compile and I am out of ideas as to why libgcc is not picking up the environment variables, I decided to share the chroot I am trying to build from.
> >
> > The file can be found here: https://mega.nz/file/qqBB2QKZ#mQVV3Vqyre6MYtdGJlx2rNq7el8Aiimr6uv4aTZR97g
> >
> > When I chroot I firstly run the command to populate the environment variables:
> >
> > . /opt/webos-sdk-x86_64/1.0.g/environment-setup-armv7a-neon-webos-linux-gnueabi
> >
> > Then execute the following commands to start the build process:
> >
> > cd /root/gcc-build
> >
> > CC="arm-webos-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=softfp --sysroot=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi" CXX="arm-webos-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=softfp --sysroot=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi" ../gcc-6.2.0/configure --prefix=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi --with-mpfr=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi --host=armv7a-linux-gnueabi --target=armv7a-linux-gnueabi --build=x86_64-linux-gnu
> >
> > make -j8
> >
> > Right now, the folder contains a state where it fails with stdio.h no such file or directory. If you skip the configure part and run make -j8 directly after setting the env vars, you can see what's going on.
> >
> > I appreciate any feedback!
> >
> > Thanks

Running the toolchain gcc with -v reveals that it was configured with
--with-sysroot=/not/exist. ;)

So I got a little creative and used:

mkdir /not
ln -s /opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi
/not/exist

Then I set:

export PATH=/opt/webos-sdk-x86_64/1.0.g/sysroots/x86_64-webossdk-linux/usr/bin/arm-webos-linux-gnueabi:$PATH

and only this. Forget about all the crap in
/opt/webos-sdk-x86_64/1.0.g/environment-setup-armv7a-neon-webos-linux-gnueabi!

Then

/root/gcc-6.2.0/configure
--prefix=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi
--build= --host=arm-webos-linux-gnueabi
--target=arm-webos-linux-gnueabi --with-sysroot=/
--with-build-sysroot=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi
--with-float=softfp --with-fpu=neon --with-arch=armv7-a
--enable-languages=c,c++ --disable-multilib
--with-mpfr=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi
make -j8

gives me a working build. At least a build running to completion. If
it actually works I cannot tell because I do not own the target. The
--with-build-sysroot is not strictly necessary because of the
/not/exist trick, but I consider it good taste. I’m also not sure
about the --with-sysroot=/. It may or may not help or hurt. Also, your
--prefix is probably not the best idea. Just use something short like
/usr/gcc6 or similar, and install with make install
DESTDIR=<somewhere>.

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

* Re: Gcc build fails with test_real_width is negative
  2021-11-29 10:10 ` Stefan Ring
@ 2021-11-29 14:01   ` Jonathan Wakely
  0 siblings, 0 replies; 10+ messages in thread
From: Jonathan Wakely @ 2021-11-29 14:01 UTC (permalink / raw)
  To: Stefan Ring; +Cc: gcc-help

On Mon, 29 Nov 2021 at 10:11, Stefan Ring wrote:
> Looks like a -Werror issue. I don't remember if gcc has a
> --disable-werror flag, but I guess it should.

It does.

> Also you're not supposed
> to build inside the source tree.

Correct, see https://gcc.gnu.org/wiki/FAQ#configure

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

* Re: Gcc build fails with test_real_width is negative
  2021-11-28 19:16 Mr Dini
@ 2021-11-29 10:10 ` Stefan Ring
  2021-11-29 14:01   ` Jonathan Wakely
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Ring @ 2021-11-29 10:10 UTC (permalink / raw)
  To: gcc-help

On Sun, Nov 28, 2021 at 8:18 PM Mr Dini via Gcc-help
<gcc-help@gcc.gnu.org> wrote:
> In file included from ../.././gcc/rtl.h:27,
>                  from ../.././gcc/genoutput.c:90:
> ../.././gcc/real.h:74:76: error: narrowing conversion of '-1' from 'int' to 'long unsigned int' [-Wnarrowing]
>    74 |   [sizeof (REAL_VALUE_TYPE) <= REAL_WIDTH * sizeof (HOST_WIDE_INT) ? 1 : -1];
>       |                                                                            ^
>
> Also, it looks like when gcc is building this specific component, make does a cd to host-armv7a-linux-gnueabi/gcc yet it uses the g++ of the host and completely ignores the CXX variable I have set when I configure gcc:
>
> CC="arm-webos-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=softfp --sysroot=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi" CXX="arm-webos-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=softfp --sysroot=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi" ./configure --prefix=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi --with-mpfr=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi --host=armv7a-linux-gnueabi --target=armv7a-linux-gnueabi --build=x86_64-linux-gnu
>

Looks like a -Werror issue. I don't remember if gcc has a
--disable-werror flag, but I guess it should. Also you're not supposed
to build inside the source tree.

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

* Gcc build fails with test_real_width is negative
@ 2021-11-28 19:16 Mr Dini
  2021-11-29 10:10 ` Stefan Ring
  0 siblings, 1 reply; 10+ messages in thread
From: Mr Dini @ 2021-11-28 19:16 UTC (permalink / raw)
  To: gcc-help

Hi,

I am trying to build a native gcc binary for a pre-existing rootfs of my smart TV. The vendor has provided a toolchain for x86_64 hosts:

root@hal-9000:~# arm-webos-linux-gnueabi-gcc --version
arm-webos-linux-gnueabi-gcc (GCC) 6.2.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

As for the building I have tried building on an ubuntu 16.04 host with gcc version 5.3.1 and Ubuntu 20.04 with gcc version 9.3.0. The issue is always the same.

I have also tried to build the latest gcc release, 9.3.0, 9.2.0, 5.4.0 and 6.2.0.

Here is the error: https://pastebin.com/raw/Cr4amNCJ

To quote the specific part:

In file included from ../.././gcc/rtl.h:27,
                 from ../.././gcc/genoutput.c:90:
../.././gcc/real.h:74:76: error: narrowing conversion of '-1' from 'int' to 'long unsigned int' [-Wnarrowing]
   74 |   [sizeof (REAL_VALUE_TYPE) <= REAL_WIDTH * sizeof (HOST_WIDE_INT) ? 1 : -1];
      |                                                                            ^

Also, it looks like when gcc is building this specific component, make does a cd to host-armv7a-linux-gnueabi/gcc yet it uses the g++ of the host and completely ignores the CXX variable I have set when I configure gcc:

CC="arm-webos-linux-gnueabi-gcc -march=armv7-a -mfpu=neon -mfloat-abi=softfp --sysroot=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi" CXX="arm-webos-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=softfp --sysroot=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi" ./configure --prefix=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi --with-mpfr=/opt/webos-sdk-x86_64/1.0.g/sysroots/armv7a-neon-webos-linux-gnueabi --host=armv7a-linux-gnueabi --target=armv7a-linux-gnueabi --build=x86_64-linux-gnu

Any ideas what can I do?

Thank you so much!

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

end of thread, other threads:[~2021-12-02 21:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 11:05 Gcc build fails with test_real_width is negative Mr Dini
2021-11-29 12:00 ` Stefan Ring
2021-11-29 12:12   ` Mr Dini
2021-11-29 12:18   ` AW: " Stefan Franke
2021-11-29 19:40     ` Mr Dini
2021-12-02  9:20       ` Stefan Ring
2021-12-02 21:22         ` Stefan Ring
  -- strict thread matches above, loose matches on Subject: below --
2021-11-28 19:16 Mr Dini
2021-11-29 10:10 ` Stefan Ring
2021-11-29 14:01   ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).