public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Richard Biener <richard.guenther@gmail.com>
Cc: gcc@gcc.gnu.org,  Jonathan Yong <10walls@gmail.com>,
	 Jan Hubicka <hubicka@ucw.cz>,  Nathan Sidwell <nathan@acm.org>
Subject: Re: libgcov, fork, and mingw (and other targets without the full POSIX set)
Date: Fri, 01 Dec 2023 09:57:07 +0100	[thread overview]
Message-ID: <8734wms3ks.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <CAFiYyc1zv2Q5sR42knEh6=v7PhVSWHS-r5KjDi036HRBV3kT2g@mail.gmail.com> (Richard Biener's message of "Fri, 1 Dec 2023 09:42:57 +0100")

* Richard Biener:

> On Fri, Dec 1, 2023 at 9:04 AM Florian Weimer via Gcc <gcc@gcc.gnu.org> wrote:
>>
>> I've received a report of a mingw build failure:
>>
>> ../../../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:932: _gcov_fork.o] Error 1
>> make[2]: *** Waiting for unfinished jobs....
>>
>> 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.
>>
>> 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.
>
> This is wrapped inside
>
> #ifdef L_gcov_fork
> #endif
>
> grepping didn't find me what defines this, but it suggests the solution
> lies there ...

That's just the general libgcc/ coding style, which puts multiple
related functions into one C source file.  The file is compiled multiple
times with different -D options using Makefile rules like this one:

$(libgcov-interface-objects): %$(objext): $(srcdir)/libgcov-interface.c $(srcdir)/gcov.h $(srcdir)/libgcov.h
	$(gcc_compile) -DL$* -c $(srcdir)/libgcov-interface.c

It looks like this is done to emulate -Wl,--gc-sections without separate
source files.  Unfortunately, this is all built unconditionally.

Thanks,
Florian


  reply	other threads:[~2023-12-01  8:57 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 [this message]
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
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=8734wms3ks.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=10walls@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=nathan@acm.org \
    --cc=richard.guenther@gmail.com \
    /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).