From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id 02011385AC22 for ; Fri, 1 Dec 2023 09:16:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 02011385AC22 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ispras.ru ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 02011385AC22 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=83.149.199.84 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701422195; cv=none; b=ma+x/764PUWmYOD2dKmXHpfxJhzxCRQmE6Ll9aWGrwA/5rWOeA1KwfrOau4it6mVXaRCah2H+fExh6jcJfJQIMv50yCwZ0LPk3ognNUrAKIS+qKEYR5KB4PTS259NqZ/Ppl+0x3O59TQARDZy8MHx+MO+LbRAj1LVCEh12bnmjU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701422195; c=relaxed/simple; bh=kG+nKEEz50I3juUQBZYKfE1LoPuMSE+ON0iyzgG8AEs=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=Pp83NjI/CM1NnIX+w9bincLss8BeA1Rm9ZVTPZvhXGmg72gw9jaMA6CeRfPmhj76UPZRtJYHhwcqAjQRLX0ADW60uUUzuGNT5/w7B2PTtxoERlWmDMPBpFS0EcW4kHv9DcVcL37yWhh7S5OgZuhA0nA22vbouHHceFussuhGCk0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.10.3.121] (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTPS id 49CB840F1DD8; Fri, 1 Dec 2023 09:16:31 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 49CB840F1DD8 Date: Fri, 1 Dec 2023 12:16:31 +0300 (MSK) From: Alexander Monakov To: LIU Hao cc: Eli Zaretskii , Florian Weimer , gcc@gcc.gnu.org, 10walls@gmail.com, hubicka@ucw.cz, nathan@acm.org Subject: Re: libgcov, fork, and mingw (and other targets without the full POSIX set) In-Reply-To: Message-ID: References: <878r6es634.fsf@oldenburg.str.redhat.com> <83y1ee9vww.fsf@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,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: On Fri, 1 Dec 2023, LIU Hao via Gcc wrote: > >> 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 pretty sure configure runs for the target, but for musl-cross-make it would be nice to limit it to declaration check rather than link test (musl-cross-make installs libc headers, then configures and builds gcc and libgcc just once, then builds libc, then builds the rest of gcc target libraries, IIRC). > > 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. A possible stop-gap solution is using __builtin_fork() instead. Alexander