Reputation: 917
I'm currently trying to compile my own gcc 9.1.0 cross compiler for aarch64-linux-gnu
target. I used this tutorial: https://wiki.osdev.org/GCC_Cross-Compiler
The compile progress for the gcc and g++ compiler seems to finish without errors, but allways when I try to compile libgcc
with the command make all-target-libgcc
I run into this error:
In file included from ../../../gcc-9.1.0/libgcc/gthr.h:148,
from ../../../gcc-9.1.0/libgcc/libgcov-interface.c:27:
./gthr-default.h:35:10: fatal error: pthread.h: No such file or directory
35 | #include <pthread.h>
| ^~~~~~~~~~~
compilation terminated.
g++ --version
on my build maschine prints:
g++ (GCC) 9.1.0
Copyright (C) 2019 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.
And my configuration command for gcc
is:
../gcc-9.1.0/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --without-headers
With:
export TARGET=aarch64-linux-gnu
export PREFIX=/opt/aarch64-linux-gnu
What do I forget?
Upvotes: 4
Views: 6378
Reputation: 782
When bootstrapping to a new architecture, there might not yet be any C library available. In this case, adding --disable-threads
to the list of configure
arguments will get you past this specific error message. But also: if you don't have a libc yet, you will need to add t-slibgcc-nolc-override
to tmake_file
in gcc/config.gcc
. Of course, this may lead to further problems down the road, but such is the nature of bootstrapping.
Upvotes: 0
Reputation: 2172
From GCC installation manual:
In order to build GCC, the C standard library and headers must be present for all target variants for which target libraries will be built (and not only the variant of the host C++ compiler).
So you need a libc for aarch64.
If you want to build it yourself, Preshing has a good article on the topic, which I haven't read in full but recommend anyway. He even has a picture mentioning both pthread.h
and libgcc.a
.
AFAIK, GCC can pick up a symlink to newlib
sources and build it automatically during the course of building a full cross compiler with target libraries. Not sure about Glibc.
Upvotes: 3