On 2022-05-02 05:49, janezz55 (jane...@gmail.com
) [via dj...@delorie.com
> I know a port exists, but for all I know it's an add-on to an already existing djgpp install, so no <thread> header becomes available after installing it. But if pth could be built during build-time of djgpp, <thread> would become available. Does any build script (for linux) feature this? I tried to do the hack myself, but it took too much time. Maybe there's an alternative to GNU pth to get <thread>?
I have some progress to report: it doesn't work :)
Surprisingly, configuring gcc with --enable-threads is actually possible, but
it did require a small patch to Pth. The executables it produces however, will
not run. A thread-aware libgcc will try to lock a mutex in
__register_frame_info(), which is invoked from crt0 before __crt1_startup().
But locking a mutex involves a whole series of libc functions that rely on
things like _dos_ds, which are only initialized from __crt1_startup().
Fixing this would involve reordering the crt0 startup logic. Or maybe libgcc
could be patched to not use a mutex at that point. If you (or anyone else)
want to experiment with that, you can use the following build scripts:
Checkout branch 'pth', then first build a regular toolchain:
$ ./build-djgpp.sh --prefix=$HOME/djgpp djgpp-cvs binutils gcc
Then use that toolchain to compile Pth and build a second toolchain configured
with --enable-threads=posix (this is done automatically in one step):
$ PATH="$HOME/djgpp/bin:$PATH" \
./build-djgpp.sh --prefix=$HOME/djgpp-pth djgpp-cvs binutils gcc watt32 pth
Linking requires -lstdc++ -lpthread -lsocket, in that order.