On Fri, Dec 01, 2023 at 01:03:01PM +0100, Jan Hubicka via Gcc wrote: > > On Dez 01 2023, Richard Biener via Gcc wrote: > > > > > Hmm, so why's it then referenced and not "GCed"? > > > > This has nothing to do with garbage collection. It's just the way > > libgcc avoids having too many source files. It would be exactly the > > same if every function were in its own file. > > THe ifdef machinery makes every function to go insto its own .o file > which are then archived. So if user code never calls to fork, the .o > file with fork wrapper should not be picked by linker and we should not > have link error. > > If user code calls fork, then the .o file with wrapper should be picked > and we will get linker error on missing fork. So I think it ought to > work as it is now. Does mingw linker behave somehow differently with > archives? Or is there problem with a libgcov being DLL or something?
The problem is that the changes to switch to modern C result in calls to unprototyped function being an error rather than just warning as before. int foo (void) { return fork (); } warning: implicit declaration of function ‘fork’ [-Wimplicit-function-declaration] previously, now error: implicit declaration of function ‘fork’ [-Wimplicit-function-declaration] (by default in C99+). So, as has been discussed earlier, either we should use __builtin_fork () rather than fork (), or we need in configure to test for fork prototype and if missing, prototype it ourselves, or ensure _gcov_fork.o is not compiled on targets which don't have fork prototyped. Jakub