public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: Jakub Jelinek <jakub@redhat.com>, Jan Hubicka <hubicka@ucw.cz>
Cc: Andreas Schwab <schwab@linux-m68k.org>,
	Richard Biener via Gcc <gcc@gcc.gnu.org>,
	Florian Weimer <fweimer@redhat.com>,
	Richard Biener <richard.guenther@gmail.com>,
	Jonathan Yong <10walls@gmail.com>,
	Nathan Sidwell <nathan@acm.org>
Subject: Re: libgcov, fork, and mingw (and other targets without the full POSIX set)
Date: Thu, 07 Dec 2023 13:50:23 +0100	[thread overview]
Message-ID: <030d6a60148c8ff0334e97d36313ca53c40126ca.camel@klomp.org> (raw)
In-Reply-To: <ZWnNAFgHYIdgjWLA@tucnak>

Hi,

On Fri, 2023-12-01 at 13:09 +0100, Jakub Jelinek via Gcc wrote:
> 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.

BTW. The gcc-fedora-mingw buildbot has been broken because of this
issue for the last week:

https://builder.sourceware.org/buildbot/#/builders/gcc-fedora-mingw
../../../gcc/libgcc/libgcov-interface.c: In function '__gcov_fork':
../../../gcc/libgcc/libgcov-interface.c:185:9: error: implicit
declaration of function 'fork' [-Wimplicit-function-declaration]
  185 |   pid = fork ();
      |         ^~~~
make[2]: *** [Makefile:935: _gcov_fork.o] Error 1

Cheers,

Mark

  reply	other threads:[~2023-12-07 12:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-01  8:02 Florian Weimer
2023-12-01  8:19 ` Eli Zaretskii
2023-12-01  9:00   ` LIU Hao
2023-12-01  9:16     ` Alexander Monakov
2023-12-01  8:42 ` Richard Biener
2023-12-01  8:57   ` Florian Weimer
2023-12-01  9:09     ` Richard Biener
2023-12-01  9:23       ` LIU Hao
2023-12-01  9:23       ` Alexander Monakov
2023-12-01 10:48       ` Andreas Schwab
2023-12-01 12:03         ` Jan Hubicka
2023-12-01 12:09           ` Jakub Jelinek
2023-12-07 12:50             ` Mark Wielaard [this message]
2023-12-08 13:59               ` Florian Weimer
2023-12-10  9:27                 ` LIU Hao
2023-12-11  6:48                   ` Florian Weimer
2023-12-08  8:53 Julian Waters
2023-12-11 12:38 Julian Waters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=030d6a60148c8ff0334e97d36313ca53c40126ca.camel@klomp.org \
    --to=mark@klomp.org \
    --cc=10walls@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=jakub@redhat.com \
    --cc=nathan@acm.org \
    --cc=richard.guenther@gmail.com \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).