I am working on an embedded RTOS on ARM, now I am going to build the GNU toolchain for the ARM in my X86 Linux host (ubuntu-20.04), so I did followings by referring to https://gnutoolchains.com/building/
- Download binutils-2.42.tar.gz
- Download gcc-11.3.0.tar.gz
- Download newlib-4.4.0-20231231
- Download mpc-1.0.3.tar.gz
- Download mpfr-3.1.6.tar.bz2
- Download gmp-4.3.2.tar.bz2
- Download gdb-14.1.tar.gz
Put and extract them into /home/t/testmnt/armtoolchain/, as follows,
@t-VirtualBox:~/testmnt/armtoolchain$ ls -l total 442348 drwxrwx--- 20 t t 4096 3月 21 09:11 binutils-2.42 drwxrwx--- 13 t t 4096 3月 23 18:06 binutils-2.42-build -rwxrwx--- 1 t t 51892456 1月 29 23:22 binutils-2.42.tar.gz drwxrwx--- 38 t t 4096 4月 21 2022 gcc-11.3.0 drwxrwx--- 16 t t 4096 3月 23 19:56 gcc-11.3.0-build -rwxrwx--- 1 t t 143527306 4月 21 2022 gcc-11.3.0.tar.gz drwxrwxr-x 23 t t 4096 3月 22 12:47 gdb-14.1 drwxrwxr-x 17 t t 4096 3月 22 12:53 gdb-14.1-build -rw-rw-r-- 1 t t 41058403 12月 3 13:39 gdb-14.1.tar.gz drwxrwx--- 16 t t 4096 3月 21 10:37 gmp-4.3.2 -rwxrwx--- 1 t t 1897483 2月 1 2010 gmp-4.3.2.tar.bz2 drwxrwx--- 6 t t 4096 3月 21 10:42 mpc-1.0.3 -rwxrwx--- 1 t t 669925 4月 28 2016 mpc-1.0.3.tar.gz drwxrwx--- 9 t t 4096 3月 21 10:46 mpfr-3.1.6 -rwxrwx--- 1 t t 1287202 9月 7 2017 mpfr-3.1.6.tar.bz2 drwxrwx--- 9 t t 4096 3月 22 08:05 newlib-4.4.0.20231231 drwxrwxr-x 4 t t 4096 3月 22 14:27 newlib-4.4.0.20231231-build drwxrwx--- 6 t t 4096 3月 23 18:07 out I firstly configured and built gmp, mpc, and mpfr, and installed them into /usr/local/lib/
Then, I configured and built binutils as follows,
cd binutils-2.42-build/ ../binutils-2.42/configure -target arm-test-eabi --prefix /home/t/testmnt/armtoolchain/out/ make install-strip Then, I configured and built gcc as follows,
cd gcc-11.3.0-build/ ../gcc-11.3.0/configure --target=arm-test-eabi --build=x86_64-linux-gnu --host=x86_64-linux-gnu --prefix /home/t/testmnt/armtoolchain/out --enable-languages=c,c++ --enable-plugins --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --enable-threads=posix --disable-tls --with-gnu-as --with-gnu-ld --with-newlib --with-headers=yes --build=x86_64-linux-gnu --host=x86_64-linux-gnu --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-multilib-list=aprofile,rmprofile --with-headers=/home/t/testmnt/armtoolchain/newlib-4.4.0.20231231/newlib/libc/include --with-pkgversion='GNU Arm Embedded Toolchain 11.3.0' make -j12 Then, I hit the following errors.
make[4]: Entering directory '/home/t/testmnt/armtoolchain/gcc-11.3.0-build/arm-test-eabi/arm/v5te/softfp/libgcc' # If this is the top-level multilib, build all the other # multilibs. /home/t/testmnt/armtoolchain/gcc-11.3.0-build/./gcc/xgcc -B/home/t/testmnt/armtoolchain/gcc-11.3.0-build/./gcc/ -B/home/t/testmnt/armtoolchain/out/arm-test-eabi/bin/ -B/home/t/testmnt/armtoolchain/out/arm-test-eabi/lib/ -isystem /home/t/testmnt/armtoolchain/out/arm-test-eabi/include -isystem /home/t/testmnt/armtoolchain/out/arm-test-eabi/sys-include -g -O2 -marm -march=armv5te+fp -mfloat-abi=softfp -O2 -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -fno-inline -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -fno-inline -I. -I. -I../../../../.././gcc -I../../../../../../gcc-11.3.0/libgcc -I../../../../../../gcc-11.3.0/libgcc/. -I../../../../../../gcc-11.3.0/libgcc/../gcc -I../../../../../../gcc-11.3.0/libgcc/../include -o emutls.o -MT emutls.o -MD -MP -MF emutls.dep -fexceptions -c ../../../../../../gcc-11.3.0/libgcc/emutls.c -fvisibility=hidden -DHIDE_EXPORTS In file included from ../../../../../../gcc-11.3.0/libgcc/gthr.h:148, from ../../../../../../gcc-11.3.0/libgcc/emutls.c:31: ./gthr-default.h:102:9: error: 'pthread_once' undeclared here (not in a function); did you mean 'pthread_once_t'? 102 | __gthrw(pthread_once) | ^~~~~~~~~~~~ ./gthr-default.h:90:19: note: in definition of macro '__gthrw2' 90 | static __typeof(type) name \ | ^~~~ ./gthr-default.h:102:1: note: in expansion of macro '__gthrw' 102 | __gthrw(pthread_once) | ^~~~~~~ ./gthr-default.h:103:9: error: 'pthread_getspecific' undeclared here (not in a function) 103 | __gthrw(pthread_getspecific) | ^~~~~~~~~~~~~~~~~~~ ./gthr-default.h:90:19: note: in definition of macro '__gthrw2' 90 | static __typeof(type) name \ | ^~~~ ./gthr-default.h:103:1: note: in expansion of macro '__gthrw' 103 | __gthrw(pthread_getspecific) | ^~~~~~~ ./gthr-default.h:104:9: error: 'pthread_setspecific' undeclared here (not in a function) 104 | __gthrw(pthread_setspecific) | ^~~~~~~~~~~~~~~~~~~ ./gthr-default.h:90:19: note: in definition of macro '__gthrw2' 90 | static __typeof(type) name \ | ^~~~ ./gthr-default.h:104:1: note: in expansion of macro '__gthrw' 104 | __gthrw(pthread_setspecific) | ^~~~~~~ ./gthr-default.h:106:9: error: 'pthread_create' undeclared here (not in a function); did you mean 'htab_create'? 106 | __gthrw(pthread_create) | ^~~~~~~~~~~~~~ ./gthr-default.h:90:19: note: in definition of macro '__gthrw2' 90 | static __typeof(type) name \ | ^~~~ ./gthr-default.h:106:1: note: in expansion of macro '__gthrw' 106 | __gthrw(pthread_create) | ^~~~~~~ ./gthr-default.h:107:9: error: 'pthread_join' undeclared here (not in a function); did you mean 'pthread_kill'? 107 | __gthrw(pthread_join) | ^~~~~~~~~~~~ ..... ..... I checked the ../newlib-4.4.0.20231231/newlib/libc/include/pthread.h, it has following definitions,
254 /* Thread Creation, P1003.1c/Draft 10, p. 144 */ 255 256 int pthread_create (pthread_t *__pthread, const pthread_attr_t *__attr, 257 void *(*__start_routine)(void *), void *__arg); 258 259 /* Wait for Thread Termination, P1003.1c/Draft 10, p. 147 */ 260 261 int pthread_join (pthread_t __pthread, void **__value_ptr); .... .... 298 #define PTHREAD_ONCE_INIT _PTHREAD_ONCE_INIT 299 300 int pthread_once (pthread_once_t *__once_control, 301 void (*__init_routine)(void)); .... .... 308 /* Thread-Specific Data Management, P1003.1c/Draft 10, p. 165 */ 309 310 int pthread_setspecific (pthread_key_t __key, const void *__value); 311 void * pthread_getspecific (pthread_key_t __key); I googled and found similar issues, one pointed out there should be something wrong in the building system, but I don't know what problem it is.
So currently, building gcc-11.3.0 is failed with enable-threads=posix, how to fix it and build a ARM GNU toolchain with newlib?
Thanks,