在 2023/12/1 16:19, Eli Zaretskii via Gcc 写道:
As far as I understand it, mingw doesn't have fork and doesn't declare it in <unistd.h>, so it's not clear to me how this has ever worked. I would expect a linker failure. Maybe that doesn't happen because the object containing a reference to fork is only ever pulled in if the application calls the intercepted fork, which doesn't happen on mingw.
That's correct. No program has been calling `fork()` in any way.
What's the best way to fix this? I expect it's going to impact other targets (perhaps for different functions) because all of libgcov-interface.c is built unconditionally. I don't think we run configure for the target, so we can't simply check for a definition of the HAVE_FORK macro.I'm not familiar with this code, so apologies in advance if what I suggest below makes no sense. If the code which calls 'fork' is never expected to be called in the MinGW build, then one way of handling this is to define a version of 'fork' that always fails, conditioned by a suitable #ifdef, so that its declaration and definition are visible when this file is compiled.
Makes sense. The target-specific macro `_WIN32` serves that purpose.However `fork()` doesn't actually exist there, and linking should indeed fail. Maybe `__gcov_fork()` shouldn't be defined at all.
-- Best regards, LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature