From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 475AC3857B8B for ; Fri, 1 Dec 2023 08:57:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 475AC3857B8B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 475AC3857B8B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701421038; cv=none; b=INKJDSqo6socs6mSRMSVOJT3FM7TJfp3aPsgojKT20EZYGi/6Lmqp+VLx8zNuM3z9Pzjd4ZyezELh8HCAzKRRd8khYQJu38b5F/tUKOzQ01+QkXfkFwAhW5/IIxQoWmu+fSnkkRiAq2L1EKwtqJYVA3CDb5xT2G4YIl9nftyb3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701421038; c=relaxed/simple; bh=YTArnSCbCCHo/1RV8x8+KDDLAdnw94BnwIXevBv0o8A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=p15q+TMX1Msech7Nfo7gBQjbY+b7kg7vQH+snvdfxboIe/eo5zgwYBcEhQ2wtpQzJtQFuO53xBMuVEeLZKrnuHoT0pjeAaYkyIeb3D+s1dGvDQ6m8haP89G6Ea/XtEeZz1jre9kXQ47DWF0zNeGIlFspT5p43xSCQ1woYfvBNN0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701421034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IPHyotEldkoIaoKTkWkhBrlFpd65zNfyEsIDuQQ3lp0=; b=egHYQw7kJ2SlHyR50HcdfR83y4Sm103n9mg8zxDmoImmLg6UdHIlTNb/Nqr5+z3S63Yr4Y F+kyykRvbZth6mx5Uoxh2yVFlFpuitAPcA9LvCrBdI9ox+tUgGLgRJV2DN6kCxZstafofD iA+LIyrclWi3eWm7LYt5IhAcknDvJHI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-681-ePiiaQ_uMyeqd3FAOjuXcQ-1; Fri, 01 Dec 2023 03:57:11 -0500 X-MC-Unique: ePiiaQ_uMyeqd3FAOjuXcQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 316921C0519E; Fri, 1 Dec 2023 08:57:11 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8C15C1596F; Fri, 1 Dec 2023 08:57:09 +0000 (UTC) From: Florian Weimer To: Richard Biener Cc: gcc@gcc.gnu.org, Jonathan Yong <10walls@gmail.com>, Jan Hubicka , Nathan Sidwell Subject: Re: libgcov, fork, and mingw (and other targets without the full POSIX set) References: <878r6es634.fsf@oldenburg.str.redhat.com> Date: Fri, 01 Dec 2023 09:57:07 +0100 In-Reply-To: (Richard Biener's message of "Fri, 1 Dec 2023 09:42:57 +0100") Message-ID: <8734wms3ks.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Richard Biener: > On Fri, Dec 1, 2023 at 9:04=E2=80=AFAM Florian Weimer via Gcc 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 declarati= on of function 'fork' [-Wimplicit-function-declaration] >> 185 | pid =3D 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 , 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 $(s= rcdir)/gcov.h $(srcdir)/libgcov.h =09$(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