I need to use the C standard to compile with my POSIX implementation. I downloaded the precompiled lib of gcc-11.2, but after unzipping, I am facing libgcc.a and libc.a libraries.
I tried to compile with libc.a, but <stddef.h> is missing. I compiled with both libraries, and it solved the inclusion issue. But a new issue has arisen: the function clock_gettime() isn't being referenced. This function is defined by POSIX (Real Time) as an extension of time.h. I need this file and function for my implementation. I checked with dumpobj on libc.a and libgcc.a, but the function is not present. So, it seems that libc.a has been compiled without the function. A solution can be to compile the GCC sources with the -D_POSIX_TIMERS flag (clock_gettime is defined if _POSIX_TIMERS exists) ?
I don't understand why there are libgcc.a and libc.a instead of one library, what is the difference between these libraries ? And is it possible to use a POSIX function defined in the GCC library without including all the other POSIX features to prevent conflicts with my POSIX implementation ?
libgccis a low-level runtime library, that is used bygccinternals "automatically". Whilelibcis the implementation of C library, that is library functions callable by the "user"..aversion oflibc. On linux [at least], you want the shared.soas well. Particularly forclock_gettimebecause (for optimal performance) it's in theVDSO(code injected into the user program by the kernel). See my answer: __rdtsc/__rdtscp for ARM Mac M1/M2?