Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5429894iob; Mon, 9 May 2022 16:34:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBQKYToIiR2relTxF86K5pR2O1Sc5u0mvSBhBnWISW4AnXb69BTmbgX/mqYg04a2Pn2xhW X-Received: by 2002:ac8:59c7:0:b0:2e1:a0d1:fc7b with SMTP id f7-20020ac859c7000000b002e1a0d1fc7bmr17612782qtf.320.1652139261403; Mon, 09 May 2022 16:34:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652139261; cv=none; d=google.com; s=arc-20160816; b=RBWAueq59wV0TB0tZ7Kh7H491jf8cS8Ynf6lXbUlBD00HBua/z96ewDLPZiHqVkcK+ cT7vobrpoFeiDG+HQ+Tljg0aiMbr7F3KNEW0vn9abAk4ZIZRJBvuG3AR6nSFxp2yIERE O31Z/o4A97NHiMKM7/c1FNT1cFIq8BDcCF545uf0F5wGP9xjX5Z31xAE76VNkQW9I9Lj 1bTv5Xnc+YwH2sR9pAIa2lwc1Ya0mDRxg5BxnKuo14y6cjEjTyRCzejK8L6wE3Yd4w2e kPiof9KnkZ6qPyEzKZ3PnM/vIR3qp21HO16u0VEusPvZfIIt36ueAH6trCReWQaLuJCE fkRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=2ZF0aaGxPgqlWytLFil+L87rXP/3Mh2LugmakMdLiHc=; b=VK6sKCKr44iOIwhAepjNEDBLvXlQM6iSAYGMLeHBNsuH5uRSXbvTdUUORXW4ZKWF34 vilie00TcuHaZCg67eZOiELCd5oxokCElsvchAd7AzH+uR0uM3IhJLKSJt4foI9yAZ2f cg8uBGIApzjB8oCCIJF7uTw1AaPXXVPG5acdZbLvojz95w/xrH/oCmj298qKolDZn4eR vHs9bNiXm4grLmht+t3m8vbCLydLnF/4WE4CT90ZXF64dQl4LU9YIKJGf7g1M6FJVL+I RZ5SLvgh1lSJDiaO3/t8+I3Vax5qWm/TR3lpeenwHvus4Eu2hXbcZvtsPCeCAVzG13M7 D+hw== ARC-Authentication-Results: i=1; mx.google.com; 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 t129-20020a375f87000000b0069fadfafb77si8809319qkb.192.2022.05.09.16.34.06; Mon, 09 May 2022 16:34: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; 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 S232245AbiEIXQn (ORCPT + 99 others); Mon, 9 May 2022 19:16:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbiEIXQk (ORCPT ); Mon, 9 May 2022 19:16:40 -0400 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E91E2A3BC2 for ; Mon, 9 May 2022 16:12:45 -0700 (PDT) Received: by mail-yb1-f172.google.com with SMTP id i11so5666767ybq.9 for ; Mon, 09 May 2022 16:12:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2ZF0aaGxPgqlWytLFil+L87rXP/3Mh2LugmakMdLiHc=; b=uXpqT0xCF7vBrqs0KtzqrYI5dB+NVARskSozy72v17V+phYFohxqGKoCQmNGZiRNTf 3Fx3Q9C322EYG2TGPF5myqFa/qInvw9sg+ZYf3OfFFr42/XArxTHnaFV/kDYECVH87YV atAKF4MJq42CnM/B72U1CjlzPZbRVhhxYm55LLlU2jVQmEraUWTgILXKzv96PlmDlH2t cutIzlOUwHX6qBLgIp1Ldc2c22miFNkOjhPuIUhoyW188TwxAFtiPl9MM+jE1tPURIPJ wQYXlMcUm6MRAU9AlN/Hb1vAny6dk+KsZqiLGnCZDYgMPuFxSD6UnPquzriaVEERvt+y ESpg== X-Gm-Message-State: AOAM53126MAQ1kYzo3P/1/GlJxWmQWHU/wKap853AGTZ5SKcXPEUqGRL zem9HTYbnMdNpx4oteqCS6xR2EnLEzW1MMDKRqg= X-Received: by 2002:a25:76c6:0:b0:648:5616:ca50 with SMTP id r189-20020a2576c6000000b006485616ca50mr16718433ybc.423.1652137964457; Mon, 09 May 2022 16:12:44 -0700 (PDT) MIME-Version: 1.0 References: <20220306171009.1973074-1-mailhol.vincent@wanadoo.fr> <20220508100907.61231-1-mailhol.vincent@wanadoo.fr> In-Reply-To: From: Vincent MAILHOL Date: Tue, 10 May 2022 08:12:33 +0900 Message-ID: Subject: Re: [RESEND PATCH v1] x86/build: add -fno-builtin flag to prevent shadowing To: Nick Desaulniers Cc: Nathan Chancellor , Arnd Bergmann , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "the arch/x86 maintainers" , "H . Peter Anvin" , Linux Kernel Mailing List , clang-built-linux , Tom Rix , Kees Cook Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 Hi Nick, On Tue. 10 May 2022 at 04:50, Nick Desaulniers wrote: > On Mon, May 9, 2022 at 8:01 AM Vincent MAILHOL > wrote: > > > > Instead, I am thinking of just using -fno-builtin-ffs to remove > > the annoying -Wshadow warning. Would that make more sense? > > Perhaps a pragma would be the best tool to silence this instance of > -Wshadow? I understand what GCC is trying to express, but the kernel > does straddle a weird place between -ffreestanding and a "hosted" env. I was a bit reluctant to propose the use of pragma because I received negative feedback in another patch for using the __diag_ignore() c.f.: https://lore.kernel.org/all/YmhZSZWg9YZZLRHA@yury-laptop/ But the context here is a bit different, I guess. If I receive your support, I am fully OK to silence this with some #pragma. The patch would look as below (I just need to test with clang before submitting). diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h index a288ecd230ab..e44911253bdf 100644 --- a/arch/x86/include/asm/bitops.h +++ b/arch/x86/include/asm/bitops.h @@ -269,6 +269,9 @@ static __always_inline unsigned long __fls(unsigned long word) #undef ADDR #ifdef __KERNEL__ +__diag_push(); +__diag_ignore_all("-Wshadow", + "-fno-builtin-foo would remove optimization, just silence it instead"); /** * ffs - find first set bit in word * @x: the word to search @@ -309,6 +312,7 @@ static __always_inline int ffs(int x) #endif return r + 1; } +__diag_pop(); /* ignore -Wshadow */ /** * fls - find last set bit in word