Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1023286rwe; Thu, 1 Sep 2022 11:09:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR7ad2juhC2J6gjdflV0XA1hXLf0iF1laWdCjrBqcCJXnt0ljxvHuhHZyP7vomjN8KX1eaLt X-Received: by 2002:a17:906:8462:b0:741:6003:71e4 with SMTP id hx2-20020a170906846200b00741600371e4mr16791239ejc.170.1662055770797; Thu, 01 Sep 2022 11:09:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662055770; cv=none; d=google.com; s=arc-20160816; b=F2IJVhJP6lG4IYxHoUMvaW8Nqbcj6/bAVPutvfUwBuLU4iYlNyd+K7vdNuyAKIxoVJ G6moZpXpxskL+8q5ehqnZaPTVNzyth5CBiRb5+vTWpSrhQH8yc5+rjSpsmwRq8D6K1YG oodS2s8qTBP8tj9d7PUtSb6lLzm/dnTIE3HK6zK1GlmcJlUkfUqGFLRKRh/4qjRVdtsw Jz5k3I4yDhiGSRGgjFiL9B4UTxW30ni41fJ9n3uAkFB2RSZ3QxCSfyu1kuIY98N2myX+ y9PbDFujYOT5sqd8+bAHwmA/hONLCxErRGJlrTR/oA25foe8CqTHKrKP05eM6ZF42KbQ 8N3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OfaQjYc4yfi90+Qw/rGjddj9Zef84Xn04nGKaTPnQmc=; b=BziyR7l4XEYjmkuzKBE6QosuTmaLaXGdrTWb6wO5KMoW0MjL1ULnBTpYpySj0C+Xh/ 7Y/mr4kEa7AnArvn5o79GeGAC2rATw7Hn9Nq/mKPuCXFTFBOIM+tDasrCXWxbC28+GHg eQIeaXi6pS2SgYVCC2FIJaWGiFGccvEG5CxjiWmDKszV8893e3sA//WMNoRQpwpx5iIj XWUL8s8P6TMp/7q0nyQkB+jjVMc7C5JN8qlBRmjCIQZCPBm6f0ODKFamgkjAOVRg3wYU LnKoUW2NxMWBzZevwvgKG6le/mhJG2+tCanQ+IMSF6U48mPGckJ5Cwmv/cbu7vSs+PRe QGJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CN399PbR; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg17-20020a170907a41100b00738399b2bc9si15061226ejc.166.2022.09.01.11.09.03; Thu, 01 Sep 2022 11:09:30 -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=@kernel.org header.s=k20201202 header.b=CN399PbR; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233401AbiIASG7 (ORCPT + 99 others); Thu, 1 Sep 2022 14:06:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233277AbiIASGu (ORCPT ); Thu, 1 Sep 2022 14:06:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5B331114E; Thu, 1 Sep 2022 11:06:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2951061456; Thu, 1 Sep 2022 18:06:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA638C433D6; Thu, 1 Sep 2022 18:06:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662055608; bh=dx+lbNdZhrbcSwJy0QSUk/lhfZMvh0A57p9uFTmJk8U=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CN399PbRaB4h4fOuo/mP+ZJlQs4+eg5E6oM/kEo5LjYIqb3F0LrrpJM09OblTL9sl twDItFo5WWfzH5JkAwkJLB+eXX2n0GufLvK2ceWKnBvCM7uKfy3cItK2Drs0xKcoeL 1RMJzUWGI5nzSM8eDEMjui8wdcqHaQZGPnqBJ13Si/KKy4VJ9CjXery9Vr3FX2Ivot kfzAPNdN7QHJkRUEdFt1ZWQ1T/pDJ6sHsHSEFdWGdyC6dm1j6k6MCwSPAkCYRQQtXQ 7RKQlLKJh8fi88xp+C8SsToLORLvM+LDAnyNKhC6vRkafN+OK6BAG4SRG5I3p5jfhL fHHl6G0+oLXzw== Date: Thu, 1 Sep 2022 11:06:46 -0700 From: Nathan Chancellor To: Nick Desaulniers Cc: Linus Torvalds , Joe Perches , "Sudip Mukherjee (Codethink)" , Masahiro Yamada , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux , Justin Stitt , Youngmin Nam Subject: Re: [PATCH] Makefile.extrawarn: re-enable -Wformat for clang; take 2 Message-ID: References: <20220901175913.2183047-1-ndesaulniers@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220901175913.2183047-1-ndesaulniers@google.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 Thu, Sep 01, 2022 at 10:59:13AM -0700, Nick Desaulniers wrote: > -Wformat was recently re-enabled for builds with clang, then quickly > re-disabled, due to concerns stemming from the frequency of default > argument promotion related warning instances. > > commit 258fafcd0683 ("Makefile.extrawarn: re-enable -Wformat for clang") > commit 21f9c8a13bb2 ("Revert "Makefile.extrawarn: re-enable -Wformat for clang"") > > ISO WG14 has ratified N2562 to address default argument promotion > explicitly for printf, as part of the upcoming ISO C2X standard. > > The behavior of clang was changed in clang-16 to not warn for the cited > cases in all language modes. > > Add a version check, so that users of clang-16 now get the full effect > of -Wformat. For older clang versions, re-enable flags under the > -Wformat group that way users still get some useful checks related to > format strings, without noisy default argument promotion warnings. I > intentionally omitted -Wformat-y2k and -Wformat-security from being > re-enabled, which are also part of -Wformat in clang-16. > > Link: https://github.com/ClangBuiltLinux/linux/issues/378 > Link: https://github.com/llvm/llvm-project/issues/57102 > Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2562.pdf > Suggested-by: Justin Stitt > Suggested-by: Nathan Chancellor > Suggested-by: Youngmin Nam > Signed-off-by: Nick Desaulniers Reviewed-by: Nathan Chancellor > --- > Linus, I figured I'd send this to you to see whether you'd prefer to > apply it, or let it "ride the trains" up through the kbuild tree? I do > have another series I'm working on to improve the compiler version > checks > > where I can/will improve the checks used here, but I'm also interested in > having something that might backport cleanly to stable. > > scripts/Makefile.extrawarn | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn > index 0621c39a3955..6ae482158bc4 100644 > --- a/scripts/Makefile.extrawarn > +++ b/scripts/Makefile.extrawarn > @@ -47,7 +47,19 @@ else > > ifdef CONFIG_CC_IS_CLANG > KBUILD_CFLAGS += -Wno-initializer-overrides > +# Clang before clang-16 would warn on default argument promotions. > +ifeq ($(shell [ $(CONFIG_CLANG_VERSION) -lt 160000 ] && echo y),y) > +# Disable -Wformat > KBUILD_CFLAGS += -Wno-format > +# Then re-enable flags that were part of the -Wformat group that aren't > +# problematic. > +KBUILD_CFLAGS += -Wformat-extra-args -Wformat-invalid-specifier > +KBUILD_CFLAGS += -Wformat-zero-length -Wnonnull > +# Requires clang-12+. > +ifeq ($(shell [ $(CONFIG_CLANG_VERSION) -ge 120000 ] && echo y),y) > +KBUILD_CFLAGS += -Wformat-insufficient-args > +endif > +endif > KBUILD_CFLAGS += -Wno-sign-compare > KBUILD_CFLAGS += $(call cc-disable-warning, pointer-to-enum-cast) > KBUILD_CFLAGS += -Wno-tautological-constant-out-of-range-compare > > base-commit: 2880e1a175b9f31798f9d9482ee49187f61b5539 > -- > 2.37.2.789.g6183377224-goog >