From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id D4F1C3858D39 for ; Tue, 28 Mar 2023 17:52:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D4F1C3858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4PmHLq0ggHz3hkH; Tue, 28 Mar 2023 17:52:03 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PmHLp6y8cz3qVh; Tue, 28 Mar 2023 17:52:02 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680025923; 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=C9k4TXzkPLd5BbBK/xy3weWPMXNWHIErkXArhcT+bfM=; b=IF+rozzBpYVMO6IVRx4qbvi+v92ulMvgcT0sgICMiBDUW8jEXJLfo+AbM0ACqByp5B/xD4 nvNqs0y5M/HoYMSnG9J6bXKUFx24IPXRb7V/Lqfnk7pHL4MRFZJxX/6ctZYwBS+iKTcoPs Q4RCNxUWk4/DwcAxQ8KZkExORvlJviVNmmRE30fCQld7mplrP4Ri/BtfJOtYxwDTT4j5h9 C898zgcfEz8nAjqigViNPPRBy7vxv9jkdxhBWN3ZI2i7Pog7ONH3Pj2c+5JHQZV2vInIWG SX1xqrt9N0h6wQvB3jbXZSF2+s/PlvUaivGwCLuVwol8XLj5aiwR4yHuqYgjgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680025923; 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=C9k4TXzkPLd5BbBK/xy3weWPMXNWHIErkXArhcT+bfM=; b=NqjkP+QQEXYfLAV3c6KL/TNiWxOSdfyZXP6CQZLOkWD55cj9wZjZiIVYer8h56Wp6ToTTm YNrZh10oOTTK+f8dYsOnHiNYNN1liz/jZkpjNHndirCyzMbJoTGpL7a5yFs/CkuyMDitBo AmA9zkUvwOCwqV4A5botyH2kXzJ4yvLzMooPlem5um5sJYK4ju8KuFsqOTmNUrGvRJjhkv amoBv2lounW3d354TbtK70qE5CMqN8Ia0Q5gohLKYwg0DpoP9CP0tyu4IY7lVAo5svTfdz sNnN59+ix3orGj7rRn+XnBmnn/Jgfc7CoXbSRQ/O4aRVdAv+2xGezsUhNJj6Ow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1680025923; a=rsa-sha256; cv=none; b=v6iIJf0uOiOMDIVJAZLnybo1BNdf5ovghg8Lcg/5L+GFej251BmkHMhTEJC3jlxbU/9zIc wuMOf3MjMgqk9yroRalW37P0xQv0Pvz5pJD3T+25VIDkbS1PD5FWBnB05uYVLfuNx6iBPE i0b4UqDQludaMh13/dfvMJTTBJ+eF6NzK0VYbT9/gVQk7In0w1YrqFOALQbesAlD4zfBx4 4Vi4Epg1YS4Yy32Nd3NfMVUNpfuiCZPePM3myZ86wXlqEf0vTMmxwXUiKMqyUAYLu5beHa 5tantmGmhQOZPe/khngJFO8flsv1ef3JnrPK4Nm6TfJ9NtR2uATqUjCVdce07w== Received: from [IPV6:2601:648:8680:16b0:2d4e:165:cff:1385] (unknown [IPv6:2601:648:8680:16b0:2d4e:165:cff:1385]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4PmHLp2f4bzjtH; Tue, 28 Mar 2023 17:52:02 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Tue, 28 Mar 2023 10:52:00 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] gdb: fix -Wdeprecated-declarations on macOS Content-Language: en-US To: Simon Marchi , 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> <4d64a51b-4a3b-2949-84cd-bbdb528b971e@simark.ca> From: John Baldwin In-Reply-To: <4d64a51b-4a3b-2949-84cd-bbdb528b971e@simark.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP 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 3/28/23 9:01 AM, Simon Marchi wrote: > 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? Hummm, it depends on the prep work. If you are shuffling things like fd's you do that as actions you pass to posix_spawn. However, Tom's point about PTRACE_ME is true that I don't know if any systems have a posix_spawn extension to do that operation. In theory it wouldn't be hard to add such a thing to posix_spawn, but it's not there today. If MacOS does support attaching the debugger for its posix_spawn it might still be better to use posix_spawn on MacOS, but if not I guess we are stuck with plain fork. -- John Baldwin