2016-04-18 1:03 GMT+02:00 David Grayson <[email protected]>:
> I'm not an expert on GCC internals, but maybe I can give you some clues
> (which might not be totally accurate).
>
> The function clock_gettime is defined in the mingw-w64 source code.
>
Yes and I wonder why, because I don't see this function related to threads.
> You can see the source code of that function it in the git repository
> git://git.code.sf.net/p/mingw-w64/mingw-w64 inside
> mingw-w64-libraries/winpthreads/src/clock.c.
>
> (Your example code has the wrong prototype for clock_gettime, by the way.)
>
>
> Yes, but that was extracted from some configure script, which only tested
for function existence, so not a problem.
If you compile with the "-v" option, you can see that in the last step, GCC
> invokes the collect2.exe with a lot of arguments specifying libraries:
>
> -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread
> -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh
> -lmoldname -lmingwex -lmsvcrt
>
> I'm not sure where it gets this list of libraries, but it might be
> hardcoded or it might have something to do with the specs file that you can
> see by running "gcc -dumpspecs".
>
Thanks, this is what I was looking for. The days when I compiled gcc myself
are gone for long. Forgot about those specs files.
There is one specs file which is hardcoded, and an option to pass another
one on the command line.
If you run "objdump -t libpthread.dll.a | grep clock_gettime", you can see
> that there are two symbols listed, clock_gettime and __imp_clock_gettime.
> I'm not sure what is going on there, but somehow libpthread.dll.a contains
> code for loading libwinpthread.dll at runtime and actually executing the
> functions inside it, and that code gets included in your executable. If
> you compile with the "-Wl,-Map=prog.map" option you can see more info about
> __imp_clock_gettime and clock_gettime and where they got placed in your
> program.
>
The __imp_* are the stubs in the static part of the dynamic library that
get linked in the executable. They are resolved when the dll is loaded.
Thanks,
Fabrice
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Msys2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/msys2-users