From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2060.outbound.protection.outlook.com [40.107.22.60]) by sourceware.org (Postfix) with ESMTPS id AE6273858CDB for ; Wed, 10 Apr 2024 11:04:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE6273858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AE6273858CDB Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.22.60 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1712747089; cv=pass; b=tzDxGAv5/9pqmC7M+MP6nfbY0gBzFdrDI44iRRCUef2bPNyB9Oc/jWrfNuC3xBdb3Pmymk1fvQURz+rP4rrzCcDnPDtKuExe+tzZW/X1vI6pRzmdjNiBDNdZGxizZMr70yCPbYLwRH5yXJd33pl3Z5yjbKO++9kMVIsgxMSi0wA= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1712747089; c=relaxed/simple; bh=lKwj+aU7RVIl+3b3ORkazyLn4iCqQ1nim20/966XiAs=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=UQbbHC7MWuh9Z/1B5RfbOcAQDIo4MNq3JZo3UrGFXZu4It5GVYPEuJey8glCRjiFJfznnJ78zlI66zWEmURKNbvsiX3SR+urbDNr/oj212OZMBQ97TOFM/AAOqB7tP7nvW9nLWOJsmMPTyRWf7uUvfR6pLXah4VG/n/EW9e6/g0= ARC-Authentication-Results: i=3; server2.sourceware.org ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=kFANoLo6QDrTG4AcG+B+VqQOzVHTocpXUgn+j1RxzLgOxbh7BL2IlbpV3oJuu37TNnpEBUfudLNfdzHWE1BnmtvUsUas79K0uODGfxSZveA55UUS5X747911nyjullidCC5JuQgdj/wgKEpGbjQRxfwCWErX5w3SkOwMDTxs0ozywiwbN8AvPudzfeL5OXxhgUuSxTSlOFJrFEtaiN2Nz53XxopkJS8tGWJWwKe/V4ch+qje0qop3SAlJOCiJ/6gLEk/yyVvkQLa30AnHuTFcOTMXgZl3p2nc07PIbBcL4agwuad3WUNG0EQyrxgvr/MP4EmxZpc+VUSSoV6oK+HOg== ARC-Message-Signature: i=2; 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=S8rN/sBaLYPiDiKSiROfuxC5COk3f+Dg5NHTaqnyJ4E=; b=C8uzbKqQ3ZSklEawhcUFq/e7t2DoEyXX3x62fYdGbODAwHXXDfHkAftxA0BAMCwuMm2EoFQ7g3/jvKj/VHNr8dvySFxNUEd+dv9KgsCWVzySVqFNV7rQxfVtEfFoXPYWz3K6YOeBNSMGOlkaATV1jbx3KyNE6fpFj9L/X7BJoV8b4U3SnoSOxCQWVVFKVyneQ7NUCdrtQV//OrMCqxj66AE5UqxfnlQOnzgQDb1jQkdXyytHBZ0vZQCjzrjXpgmrmummqLRPreWuoc/sg+K9XxZnHnxR7ZtI1Vi4zuPuaNjsKoldRGXshaUx+neEJ3Zl3hp9syS8vX6vDteE6jnD3Q== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=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=S8rN/sBaLYPiDiKSiROfuxC5COk3f+Dg5NHTaqnyJ4E=; b=53MGmtAQiZCl5ymiYOTUDDlVoA8CLsHCSHt+I8QREQs6RtOUXa+Xdm4KgXZPjl87RTcM4+Y5oRWYU1spzLcGPDJ4Pz7JPEcWhJIIKxPBprVAxODnq/tykGlHmTwQOcLwmx9n7WVVe58hU7mdqRmyJ+gx8mwmtkKiC3+BerMLG6s= Received: from DU7P191CA0013.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:54e::17) by AM7PR08MB5462.eurprd08.prod.outlook.com (2603:10a6:20b:10b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Wed, 10 Apr 2024 11:04:45 +0000 Received: from DU6PEPF0000A7E3.eurprd02.prod.outlook.com (2603:10a6:10:54e:cafe::d1) by DU7P191CA0013.outlook.office365.com (2603:10a6:10:54e::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.19 via Frontend Transport; Wed, 10 Apr 2024 11:04:45 +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 DU6PEPF0000A7E3.mail.protection.outlook.com (10.167.8.41) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.7452.22 via Frontend Transport; Wed, 10 Apr 2024 11:04:44 +0000 Received: ("Tessian outbound 1b0f2681ce6f:v300"); Wed, 10 Apr 2024 11:04:44 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: bfa07c7016b1177f X-CR-MTA-TID: 64aa7808 Received: from 952b1c18a72e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F5D81957-FB5A-4875-8665-50A17ECFDD53.1; Wed, 10 Apr 2024 11:04:38 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 952b1c18a72e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 10 Apr 2024 11:04:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nSz71fNwhfxZxoIE/PV0noGUmYx19WIt/jtfKM2alGescox3eVJMYWnYSxCkThfhswLQwOgHipiYKnOxDfaOW4gAEAm5meOZaSOV3HeelLk/3M2W/GGJDOpsnFw6RSdOSD9BxP8BtJpQND9cR1BMLXDwLfsXNu11G4G+U/eUzYr1NoOFFNUcxL7qDPCEpr4V/kMM61K7WC1QnvwSGm4oQGaTWZaYMS3F5EKE+voKuTrTLS6Hi/1UMMS/dl0Wz+2lBr9+wXZkyXWWpkXKb+sK5hYADKGQxq5YuiYt3qs/Gd5xEWpqL7ovE/skmuoAKNSKsOo6hn9xx8AFS/w+nUBaIw== 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=S8rN/sBaLYPiDiKSiROfuxC5COk3f+Dg5NHTaqnyJ4E=; b=Yv7EJw1zBwl6FdiForSRsDbj6jcNIwDq9pl+cI48aRJsvvJU7nGipXpAKPjHQmmXvY0TpGy6wRh3KKc6QIGZN9qC999y5UwxlbuUmqo2S30t/cVVme/grIp8Jy2fDriKOGjtITOVq9UWboHiIEbV2ppU4CcYaNqp0c00YS82+av4zioVdqUCPUxnL7aFeD0y9ca2sSqOV4VKtT7JpeHcNfIz9pCgcsZYkxI2aZpNoelVYmS1hovQs6lJXjSo/ybUFdEo3CN47N6LeH9jes3ghCR/5brLLKmcA64ytTCHifnwvLu8y9N7p7EaXhoerJxxmQLdt0JjTqcJKILIWlLpdw== 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=S8rN/sBaLYPiDiKSiROfuxC5COk3f+Dg5NHTaqnyJ4E=; b=53MGmtAQiZCl5ymiYOTUDDlVoA8CLsHCSHt+I8QREQs6RtOUXa+Xdm4KgXZPjl87RTcM4+Y5oRWYU1spzLcGPDJ4Pz7JPEcWhJIIKxPBprVAxODnq/tykGlHmTwQOcLwmx9n7WVVe58hU7mdqRmyJ+gx8mwmtkKiC3+BerMLG6s= Received: from DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) by DU0PR08MB10326.eurprd08.prod.outlook.com (2603:10a6:10:472::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Wed, 10 Apr 2024 11:04:35 +0000 Received: from DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::8c23:46ef:c2c9:ea91]) by DB9PR08MB7179.eurprd08.prod.outlook.com ([fe80::8c23:46ef:c2c9:ea91%4]) with mapi id 15.20.7409.042; Wed, 10 Apr 2024 11:04:35 +0000 Date: Wed, 10 Apr 2024 12:04:19 +0100 From: Szabolcs Nagy To: Matheus Afonso Martins Moreira , gcc@gcc.gnu.org Subject: Re: [RFC] Linux system call builtins Message-ID: References: Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-ClientProxiedBy: LO2P265CA0449.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:e::29) To DB9PR08MB7179.eurprd08.prod.outlook.com (2603:10a6:10:2cc::19) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DB9PR08MB7179:EE_|DU0PR08MB10326:EE_|DU6PEPF0000A7E3:EE_|AM7PR08MB5462:EE_ 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: 8Y5PziTMpOelQ/UDMMQSgoFM0v2Wnl4LZzqgAY1vrQKkyXr9eoSux1gL3XXUcHltYNKTlrQ63b+13H2gaCAsEGKJStmMM8fOmHH2VAeh2uLp9pTKZKBkSkEWhhTWS8bYXXezpyqt8qmxDMK5QtLUts7D4viSrZr7b4OQqZUdFJwlOxsVbkBI0ZDD+xoGDDTLS6f3I4K7JDMUUWwnczhbrmKM1nCWDjdEcTnzumgD4sJT314pGtM7GWgGfYU2dVDTA/5OfyBHhTraQGI38vUIv0aCABKPP5cr8cyXs7kQ5qoltRE/1HPKM0BJzfgRnbFHfev7HYzlozb9yVlPlsz6Ic6inMAL8yR7zaFUMoqIPTi/JclasY2rYgiCDtfehguud27x9qeCslBE/Z/5w+QZWwYrsClDVOZ98rkQi84jCYmkGwYDxG96yS6Fscrn1Bbkj9KbZ16NT59N7kfISxbjHETdp8pNOexfGvKrZGyEESdvj8ZSuOZ+nj057Elg8JdlVWu1mj7qVNqTrf7Hc5+FiQstthhDnx7UK5UVVJK5MaQy5APqpggLvJZ/1DnTaZ8undSQT0TT2gMreb2TN3d45j/6zJS73sdNp6x0TSp7hXMYOu5TorSkx4An4Vo335LiekVwbHV02PGdyBGiSAotPJWddmZt/8zzfYtnERaKGsc= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR08MB7179.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(1800799015)(376005);DIR:OUT;SFP:1102; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB10326 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DU6PEPF0000A7E3.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2f198883-8b53-4238-f76e-08dc594e0798 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ToRPaFMiFvBpme8ZRI++18977u1MbB5XVRB/t/szpvtVZGIGhu1+lXBwwV50lknw13kA5bYRw3wPo5Jf6gNky33Or0LZOasFRHbAld1BUZW8/C2CdlXCj3K0taPP2/OXqxc2t54Kr6ZZUfQRTM4Cu40uUI7X9WoeVhMhl2u1EvDAoeKftMaUu+al0frvBuY63DOk/n8Zo7S1zbZmlA7U3r/+4tubmeSZ3R88oRhSw7ZEF01fX/M47oaXn3+ux7AwYFcg0EB+GcJmTFsVYkMc4STid6zwcUYOX2yu3SpM/OgFSrz77K8v7Ta12dUBbes442A7TWbJJeb9Al5YNhWokX2mFZ4jYSlmYIa8MjuaFRPM+QrnisUyLX/qLYyA/Zo3gnLe9VPvQIaa3x3Bl1yv6iBhR1M7vQgNiBGp1n/PWE2v73B93N+SCOJSXC1jz5IdyN3hK3HSd6K4OFnvxaPmzowM1QJcXIdpMWyGfINCNA0c/+F/5k6CkoJcp3TU90gZhpQ1AjznRfTl7uuTszJAZDcakdnKlIGATJCqaB2T0k6LzGnSowxk9DDh3pqflCI6YrNRGQBuDXKFCM2mYn2iPkT2z4ZRHnrxz8O66SnyBEV28oH2sodONRO6zXKrd4NVk+ku83c50K8G51wVGQ1+gSAdz2k9KKHiYvgFzhf+/NDQzhhNJ9n0MJfjZENdNNKgXDbkGwjhY5ovt7Bow7AMEwbHfaSkpa99JO2swKFLgy+aXaD67RROGnbtTqB8XdHpWmc/22V2R1PWvtO/EfgrSA== 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:(13230031)(1800799015)(36860700004)(82310400014)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Apr 2024 11:04:44.9398 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f198883-8b53-4238-f76e-08dc594e0798 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: DU6PEPF0000A7E3.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5462 X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,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: The 04/09/2024 23:59, Matheus Afonso Martins Moreira via Gcc wrote: > > and using raw syscalls outside of the single runtime the > > application is using is problematic (at least on linux). > > Why do you say they are problematic on Linux though? Please elaborate. because the portable c api layer and syscall abi layer has a large enough gap that applications can break libc internals by doing raw syscalls. and it's not just the call convention that's target specific (this makes the c syscall() function hard to use on linux) and linux evolves fast enough that raw syscalls have to be adjusted over time (to support new features) which is harder when they are all over the place instead of in the libc only. > > The ABI being stable should mean that I can for example > strace a program, analyze the system calls and implement > a new version of it that performs the same functions. you could do that with syscall() but it is not very useful as the state of the system is not the same when you rerun a process so syscalls would likely fail or do different things than in the first run. > > clone cannot even be used from c code in general > > as CLONE_VM is not compatible with c semantics > > without a new stack (child clobbers the parent stack) > > so the c builtin would not always work > > it is also a syscall that only freestanding > > application can use not something that calls > > into the libc > > There are major projects out there which do use it regardless. that does not make it right. > For example, systemd: > > https://github.com/systemd/systemd/blob/main/src/basic/raw-clone.h > https://github.com/systemd/systemd/blob/main/src/shared/async.h > https://github.com/systemd/systemd/blob/main/src/shared/async.c > https://github.com/systemd/systemd/blob/main/docs/CODING_STYLE.md > > > even in a freestanding application it is tricky to use right > > No argument from me there. It is tricky... > The compiler should make it possible though. > > > so i don't see why clone is the quintessential example. > > I think it is the best example because attempting to use clone > is not actually supported by glibc. > > https://sourceware.org/bugzilla/show_bug.cgi?id=10311 > > "If you use clone() you're on your own." should be "if you use clone() *or* raw clone syscall then you're on your own" which is roughly what i said in that discussion. so your proposal does not fix this particular issue, just provide a simpler footgun. > > i guess it's ok if it is by default an error > > outside of -ffreestanding. > > Hosted C programs could also make good use of them. they should not. > They could certainly start out exclusive to freestanding C > and then made available to general code if there's demand.