Discussion:
stdc-predef.h failed during gcc-linaro-snapshot-6.1-2016.07 compile
s***@comcast.net
2016-08-13 22:17:06 UTC
Permalink
Hi,

I've been trying to build the c and c++ cross-compiler for triplet aarch64-linux-gnu (--target=aarch64-linux-gnu --enable-languages=c,c++) on snapshot for 6.1-2016.07, and cannot get past this:
cc1: error: no include path in which to search for stdc-predef.h From what I can tell this may already be a known bug inherited from back in the days of Linaro 4.8. I tried various ways around this, such as trying to create an empty stdc-predef.h in various locations, but always ended up either not fixing the issue or breaking something else even sooner. Is there a simple way around this on the configure command line? If not, is there some recommended edit for this?
Thanks!
Jim Wilson
2016-08-13 23:16:29 UTC
Permalink
Post by s***@comcast.net
I've been trying to build the c and c++ cross-compiler for triplet
aarch64-linux-gnu (--target=aarch64-linux-gnu --enable-languages=c,c++) on
cc1: error: no include path in which to search for stdc-predef.h
stdc-predef.h is a glibc header file that defines macros that the ISO
C standard requires that the compiler define by default. So gcc
includes the file by default for linux targets, unless you use
-ffreestanding or -nostdinc. The real problem here is that you are
apparently trying to build a cross compiler without glibc, and that
doesn't work. Glibc is required for the compiler build when building
for a linux target.

If you have a target OS that already has a userspace filesystem, then
you can create a sysroot that contains /lib, /usr/lib, /usr/include
(and other library dirs if they exist), put a copy on the machine
where you are doing the compiler build, and then use a --sysroot
configure option to point at the sysroot. This also requires that
binutils is configured with the same --sysroot option. If you don't
care about the target OS, you could grab one of the sysroots that the
tcwg team builds and releases.

Alternatively, you can build gcc and glibc at the same time. This is
complicated, because of the circular dependencies between gcc and
glibc, so it is best to use a script. Linaro uses ABE for toolchain
builds.
https://wiki.linaro.org/ABE
But there are other choices, like crosstools-ng and Open Embedded.

I wouldn't recommend modifying gcc sources to work around this, as
then you will get a compiler that doesn't fully conform to the ISO C
standard.

Jim
s***@comcast.net
2016-08-15 03:29:48 UTC
Permalink
Hi,

Thank you, that made me think about what was installed on my sysroot, which was part of the problem (some dev packages had to be added). I added some packages to the sysroot and got the build further along, but for some reason there is still a failure to find pthread.h from standard include locations. Even though all of the pthread dev is installed on both host and sysroot,making pthread.h available in both "/usr/include" of the host and "sysroot/usr/include" of the sysroot, I keep getting missing headers. The "--includedir=" has no effect.

One sample configure I'm trying, where "/mnt" is a loopback mounted clone of the aarch64 system:
${SRC}/configure --prefix=/usr/local/aarch64-linux-gnu/gcc-linaro-6.1-2016.07 --target=aarch64-linux-gnu \ --with-build-sysroot=/mnt \ --enable-languages=c,c++ \ --includedir=/mnt/usr/include
Much earlier in the build with this configuration, long before the build halts, I see this:
cc1: error: no include path in which to search for stdc-predef.h
...I have to wonder why this is even though the compile does not halt (with sysroot it doesn't halt here, but it seems sysroot didn't actually provide its version of stdc-predef.h).

The build actually terminates with several missing pthread.h messages, e.g.:
In file included from /home/build/linaro/gcc-linaro-snapshot-6.1-2016.07/libgcc/gthr.h:148:0, from /home/build/linaro/gcc-linaro-snapshot-6.1-2016.07/libgcc/libgcov-interface.c:27:./gthr-default.h:35:21: fatal error: pthread.h: No such file or directory #include <pthread.h> ^compilation terminated.Makefile:883: recipe for target '_gcov_dump.o' failedmake[2]: *** [_gcov_dump.o] Error 1

Various experiments with "--includedir" options (sysroot/usr/include, sysroot/) in configure failed to change anything. What am I missing? Is this a configure option I need to change? Is this sysroot missing something?

Thanks!

----- Original Message -----From: Jim Wilson <***@linaro.org>To: ***@comcast.netCc: Linaro Toolchain Mailman List <linaro-***@lists.linaro.org>Sent: Sat, 13 Aug 2016 23:16:29 -0000 (UTC)Subject: Re: stdc-predef.h failed during gcc-linaro-snapshot-6.1-2016.07 compile

On Sat, Aug 13, 2016 at 3:17 PM, <***@comcast.net> wrote:> I've been trying to build the c and c++ cross-compiler for triplet> aarch64-linux-gnu (--target=aarch64-linux-gnu --enable-languages=c,c++) on> snapshot for 6.1-2016.07, and cannot get past this:> cc1: error: no include path in which to search for stdc-predef.h

stdc-predef.h is a glibc header file that defines macros that the ISOC standard requires that the compiler define by default. So gccincludes the file by default for linux targets, unless you use-ffreestanding or -nostdinc. The real problem here is that you areapparently trying to build a cross compiler without glibc, and thatdoesn't work. Glibc is required for the compiler build when buildingfor a linux target.

If you have a target OS that already has a userspace filesystem, thenyou can create a sysroot that contains /lib, /usr/lib, /usr/include(and other library dirs if they exist), put a copy on the machinewhere you are doing the compiler build, and then use a --sysrootconfigure option to point at the sysroot. This also requires thatbinutils is configured with the same --sysroot option. If you don'tcare about the target OS, you could grab one of the sysroots that thetcwg team builds and releases.

Alternatively, you can build gcc and glibc at the same time. This iscomplicated, because of the circular dependencies between gcc andglibc, so it is best to use a script. Linaro uses ABE for toolchainbuilds. https://wiki.linaro.org/ABEBut there are other choices, like crosstools-ng and Open Embedded.

I wouldn't recommend modifying gcc sources to work around this, asthen you will get a compiler that doesn't fully conform to the ISO Cstandard.

Jim
Jim Wilson
2016-08-15 20:08:35 UTC
Permalink
Post by s***@comcast.net
One sample configure I'm trying, where "/mnt" is a loopback mounted clone of
${SRC}/configure
--prefix=/usr/local/aarch64-linux-gnu/gcc-linaro-6.1-2016.07
--target=aarch64-linux-gnu \
--with-build-sysroot=/mnt \
--enable-languages=c,c++ \
--includedir=/mnt/usr/include
The problem here is that you are using --with-build-sysroot but not
--with-sysroot. --with-sysroot enables support for sysroots.
--with-build-sysroot changes the sysroot value used during the build,
but does not itself enable sysroot support. So using
--with-build-sysroot without --with-sysroot is useless. This is
mentioned in the install docs. You can specify --with-sysroot=/ to
enable sysroot support, without specifying an alternative host sysroot
dir. That makes the build succeed.

I think the --includedir option here is useless. includedir is
supposed to be for the dir where gcc header files are installed, which
is not /usr/include, but rather $prefix/include. This should not be
necesary but appears to be harmless.

Jim

Loading...