From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2047.outbound.protection.outlook.com [40.107.105.47]) by sourceware.org (Postfix) with ESMTPS id 5F90F3858D1E for ; Tue, 20 Jun 2023 12:31:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5F90F3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ACgET8FVt358wS7RoBbk6QLVjQpj4dma3b4NptRCI8c=; b=48p78w3hiLgjHGGTJQrhScMULpUOYpW5ntlzjTEbWtIhmDOiAXfjz9yhG5c31Cv4VDYchlP36hWCITfB4c2D7FD0je7WNaNlVNP71JuMe0rQchrzEroLjtIOeB4w7kjkdICSmzELUYARsct9j0MN8ydaKvwSFX/kvKs3wgq8pyY= Received: from DB6PR07CA0103.eurprd07.prod.outlook.com (2603:10a6:6:2c::17) by AS8PR08MB6392.eurprd08.prod.outlook.com (2603:10a6:20b:31a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.37; Tue, 20 Jun 2023 12:31:19 +0000 Received: from DBAEUR03FT031.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2c:cafe::60) by DB6PR07CA0103.outlook.office365.com (2603:10a6:6:2c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.20 via Frontend Transport; Tue, 20 Jun 2023 12:31:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT031.mail.protection.outlook.com (100.127.142.173) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.21 via Frontend Transport; Tue, 20 Jun 2023 12:31:19 +0000 Received: ("Tessian outbound 3570909035da:v136"); Tue, 20 Jun 2023 12:31:19 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1e07d25dedaa1a34 X-CR-MTA-TID: 64aa7808 Received: from 6169d71acc07.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 78817CAB-91A9-4E72-A44C-2A3ABCFCD7BE.1; Tue, 20 Jun 2023 12:31:12 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 6169d71acc07.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 20 Jun 2023 12:31:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n9pIxi4X5eCRi7FvZtiaXozcjxDS26WfNe4Je8QVHf4IrXkrLHW+EUpJU1A4v3ZzCFnblNHJXiRrfJrsSb0EWdVW1JmaUD23WUCC3BCe8Htwn27A0zTwvUuU/a+VPL4LOvRJ4li3dwBOR0LllfUBDjEr8MrN4Q6cAV+8TDnH3+ZLISAdSwMmHyRITAQfvJPNWqdW41Jrcd636YW3tLd35NDN+QgKlz7zo89IWSWhxabTvj10Uq6bnG/PmP3l5iIV3PWF1cSEgKPby3rp1b8IskG94ux5vEOKBKHO+0iZgtPz3jNz5VXBFcTMXVAxPAGbolY/w8velmiCW0sxuyZFxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ACgET8FVt358wS7RoBbk6QLVjQpj4dma3b4NptRCI8c=; b=I+a1VkoawGCwVniq2ijaPB1P2KqbUncQvBIsqgbApcP7NLkshUZhrTQ891TGAL6iICZDwukF7TCQGbxymHEjjBAvqIHcc+Xru99/6mEpT4/tL1nHSriSWTyHllFYasQz5gl6a7QDDUAtAruJr5XKiAfelXnVZV9a8wL4rMA1KlYQZVZp10ZW9GuEKCeIQ3XbHiDSLUWmK2P5O18++hIquD20+tacMxaZzhAG0yPeeoB6A3IXTrxu5f53Nd3MIYnNBsjxSrwvPpzErpJt/oRQMD48aip5zz7TkfyrISQsF3hEwvDcsk2povotYI4V2v7dPQJ6RXujt0Do7vxovIv5tQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ACgET8FVt358wS7RoBbk6QLVjQpj4dma3b4NptRCI8c=; b=48p78w3hiLgjHGGTJQrhScMULpUOYpW5ntlzjTEbWtIhmDOiAXfjz9yhG5c31Cv4VDYchlP36hWCITfB4c2D7FD0je7WNaNlVNP71JuMe0rQchrzEroLjtIOeB4w7kjkdICSmzELUYARsct9j0MN8ydaKvwSFX/kvKs3wgq8pyY= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) by DU2PR08MB10262.eurprd08.prod.outlook.com (2603:10a6:10:46e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6500.35; Tue, 20 Jun 2023 12:31:09 +0000 Received: from PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::202a:45b7:3be8:47d5]) by PAWPR08MB8958.eurprd08.prod.outlook.com ([fe80::202a:45b7:3be8:47d5%6]) with mapi id 15.20.6500.036; Tue, 20 Jun 2023 12:31:09 +0000 Date: Tue, 20 Jun 2023 13:30:59 +0100 From: Alex Coplan To: Iain Sandoe Cc: GCC Patches , Joseph Myers , Jason Merrill , Nathan Sidwell Subject: Re: [PATCH][RFC] c-family: Implement __has_feature and __has_extension [PR60512] Message-ID: References: <77197F1C-5183-4F12-8701-83ACFF5FC96F@sandoe.co.uk> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <77197F1C-5183-4F12-8701-83ACFF5FC96F@sandoe.co.uk> X-ClientProxiedBy: SN4PR0501CA0112.namprd05.prod.outlook.com (2603:10b6:803:42::29) To PAWPR08MB8958.eurprd08.prod.outlook.com (2603:10a6:102:33e::15) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: PAWPR08MB8958:EE_|DU2PR08MB10262:EE_|DBAEUR03FT031:EE_|AS8PR08MB6392:EE_ X-MS-Office365-Filtering-Correlation-Id: a0e627d7-3fe8-4d7e-16c0-08db718a3fc2 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: A0tTK8wqmx8m0QTOzNvkpTnu0DFbUJkYs31VfcpaSqrdJwQwWm2PHr+5v13WF06vsDhoFvc6GB+Zhh57+MLbgNIDQjZQSMIJw8JbfZsFzA9VGJwJituGUfqYup+2k3621VRth9BCI0JoFiGNX9LJFIQPEqBKs6afaqOYflxdKE0AizdiWWj97nM+hI1v5/w9DsYdFP53EHNi+MLuihe1HrTm4tC3YpVNuueOPeZSVyebtIFAyF/bBEe/e6N6O+JfkqU8htKMxN9EO2nobml2g6cNDBpymCbzPkoNOiErk29Jyki+noeeNAqq9VCqupfVElffuKprZOJKpEoZVXE6q67cjXyZddmsVzDJrpIOi/dEMIMT7pJYX1ACA8zZ9QpkX7+KfeIz5k2ksnFW2lXwYFwBsUiUTXtDjqL3/qKWtI04I0xv8btG6vAHpQj1XecxBzL52s9o0H4U2PxxTwjqIkSfZDzHM3H1Qg2OW4gT+weg//3GhpY6liJM4BFuVgNzmXPWFdJnGkfprkVXYttUj/9o79TxPwK8f3RC54fAEN8= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAWPR08MB8958.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(376002)(39860400002)(346002)(136003)(366004)(451199021)(2906002)(478600001)(44832011)(5660300002)(4326008)(41300700001)(6916009)(66556008)(66476007)(316002)(54906003)(66946007)(186003)(6666004)(6486002)(8936002)(8676002)(53546011)(6512007)(6506007)(26005)(83380400001)(2616005)(66899021)(38100700002)(86362001)(36756003)(966005);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB10262 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c9f23797-f6dc-4b52-1c5e-08db718a3976 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CawqbadOfED93rRJENesgCfEFhLpVgVOGXEkigNlk22H2eFmtCvW1lSfKZMLqK4hkhFMLmCIKayRa6hgtiMSjKksSiZIgRnJF5ALjLdr0whD90kFFDqKOZc0lvVuhNysUkNZOg5SNLXtVUIqQk5F23RUkjg5+elqrShiHs2ewVx5vvKJhkq+nU2STs+coA3yQH3V9WkdhvkwHcTpQaU4t0VO/CVdWcIygZennwrX3/UiPyH+F/rPLASXzG4MXvC+wk9cMSxwLMbgI5N6QmnciOiJ12beZP87Zhl5sAKQEZp9u7LuEKOxxq9xzl3uVZ0JgXvTSUKnDF8q60n8uscW10bDvxqDoKPDOrYr0D3Y3QxsuKS6YLjfP411CZdLsawKjddQaG2GlfVt2giypLhlVZiQ5ihUMSNN7cEsLa9+Hy8I/k5Zd/jbGhUUUKrsFHmxGZO4r3NTy8VJRSbn8LtVb7DrjkDuYPNyzqcRQuqZpN/O3DCKrc7oI1DqBc20Qm7BtVet+YDuKwSizipfNYIobMeYpnBLwwxZC5jqfEZI3WkGyocI2ZVdo6ruB0G7VOXzfTQnLFck8JgmRVSkQR/CRdsLDHtJagvK4LBXKZ4uCrVqcagqW/pOAG/HtRef2OBdIjn1TaTXOcq6F8LohYqFk4AaQqC7Kz6uMV+wIG8MxESS7A9v34u83tLR1SuS6sMXFBJ8pMQdQTgUpuLkNkvQfJM90CNBYD80BxSVX3mDD5c= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199021)(36840700001)(46966006)(40470700004)(36860700001)(336012)(83380400001)(40480700001)(66899021)(40460700003)(82310400005)(36756003)(44832011)(70586007)(70206006)(4326008)(54906003)(6506007)(6862004)(6512007)(53546011)(2906002)(5660300002)(41300700001)(8676002)(8936002)(86362001)(47076005)(81166007)(356005)(82740400003)(316002)(26005)(6666004)(478600001)(966005)(2616005)(186003)(6486002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2023 12:31:19.2010 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0e627d7-3fe8-4d7e-16c0-08db718a3fc2 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6392 X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Iain, On 14/05/2023 17:05, Iain Sandoe wrote: > Hi Alex, > > thanks for working on this. > > I’ve applied this patch and evaluated on a few Darwin versions (which is the > target currently most affected, I believe): > > > On 9 May 2023, at 13:07, Alex Coplan wrote: > > > This patch implements clang's __has_feature and __has_extension in GCC. > > Thanks, this blocks consuming Darwin SDK headers “properly” (PR 90709 as > linked to 60512) (which is why I had a WIP patch too). > > So I am very keen to see this land in GCC-14, but have some issues to deal > with and would be looking for ideas about how to handle them by extending or > amending the patch. > > The main concern I have at the moment is that it seems to me that we need > more flexible and general predicates for declaring feature/ext support: > > a) on target (see below for examples) > b) on potentially multiple flags and language version at the same time (see below) > c) what about features that exist for a closed range of language versions? > > As mentioned by Jakub in a conversation about this on irc (months ago!) the > current identifiers potentially clash with use symbols. > > IFF we add feature designations (which IMO we should, since this approach does > help simplify testcases and configurations) we should add them into the > implementation namespace: > > e.g. ( for C) > _GNU_nested_functions or __nested_functions > > > Currently the patch aims to implement all documented features (and some > > undocumented ones) following the documentation at > > https://clang.llvm.org/docs/LanguageExtensions.html > > TL;DR > without guards or target-specific opt out this breaks bootstrap on Darwin. Thanks for trying out the patch and pointing this out, this blocker has now been addressed by relaxing the C++ parser as per g:b106f11dc6adb8df15cc5c268896d314c76ca35f. The patch can now survive bootstrap on Darwin (it looks like we'll need to adjust some Objective-C++ tests in light of the new pedwarn, but that looks to be straightforward). > (one reason to allow target opt-in/out of specific features) > > > with the following omissions: > > > - Objective-C-specific features. > > I can clearly append the objective-c(++) cases to the end of the respective > lists, but then we need to make them conditional on language, version and > dialect (some will not be appropriate to GNU runtime). > > this is why I think we need more flexible predicates on declaring features > and extensions. Would it help mitigate these concerns if I implemented some Objective-C features as part of this patch (say, those implemented by your WIP patch)? My feeling is that the vast majority of extensions / features have similar logic, so we should exploit that redundancy to keep things terse in the encoding for the general case. Where we need more flexible predicates (e.g. for objc_nonfragile_abi in your WIP patch), those can be handled on a case-by-case basis by adding a new enumerator and logic to handle that specially. What do you think, does that sound OK to you? > > ---- > > index 2b4c82facf7..5b8429244b2 100644 > --- a/gcc/c-family/c-common.cc > +++ b/gcc/c-family/c-common.cc > > +struct hf_feature_info > > + { "enumerator_attributes", 0, 0 }, > + { "tls", 0, 0 }, > > Do all GCC targets support tls? This is a good point. In clang, the features tls, c_thread_local, and cxx_thread_local are all gated on whether the target supports TLS. But in clang, it is a hard error to use TLS variables on a target which doesn't support TLS. So it seems the features are used to check whether code can make use of TLS constructs. In GCC, AFAICT, TLS variables never get rejected, since GCC just uses emulated TLS in the case that the target doesn't support TLS for real. This then begs the question of how these features should be interpreted. For c{,xx}_thread_local I'd expect that we want them to return true whenever the language-level constructs are useable (even if we end up using emutls). I think it's defensible to take the position that GCC "always supports TLS" since (AFAIK) you can make use of thread-local variables regardless of whether the target really supports TLS (since you just get emutls if it doesn't). So it's not clear which interpretation we should use for the "tls" feature. > > What about things like this: > > attribute_availability_tvos, > attribute_availability_watchos, > attribute_availability_driverkit, FWIW, clang looks to define these unconditionally, so restricting these to a given target would be deviating from its precedent. However, I don't think it would be hard to extend the implementation in this patch to support target-specific features if required. I think perhaps a langhook that targets can call to add their own features would be a reasonable approach. > ? > > Even if they are implemented centrally, it is unlikely that all targets would want > to claim support (although note that the availability stuff does seem now to be > used on other platforms - like android, zos and hlsl.) > > (non-bug-related reasons to consider target-specific predicates) > > === > > Once again, thanks for working on this - and I am keen to see it land, > Iain > Thanks, Alex