Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3380236rwe; Mon, 29 Aug 2022 10:30:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR4+Db6EfvROPEtAT0lkq5mw2X5mzbAR6rZqeaXCQKOHppagC0+kGXPbHynf7gaYXZfg4bw7 X-Received: by 2002:a63:4625:0:b0:42a:d055:22df with SMTP id t37-20020a634625000000b0042ad05522dfmr14899293pga.312.1661794221584; Mon, 29 Aug 2022 10:30:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1661794221; cv=pass; d=google.com; s=arc-20160816; b=gAsyvK/9sUHTkZX+86RgevaniaGenBW8qL3BSAZecMHDWPoxsFwBkXXZykau5Nk6Rx p8BGrRxr4HVOIYnFYWpqp7P+88ghCS3m0vFjGne/8e3Iz0Bmegt/IIlzDegJTbCWsbv7 hqRsyd6so6S9+eM5ob/NPhhnf/Q2mOY9KMLdN3lLx4KFg214jXUh0a8xBIjKEBVonrOe 4GgY8uhF9d6wYZvz4VGRQBwvqMxYwJ9HjqImgT96bzEjA1zfYWugWFETz2NDhEWkn3CS f9/rQV3fITfcwGt1vLgDXTBI4eb6RIEQ30ao/g9dLva9BYI+6j1L7NeUn+vUtdNHblys AjrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ANPd6S9qgRXWvh9rOD3Cfgz6gPRsnp4F+cXcUMjZd+Q=; b=xAem/0JXC/6krLVOqwwXr76Mz3ZrtfbFBWGeI1hdCt/0I33mjghqukzlxvB1ztK0+3 CI1AOvkBF51+Mnr3hcevPkD6JGvy5G/97e37aqdEAwjHsZ24lXUDJ4oGOEhv69rSSryh fuxQs1uxj8f2JXXZxsEMquW1RxGva5tZxvEfXslGHXCuGsO/2j06vpT4h7sEgLkRNgaI qJJ+KiE+mHsIg6TZ1lSy3TwIGeeVZKYLpOP8j60y1QSgb2C5IrhVpagIO//Midq08IBz IyouXGZ8ebf+FuBn7GcCMAgAV6/zDFKaQBOt6j7D/4YE2PllUWpT2y/LUlJBFVUUAglN jZ7w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@garyguo.net header.s=selector1 header.b=N+50HEG7; arc=pass (i=1 spf=pass spfdomain=garyguo.net dkim=pass dkdomain=garyguo.net dmarc=pass fromdomain=garyguo.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d4-20020a17090ac24400b001fd9c70c2d8si5413374pjx.53.2022.08.29.10.30.10; Mon, 29 Aug 2022 10:30:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@garyguo.net header.s=selector1 header.b=N+50HEG7; arc=pass (i=1 spf=pass spfdomain=garyguo.net dkim=pass dkdomain=garyguo.net dmarc=pass fromdomain=garyguo.net); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231298AbiH2RND (ORCPT + 99 others); Mon, 29 Aug 2022 13:13:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231478AbiH2RMo (ORCPT ); Mon, 29 Aug 2022 13:12:44 -0400 Received: from GBR01-CWL-obe.outbound.protection.outlook.com (mail-cwlgbr01on2126.outbound.protection.outlook.com [40.107.11.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD8208C032; Mon, 29 Aug 2022 10:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XFYlbqMdb9P94ANAkI5Dg1qUt3jtQ3UbCp1O0sNphaE9FHUk3LvcW2K4PgjsqYTT96glOxefpUFRx8mVKtGaRgYuF3YRAj2zdLj6hFeiQ22clC+UocP+TE55/i65DaveJwY/vSpj1xSkylTHO3L2fGTmPfW/zc22VkD/NZWUf0HpjPE8aFkmCAuWJeQ/zRXB79Thqbepv732CtcDc54zZsmDOubouFvaBGOQ3M8Ic7vqftPUZYBmvEluss3IU1tIoeNxfpwH0clYHPz30VGQWyWrKb2aPIMpKoFQyCU19woHOXMu++QSYv6a9LTsbkPyn67GCkAlL0RvXGRb2wgosg== 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=ANPd6S9qgRXWvh9rOD3Cfgz6gPRsnp4F+cXcUMjZd+Q=; b=kGXPjVSOGs0LD4iYy5bsvXJgEne5k84tqAeeS6Qkfxl2Vvhavh0dcec0/KVy6XFoiaddcdaSDvS+xlZwapIPwElstgg9x1CrqO+vUYrnBJ6Y3YFd1cZmlMTB5ezGqD5Gg0ddcT3Lp2UmVmVT4GUQpyaw1GkJYg0JlI8i5oho5BRQ2F8BgsbCt+y8h7fOTeKqJyDRUeJkDOr/tmBScQ3ZjMcr2Rzt3qkTrEf8Ju0OJFS/dMHcny8XwkCOR21hb79gUDMJfQgEvfvG/aAnG0dnfwWuB+h/GUIcG/bxm70d1L5Q7eppS8mFLI7J8sHSt+6+5NJJL8RLxAgePVY2DGEDIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=garyguo.net; dmarc=pass action=none header.from=garyguo.net; dkim=pass header.d=garyguo.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garyguo.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ANPd6S9qgRXWvh9rOD3Cfgz6gPRsnp4F+cXcUMjZd+Q=; b=N+50HEG7ieihluNJ/z/DfEZ4P/IodwDZda5XzVeYoeSFMxRr97IxCX7ZiQw0FU2Fc5mAcShRk8ZfzZTDYUZlvViLHmpQAXbUstPRnCkAaSLDKXXBxg/6dvfOS5qpq/n1I86E/GEInTA+c+FIAK7IYJH+swJiTOJulPsjLZYNiYk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=garyguo.net; Received: from LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:253::10) by LO4P265MB6683.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2f3::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Mon, 29 Aug 2022 17:11:36 +0000 Received: from LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM ([fe80::d051:d2a2:4b47:f935]) by LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM ([fe80::d051:d2a2:4b47:f935%5]) with mapi id 15.20.5566.021; Mon, 29 Aug 2022 17:11:36 +0000 Date: Mon, 29 Aug 2022 18:11:33 +0100 From: Gary Guo To: Nick Desaulniers Cc: Miguel Ojeda , Linus Torvalds , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, patches@lists.linux.dev, Jarkko Sakkinen , Alex Gaynor , Wedson Almeida Filho , Sven Van Asbroeck , Boqun Feng , =?ISO-8859-1?Q?Bj=F6rn?= Roy Baron , Masahiro Yamada , Ard Biesheuvel Subject: Re: [PATCH v9 09/27] rust: add `compiler_builtins` crate Message-ID: <20220829181133.00005f01@garyguo.net> In-Reply-To: References: <20220805154231.31257-1-ojeda@kernel.org> <20220805154231.31257-10-ojeda@kernel.org> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; i686-w64-mingw32) Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P265CA0073.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::13) To LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:253::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eb047e3e-d8bd-4b01-6f78-08da89e187d1 X-MS-TrafficTypeDiagnostic: LO4P265MB6683:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tKx8q6da5N3mJIOp0TGecjUIFRHg6IYmUGfFE5kxYw8XEAEzZe1ZAtQyCcVVxC3iQm8BBmeSDsCbEZ6IltlyzeSIPQwmg6pjTl4Dmce2h+i0hYPQEqVMIBnOftG6SPlQ2bJNGcfTLP2Ib+Wi1CzzULcoCQolDbsWuami08dk7q1s+v5yqAijzkwfHOVhz8vIzn9RIHpQIDid7KCNNKgW9ulkBlubVDzXyzL4jJqq8N8gO+0Y5/u/xX9yKjYHeXpzCuO9T//2b+Krae+DYK90IMIRHHKxsfZY073zmPtAafon+vGi5UeP/3w4bOekDEYeAAdygBjWEGm5RM8gCTod7EgflH7JIBoDka6yGlDiEMy8UqmsTSdz1uYMNNRExC6piKhZi3f9lPl423srtD5lG81FyEhOxIwDFzJMgiYCj8TzsFWfv/4l52Tltb/3XbofX1w9mpQJK5/totBpkjAO06XW25cQMmHxeBl6cru8VRH0oXgep7yq2d+B2p7gUmh7W4hyJrJTLWIG2bC8h6svxTeKLdNgwoLm2PJLRWnYEJBqqIodMoxLE+7N79SP20reb7xgdo1OwIVixo4UoxLFEnBgADchArx2dsRo9wpS3pwieoZf6tFl8rQa16V+VYV/AKa5NQJbEGuHPGeV/dpyzETRqdl2Or8CXfOIJd41cNQaBmUMb4Z3iZ+imdbiy4uzVd97Z1ywuT+2qqKfbmfOVy/xd0gKZHtE8oTrVtXt++wtDpiP5yZviPKXLB6G9sjsQlRxVj686jUGsJ91m46OYA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230016)(376002)(346002)(396003)(136003)(39830400003)(366004)(6506007)(38100700002)(52116002)(2906002)(6666004)(2616005)(83380400001)(186003)(6512007)(6486002)(86362001)(4326008)(66946007)(66476007)(66556008)(8676002)(1076003)(54906003)(316002)(966005)(6916009)(36756003)(7416002)(41300700001)(8936002)(478600001)(5660300002)(81973001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?aDjCXSSNDL954r/xcJbyCHUcOAn3AwYq0l2vrJhH2YJf+AVNFrA0NedmVD2l?= =?us-ascii?Q?DiImogIbMwaCdcGqqDrJBEjHQYpRhg4LPMy2FqbxDrf7oVtnMNJAtVuOxpyf?= =?us-ascii?Q?ScJL5FxiqVJ8WYcPng6QMQIqnxiQpOAhLP0jAyXd+yWLZxXb5dpwBU/90ezq?= =?us-ascii?Q?3LW7vaf2v2IOYAvSXz5YWhAMUqnM8MP6Ijmfl4VheLNia1oGvUbv4+/WP04j?= =?us-ascii?Q?vKAjjLivO5EvtXs8p6evipvpX7abPo4zy1lAkO/PNCU1TPZaRIMgu3/03GC8?= =?us-ascii?Q?OHkekQWpW3MohgPY7CtEgFzbRhS1kLYN0V5perSP+0Ki3sp25Ifgb9gns81i?= =?us-ascii?Q?nBoGn6GCCVMp/Zm9RvzOjaJuXpXJjY0m1Pm/O6jZ5N/3fJFj1tB875/BYBWw?= =?us-ascii?Q?k8mxLoBmS4h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ntSRt?= =?us-ascii?Q?EuDvEa/Q3X0mhXY4/+/tFHzkg2RUfw4nyfwHPfuU3Hi+8ytaShyP4h8DUINX?= =?us-ascii?Q?z57g0A2Yyw1xDbBuW4MdUCE3VKeQMe+Y4owdRIuMs9tdlgftTGj8oxISEfX5?= =?us-ascii?Q?VZHlXjCvODrzqkxMQl2MF1XK8WyOMi4fy7EG2OyaEAbMxu42O0XqlXughxtI?= =?us-ascii?Q?XeXUuL4xfKDKZ9sDXA7HUCmL0WkSIeOeyj7yWi0dcQeLAEEOylcL5VT5qwo3?= =?us-ascii?Q?LdSAyKJznTETTQE8gv0WQ7pcRAN4lpv1UUqfUhnmTw9Sn7FOqBqR54NYrBTU?= =?us-ascii?Q?SEtBm4ANvrdKoowwBXwiwaceciTnKEEIojClPdQ2tQl/?= X-OriginatorOrg: garyguo.net X-MS-Exchange-CrossTenant-Network-Message-Id: eb047e3e-d8bd-4b01-6f78-08da89e187d1 X-MS-Exchange-CrossTenant-AuthSource: LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Aug 2022 17:11:36.6580 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bbc898ad-b10f-4e10-8552-d9377b823d45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 44UwLCZdVRShsHp8jfBgQn+0J0IDVP9911qxJRLTHmZaAeq2dsO3OJ3h/tYQszqesH0aFXX5/CJGxCHn2UqyUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO4P265MB6683 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 24 Aug 2022 11:38:46 -0700 Nick Desaulniers wrote: > Another idea I had, and Ard mentioned to me this morning that efistub > does something similar: > > I think objcopy can rename symbol references. So instead of calling > foo, I think you can use objcopy to call bar instead. > > To avoid the case of Rust core refering to symbols typically provided > by the --rtlib={libgcc|compiler-rt}, what if we: > 1. build core.o (with reference to the unfavorable symbols) > 2. use objcopy to rename references in core.o to the symbols listed in > this file; maybe prepend them with `rust_core_` or something. > 3. provide this crate with panic'ing definitions, but for the renamed > symbols. > > That way, enabling CONFIG_RUST=y won't hide the case where C code is > triggering such libcalls from the C compiler? > > To restate the concern, I don't want CONFIG_RUST=y to hide that fact > that someone wrote `float x, y; if (x != y) ...` in C code, where the > C compiler will likely lower that to a libcall to __nesf2 since with > the current approach in this patch, linkage would proceed. The current > behavior is to intentionally fail to link. I think what I describe > above may work to keep this intended behavior of the kernel's build > system. > > Ah, looks like there's objcopy flags: > --redefine-sym old=new > Change the name of a symbol old, to new. This can be > useful when one is trying link > two things together for which you have no source, and there > are name collisions. > > --redefine-syms=filename > Apply --redefine-sym to each symbol pair "old new" listed > in the file filename. > filename is simply a flat file, with one symbol pair per > line. Line comments may be > introduced by the hash character. This option may be given > more than once. > > So probably could start with my diff from above, but use > --redefine-syms=filename instead of --strip-symbols=. > > -- > Thanks, > ~Nick Desaulniers This is the approach we are about to take, see https://github.com/Rust-for-Linux/linux/pull/779. It's easy for just one symbol that is known to be not defined, but it can be more complex as some of these symbols can be defined on a platform but not another, so we would have to generate a dynamic list of what symbols to "hijack" depending on the config. Currently we avoid this issue by having all symbols in compiler_builtins crate weak, but we couldn't weakly redefine a symbol. It's certainly doable, though, but it require some effort. I am not quite available recently so hadn't further extend and polish my patch. Best, Gary