From: Nick Desaulniers <ndesaulniers@google.com>
To: Nathan Chancellor <nathan@kernel.org>
Cc: masahiroy@kernel.org, nicolas@fjasle.eu, trix@redhat.com,
linux-kbuild@vger.kernel.org, llvm@lists.linux.dev,
patches@lists.linux.dev
Subject: Re: [PATCH] kbuild: Disable clang's -Wformat-{overflow,truncation}-non-kprintf
Date: Mon, 2 Oct 2023 13:10:34 -0700 [thread overview]
Message-ID: <CAKwvOdn-NqEjfteby_9hKBcrC-24P7tRnmGiTpa4fL66eJOZ8w@mail.gmail.com> (raw)
In-Reply-To: <20231002-disable-wformat-truncation-overflow-non-kprintf-v1-1-35179205c8d9@kernel.org>
On Mon, Oct 2, 2023 at 12:52 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Recently, clang added support for -Wformat-overflow and
> -Wformat-truncation. When building the kernel, it was discovered that
> clang's implementation of these warnings handles the '%p' specifier,
> which differs from GCC's implementation. This results in false positive
> warnings due to the kernel's various '%p' extensions. Fortunately, the
> clang developers placed this warning difference into a separate flag,
> allowing the kernel to turn off the warning for '%p' unconditionally.
>
> This is not currently an issue for a normal build, as -Wformat-overflow
> and -Wformat-truncation are unconditionally disabled, which includes
> this sub-warning. However, ever since commit 6d4ab2e97dcf ("extrawarn:
> enable format and stringop overflow warnings in W=1"), these warnings
> are in W=1 and the goal is to enable them in the normal build once they
> are all eliminated. Disable the warnings for W=1 to avoid false
> positives. This block should move with -Wformat-overflow and
> -Wformat-truncation when they are enabled for a normal build.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/1923
> Link: https://github.com/llvm/llvm-project/issues/64871
> Link: https://github.com/llvm/llvm-project/pull/65969
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78512
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
This should be the final piece of the puzzle...a long arduous puzzle.
Thanks Nathan!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
> ---
> scripts/Makefile.extrawarn | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index 2fe6f2828d37..bad1baa2cfb4 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -106,6 +106,13 @@ KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
> KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
> KBUILD_CFLAGS += $(call cc-option, -Wformat-overflow)
> KBUILD_CFLAGS += $(call cc-option, -Wformat-truncation)
> +# Clang checks for overflow/truncation with '%p', while GCC does not:
> +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111219
> +# The kernel has many extensions to '%p' that clang does not understand, so
> +# always disable these warnings when '-Wformat-truncation' and
> +# '-Wformat-overflow' are enabled.
> +KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow-non-kprintf)
> +KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf)
> KBUILD_CFLAGS += $(call cc-option, -Wstringop-overflow)
> KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
>
>
> ---
> base-commit: 8a749fd1a8720d4619c91c8b6e7528c0a355c0aa
> change-id: 20231002-disable-wformat-truncation-overflow-non-kprintf-033e8d8b4de8
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>
>
--
Thanks,
~Nick Desaulniers
next prev parent reply other threads:[~2023-10-02 20:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-02 19:52 [PATCH] kbuild: Disable clang's -Wformat-{overflow,truncation}-non-kprintf Nathan Chancellor
2023-10-02 20:10 ` Nick Desaulniers [this message]
2023-12-06 16:26 ` Nathan Chancellor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKwvOdn-NqEjfteby_9hKBcrC-24P7tRnmGiTpa4fL66eJOZ8w@mail.gmail.com \
--to=ndesaulniers@google.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=masahiroy@kernel.org \
--cc=nathan@kernel.org \
--cc=nicolas@fjasle.eu \
--cc=patches@lists.linux.dev \
--cc=trix@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).