Page 1 of 1
gcc -pthread option support
Posted: Mon Jun 07, 2021 8:40 am
by Hurricane
I'm trying to get a cross-compiler toolchain for my OS.
I'm using gcc and newlib.
I've implemented the required syscalls as well as pthread.
I can't get the -pthread option to be recognized by gcc though. I'm not sure if it's a ./configure issue or if my modding of the sources (following the OSDev Wiki) needs more work.
When I search about '-pthread' I get mostly what it does but not how to include it in the compiler.
I hope someone can point me in the right direction.
Thanks in advance.
Re: gcc -pthread option support
Posted: Mon Jun 07, 2021 3:16 pm
by Korona
Do you have
in your config.gcc?
Re: gcc -pthread option support
Posted: Mon Jun 07, 2021 6:46 pm
by kzinti
Make sure to configure your cross-compiler with:
You might also have to configure newlib for your target. I needed to add the following to newlib/libc/include/sys/features.h:
Code: Select all
#if defined(__rainbow__)
#define _POSIX_THREADS 1
#define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1
#endif
Re: gcc -pthread option support
Posted: Tue Jun 08, 2021 11:21 pm
by Hurricane
Korona wrote:Do you have
in your config.gcc?
kzinti wrote:Make sure to configure your cross-compiler with:
You might also have to configure newlib for your target. I needed to add the following to newlib/libc/include/sys/features.h:
Code: Select all
#if defined(__rainbow__)
#define _POSIX_THREADS 1
#define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1
#endif
Thank you both. Now I only have to find out why I'm getting errors from gthr-default.h
Hopefully it's the last snag on that front.
Re: gcc -pthread option support
Posted: Wed Jun 09, 2021 3:29 am
by Korona
Passing the configuration option should not be necessary if the config is set up correctly.
Re: gcc -pthread option support
Posted: Wed Jun 09, 2021 8:38 am
by Hurricane
I've just finished the build.
Alas "gcc -pthread" prints:
gcc: error: unrecognized command-line option '-pthread'
However, "gcc -v" prints:
Configured with: /home/builder/Projects/experimental-cross/.build/armv6-rpi-experimental-eabihf/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=armv6-rpi-experimental-eabihf --prefix=/home/builder/x-tools/armv6-rpi-experimental-eabihf --exec_prefix=/home/builder/x-tools/armv6-rpi-experimental-eabihf --with-sysroot=/home/builder/x-tools/armv6-rpi-experimental-eabihf/armv6-rpi-experimental-eabihf/sysroot --enable-languages=c,c++ --with-cpu=arm1176jzf-s --with-fpu=vfp --with-float=hard --disable-shared --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --disable-libmpx --with-gmp=/home/builder/Projects/experimental-cross/.build/armv6-rpi-experimental-eabihf/buildtools --with-mpfr=/home/builder/Projects/experimental-cross/.build/armv6-rpi-experimental-eabihf/buildtools --with-mpc=/home/builder/Projects/experimental-cross/.build/armv6-rpi-experimental-eabihf/buildtools --with-isl=/home/builder/Projects/experimental-cross/.build/armv6-rpi-experimental-eabihf/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --disable-libstdcxx-pch --enable-linker-build-id --with-linker-hash-style=both --enable-plugin --enable-gold --disable-nls --disable-multilib --with-local-prefix=/home/builder/x-tools/armv6-rpi-experimental-eabihf/armv6-rpi-experimental-eabihf/sysroot --enable-long-long
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.3.0
edit: I believe I know what's wrong (I think I'm getting a better understanding of gcc's internals). I'll be able to test that in a few hours.
Re: gcc -pthread option support
Posted: Fri Jun 11, 2021 8:01 am
by Hurricane
The last issue was a switch match in gcc/config.gcc that was hitting before my own ...
I've moved my more specific block above it and it finally worked.