From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id fKOkDlcPI2RCPxwAWB0awg (envelope-from ) for ; Tue, 28 Mar 2023 12:01:27 -0400 Received: by simark.ca (Postfix, from userid 112) id 27B131E4A3; Tue, 28 Mar 2023 12:01:27 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=bun1caFA; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_HI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 simark.ca (Postfix) with ESMTPS id CB34F1E110 for ; Tue, 28 Mar 2023 12:01:26 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 69AFB3858413 for ; Tue, 28 Mar 2023 16:01:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69AFB3858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1680019286; bh=QwUiFAT46Zxf08617ncHQQ2Nv8FPvuYidhDKzAaJo20=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=bun1caFARjBRUFnguHtCtm883ggSQSEdWIJY/erC/0TfbJBheGjDzTuzYU5BcGNnG PTPxqXjvzE1Pv1x8U/1EIbZhQcMAvZldWIohHPiJtbfMezBsq6z1AAn4qbLQ/85TQo 7UYT1EDBOJRCpuJZ7zNL+04m1/2+c9gA6cr2sH90= Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 20B953858D39 for ; Tue, 28 Mar 2023 16:01:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 20B953858D39 Received: from [172.16.0.146] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id BF2661E110; Tue, 28 Mar 2023 12:01:02 -0400 (EDT) Message-ID: <4d64a51b-4a3b-2949-84cd-bbdb528b971e@simark.ca> Date: Tue, 28 Mar 2023 12:01:02 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] gdb: fix -Wdeprecated-declarations on macOS Content-Language: fr To: John Baldwin , Enze Li , gdb-patches@sourceware.org Cc: enze.li@gmx.com References: <6379554d-4e45-0ff8-a972-47596ea83b90@simark.ca> <7657bb99-0319-ed79-fe2a-fb74a3876798@FreeBSD.org> In-Reply-To: <7657bb99-0319-ed79-fe2a-fb74a3876798@FreeBSD.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 3/28/23 11:10, John Baldwin wrote: > On 3/28/23 7:55 AM, Simon Marchi via Gdb-patches wrote: >> On 3/28/23 10:16, Enze Li via Gdb-patches wrote: >>> I noticed that there are some issues when compiling on macOS. There are >>> a few places where errors like the following are reported, >>> >>> ====== >>> CXX cli/cli-cmds.o >>> cli/cli-cmds.c:929:14: error: 'vfork' is deprecated: Use posix_spawn or fork [-Werror,-Wdeprecated-declarations] >>> if ((pid = vfork ()) == 0) >>> ^ >>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:604:1: note: 'vfork' has been explicitly marked deprecated here >>> __deprecated_msg("Use posix_spawn or fork") >>> ^ >>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:208:48: note: expanded from macro '__deprecated_msg' >>> #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg))) >>> ^ >>> 1 error generated. >>> ====== >>> >>> This patch is only available for the macOS platform. This is done by >>> using macros to differentiate between specific platforms. >>> >>> Tested by rebuilding both on x86_64 linux and macOS Big Sur. >> >> Any idea why vfork is deprecated on macOS? I can't find any answer >> online. >> >> I think it would be good to have a gdb_ util function with the ifdef at >> a single place, with an appropriate comment. I don't know how to call >> this function though. Would calling it gdb_vfork be misleading, because >> it won't always vfork? > > Even if vfork is deprecated, you still want to use it instead of fork I think > as long as it exists. The real fix is to add a patch to use posix_spawn > to fork the shell instead of vfork when posix_spawn exists. posix_spawn is > just a wrapper around vfork + execve on FreeBSD's libc for example (I haven't > looked to see what it is on Linux but suspect it is similar). I guess that using posix_spawn would require some very significant architectural changes? Right now, we fork (or vfork), do some cleanup / prep work, and then exec. How do you do that with posix_spawn? Simon