1 year ago

#142389

test-img

Ryan Stankiewicz

GCC: How does GCC disable threading support internally

From the GCC installation configuration docs, you can pass this in as a parameter when configuring GCC.

--disable-threads

Specify that threading support should be disabled for the system

I've done some digging into the GCC source code and it appears that this affects the libgcc runtime library. The header gthr-single.h is dynamically inserted in to gthr.h. If I didn't use the --disable-threads option, then gthr-posix.h would have been inserted into gthr.h instead. The gthr-posix file appears to be a wrapper around glibc's pthread.h header. So here's my question:

By forcing libgcc to use gthr-single.h and therefore by not allowing it to use pthread.h routines, how is libgcc itself affected? Why can't it support building threaded applications if those applications themselves include the pthread.h library file from glibc?

If I do a quick search for gthr.h through the libgcc source code, I see that the frame unwinding code for exception handling, vxworks files (VxWorks seems to be a RtOS), and a TLS Emulation file include it. From what I can tell, none of these files should disable GCC from building code that can use Glibc to create multithreaded programs. Is this all just a misinterpretation on my end of what the GCC docs are saying that the --disable-threads option actually does?

c

multithreading

gcc

gnu

libgcc

0 Answers

Your Answer

Accepted video resources