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.
gcc -pthread option support
Re: gcc -pthread option support
Do you have
in your config.gcc?
Code: Select all
thread_file='posix'
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
Re: gcc -pthread option support
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
-enable-threads=posix
Code: Select all
#if defined(__rainbow__)
#define _POSIX_THREADS 1
#define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1
#endif
Re: gcc -pthread option support
Korona wrote:Do you havein your config.gcc?Code: Select all
thread_file='posix'
Thank you both. Now I only have to find out why I'm getting errors from gthr-default.hkzinti 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
-enable-threads=posix
Code: Select all
#if defined(__rainbow__) #define _POSIX_THREADS 1 #define _UNIX98_THREAD_MUTEX_ATTRIBUTES 1 #endif
Hopefully it's the last snag on that front.
Re: gcc -pthread option support
Passing the configuration option should not be necessary if the config is set up correctly.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
Re: gcc -pthread option support
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.
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
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.
I've moved my more specific block above it and it finally worked.