Message ID | 20230210172203.101331-1-andrea.righi@canonical.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1082148wrn; Fri, 10 Feb 2023 09:32:41 -0800 (PST) X-Google-Smtp-Source: AK7set8QNAKW18c0f+pXng6JkmYIFxasupa6mdDhKBeO0Za5gri5tp3xyfSTE3D1WLF2zP1dDD+f X-Received: by 2002:a50:8e4f:0:b0:4ab:49eb:a8ec with SMTP id 15-20020a508e4f000000b004ab49eba8ecmr2966005edx.26.1676050361774; Fri, 10 Feb 2023 09:32:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676050361; cv=none; d=google.com; s=arc-20160816; b=Z3C/nfSSIpLjitlfgGYGSz3NkR7aWb8rMgCVQH0dQN/RMrnQAAMKS7gcRvZZkSa4nT ev5esDz9n9ZAkwl6AE3PAKjCFPSCVJ02SYluu3HrxnGIllylm5y2VInI2M8eINyHVN/3 9yz6S31ln18g2TOEmpl4xO+8evRTttg0Yi7f4BgYRnPw7ASIZy+Q5jjrLCyDUJKtqeBX hSvzyQKGhBpJO9OXSwk4oEhtU4gXu1Aau2VeVHdfMTPGLHfFnv8iZ6aN4ywwEczM4k7K SMb/lSBbv1r5pb9uoDloiJZFQmHHSW9rS4jfVpucLwA9lJmRh9GuSPLX3cZ/3OJvlGoT IjDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=S/oztqFWeJmzmDr/U8nZfNkMKK2hxPAiujJO+Umo16I=; b=oBmHlbhyHCjqkjZp7vzTBHTXOCMY+rHhZsM/z2DIg7pCXmsb5BDSGlhuPAj6cUSJIf WOeEfppV3veR0mVZe5teizJgFW4dkdQ2q504k1beLST41ubd1IiBxSab9no9KnOX/5g+ KuaI7t0B5D1XuMkvlGqmdear1BabUuNKO6of4JIlHz17o4waSixIryqeWjnmzVa8s0GX 5szI/yRTfV8W1P5whQNEfnoyYIGulVMMNJkdQB139tG0E5whfwXLTW9Uvz9eSSfCLadu CHcGyIIFCVPYu2zLpF1XdX/qQiUCmeAHl8VLxfoQdTxXM/m/ska7hsAoOSkfamkE5/BG TPOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=qvyPWeT3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a50ee91000000b004a20fa1a03dsi5633548edr.178.2023.02.10.09.32.18; Fri, 10 Feb 2023 09:32:41 -0800 (PST) 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=@canonical.com header.s=20210705 header.b=qvyPWeT3; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232764AbjBJRWL (ORCPT <rfc822;ybw1215001957@gmail.com> + 99 others); Fri, 10 Feb 2023 12:22:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232613AbjBJRWJ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 10 Feb 2023 12:22:09 -0500 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C37BC36696 for <linux-kernel@vger.kernel.org>; Fri, 10 Feb 2023 09:22:08 -0800 (PST) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (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 smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 7F1F43F0C3 for <linux-kernel@vger.kernel.org>; Fri, 10 Feb 2023 17:22:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1676049725; bh=S/oztqFWeJmzmDr/U8nZfNkMKK2hxPAiujJO+Umo16I=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=qvyPWeT34QkKF1H90NqcC7RCf83vXhwFnQhk/wrRuX5Aj1g5g7vpqiTmwCiveUY+5 GJpnPDgXs3N+jMEd3F+8OvKLzE16LZkNR8LxRqT1+iKbJ4eNs6r00t6J28sCzTuszk T2S/vCt+ckG6nnjKo8ilJBFkxAVGuPYaX4HV/hBE3L3oDJMcIPQafV+ozpsZxsNCLh e2O3zHef9VITfFTI6UOD1EChWAuvwOGzsfV7rlPfEe1yQ4YGCGPc29KGC4FDVbU53g MGLt9aZILvjU5kphfwZPeneeZAhVB4T1TG7V5W7SUaAFUcJkGZxjaMvag+X//qgoIX UhXTyXfVeJtXQ== Received: by mail-ej1-f70.google.com with SMTP id qa17-20020a170907869100b0088ea39742c8so3974986ejc.13 for <linux-kernel@vger.kernel.org>; Fri, 10 Feb 2023 09:22:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=S/oztqFWeJmzmDr/U8nZfNkMKK2hxPAiujJO+Umo16I=; b=hXZYHoM7gs+vhX2u/zQK5Ds6gB+gLKs+zpsg8lsqe+JHrASw08tPv1BbKfUJ85voxs vQyQzxgDoM9ix10JIHivKGPklo41SJ0gh2jIv7/blDpPlJRlPATEHBh4F0qh6f/T8+2W 9EBF0vrPMRyC+x+NQ3Uhs0rM0SA5iuh+n8/hKG4ATQ4iEH6Z6L/FI/3qq+D14ONMvVTZ f8b+pncFbExoFWo9Fg5PgPfQHRZALODmVEbiSTrxGBFozSqnek3YBQiY3rNaJPzJf6Ur 0HE5prvVzUFI5MzJC3SSU8T6TKGro1NE6ahlxGNEt1rvKRV+kSAhU4hujdZVjCkl6d0b EOcw== X-Gm-Message-State: AO0yUKVJCa7l4I8BeU0YBoPBinjdP3BI5xPmEu6m2Zb3OWKiWw6akUVE 6SGOumDkrg3OaVLwxvO6r65w6Ml8ajQUD1yp/hXJEa2Bv8K0NgMw+cdQSaPcICFuKWSoGJy1qrl 4x452yEmKNh+s5Kuay9rwbntqSrEH3iatZjpYrSVbrA== X-Received: by 2002:a17:906:1614:b0:87b:dba1:1bf3 with SMTP id m20-20020a170906161400b0087bdba11bf3mr16347227ejd.30.1676049725208; Fri, 10 Feb 2023 09:22:05 -0800 (PST) X-Received: by 2002:a17:906:1614:b0:87b:dba1:1bf3 with SMTP id m20-20020a170906161400b0087bdba11bf3mr16347206ejd.30.1676049725036; Fri, 10 Feb 2023 09:22:05 -0800 (PST) Received: from righiandr-XPS-13-7390.homenet.telecomitalia.it (host-87-7-128-191.retail.telecomitalia.it. [87.7.128.191]) by smtp.gmail.com with ESMTPSA id i12-20020a170906250c00b008adc971f5acsm2655543ejb.178.2023.02.10.09.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Feb 2023 09:22:04 -0800 (PST) From: Andrea Righi <andrea.righi@canonical.com> To: Miguel Ojeda <ojeda@kernel.org>, Alex Gaynor <alex.gaynor@gmail.com>, Wedson Almeida Filho <wedsonaf@gmail.com> Cc: Boqun Feng <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>, bjorn3_gh@protonmail.com, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] rust: allow to use INIT_STACK_ALL_ZERO Date: Fri, 10 Feb 2023 18:22:03 +0100 Message-Id: <20230210172203.101331-1-andrea.righi@canonical.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757466183728146119?= X-GMAIL-MSGID: =?utf-8?q?1757466183728146119?= |
Series |
rust: allow to use INIT_STACK_ALL_ZERO
|
|
Commit Message
Andrea Righi
Feb. 10, 2023, 5:22 p.m. UTC
With CONFIG_INIT_STACK_ALL_ZERO enabled, bindgen is passing
-ftrivial-auto-var-init=zero to clang, that triggers the following:
error: '-ftrivial-auto-var-init=zero' hasn't been enabled; enable it at your own peril for benchmarking purpose only with '-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang'
This flag should be dropped in clang-17, but at the moment it seems more
reasonable to add it to the bindgen CFLAGS to prevent the error above.
In this way we can enable CONFIG_INIT_STACK_ALL_ZERO with CONFIG_RUST
without triggering any build error.
Link: https://reviews.llvm.org/D125142
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
---
rust/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Fri, Feb 10, 2023 at 06:22:03PM +0100, Andrea Righi wrote: > With CONFIG_INIT_STACK_ALL_ZERO enabled, bindgen is passing > -ftrivial-auto-var-init=zero to clang, that triggers the following: > > error: '-ftrivial-auto-var-init=zero' hasn't been enabled; enable it at your own peril for benchmarking purpose only with '-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang' > > This flag should be dropped in clang-17, but at the moment it seems more > reasonable to add it to the bindgen CFLAGS to prevent the error above. > > In this way we can enable CONFIG_INIT_STACK_ALL_ZERO with CONFIG_RUST > without triggering any build error. > > Link: https://reviews.llvm.org/D125142 > Signed-off-by: Andrea Righi <andrea.righi@canonical.com> If this went via the kbuild tree, would we be able to use $(CC_AUTO_VAR_INIT_ZERO_ENABLER)? https://git.kernel.org/masahiroy/linux-kbuild/c/4e3feaad6ff8a7a57e3bf3308a93c93e3a2e17a6 Although, I suppose this could be a problem if the version of clang being used to build the kernel does not support this flag while the version of libclang in bindgen requires it? > --- > rust/Makefile | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/rust/Makefile b/rust/Makefile > index ff70c4c916f8..5e26db07a1dc 100644 > --- a/rust/Makefile > +++ b/rust/Makefile > @@ -267,7 +267,8 @@ BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH)) > # All warnings are inhibited since GCC builds are very experimental, > # many GCC warnings are not supported by Clang, they may only appear in > # some configurations, with new GCC versions, etc. > -bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET) > +bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET) \ > + -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang > > bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \ > $(bindgen_extra_c_flags) > -- > 2.37.2 >
On Fri, Feb 10, 2023 at 10:39:27AM -0700, Nathan Chancellor wrote: > On Fri, Feb 10, 2023 at 06:22:03PM +0100, Andrea Righi wrote: > > With CONFIG_INIT_STACK_ALL_ZERO enabled, bindgen is passing > > -ftrivial-auto-var-init=zero to clang, that triggers the following: > > > > error: '-ftrivial-auto-var-init=zero' hasn't been enabled; enable it at your own peril for benchmarking purpose only with '-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang' > > > > This flag should be dropped in clang-17, but at the moment it seems more > > reasonable to add it to the bindgen CFLAGS to prevent the error above. > > > > In this way we can enable CONFIG_INIT_STACK_ALL_ZERO with CONFIG_RUST > > without triggering any build error. > > > > Link: https://reviews.llvm.org/D125142 > > Signed-off-by: Andrea Righi <andrea.righi@canonical.com> > > If this went via the kbuild tree, would we be able to use > $(CC_AUTO_VAR_INIT_ZERO_ENABLER)? > > https://git.kernel.org/masahiroy/linux-kbuild/c/4e3feaad6ff8a7a57e3bf3308a93c93e3a2e17a6 > > Although, I suppose this could be a problem if the version of clang > being used to build the kernel does not support this flag while the > version of libclang in bindgen requires it? I didn't have much success with CC_AUTO_VAR_INIT_ZERO_ENABLER, but maybe a better way is to check if the version of libclang used by bindgen is less than 17, considering that is extra clang option is supposed to be dropped in clang-17: https://github.com/llvm/llvm-project/issues/44842 I'll send a v2, unless we find a better way to support this auto var zero-init feature. -Andrea
diff --git a/rust/Makefile b/rust/Makefile index ff70c4c916f8..5e26db07a1dc 100644 --- a/rust/Makefile +++ b/rust/Makefile @@ -267,7 +267,8 @@ BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH)) # All warnings are inhibited since GCC builds are very experimental, # many GCC warnings are not supported by Clang, they may only appear in # some configurations, with new GCC versions, etc. -bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET) +bindgen_extra_c_flags = -w --target=$(BINDGEN_TARGET) \ + -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang bindgen_c_flags = $(filter-out $(bindgen_skip_c_flags), $(c_flags)) \ $(bindgen_extra_c_flags)