linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] tools/perf: tools: Fix perf build issues
@ 2021-05-11 15:02 Masami Hiramatsu
  2021-05-11 15:02 ` [PATCH 1/2] perf build: Move EXTRA_CFLAGS and EXTRA_WARNINGS at the end of CFLAGS Masami Hiramatsu
  2021-05-11 15:02 ` [PATCH 2/2] tools: Add -Wno-missing-field-initializers to for clang Masami Hiramatsu
  0 siblings, 2 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2021-05-11 15:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Anders Roxell, Leo Yan, linux-kernel, Nathan Chancellor,
	Nick Desaulniers

Hi,

These are the patches to fix the perf build issues which I reported in
the previous email.

https://lore.kernel.org/lkml/162037766527.94840.4323848545957010011.stgit@devnote2/

There are 2 issues I found and are fixed with these patches.

 - Since the EXTRA_CLFAGS/WARNINGS are listed before -Wall/-Wextra in
   CFLAGS, all -Wno-* flags in the EXTRA_CFLAGS/WARNINGS are ignored.
   This makes EXTRA_WARNINGS ignored and developers can not use EXTRA_CLFAGS
   for debugging compiler warnings.

 - Clang's missing-field-initializers warning is too sensitive compared
   with GCC. I think "{ NULL }" kind of syntax is allowed for simplify code.


Thank you,

---

Masami Hiramatsu (2):
      perf build: Move EXTRA_CFLAGS and EXTRA_WARNINGS at the end of CFLAGS
      tools: Add -Wno-missing-field-initializers to for clang


 tools/perf/Makefile.config     |    3 ++-
 tools/scripts/Makefile.include |    4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

--
Masami Hiramatsu (Linaro) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] perf build: Move EXTRA_CFLAGS and EXTRA_WARNINGS at the end of CFLAGS
  2021-05-11 15:02 [PATCH 0/2] tools/perf: tools: Fix perf build issues Masami Hiramatsu
@ 2021-05-11 15:02 ` Masami Hiramatsu
  2021-05-11 15:02 ` [PATCH 2/2] tools: Add -Wno-missing-field-initializers to for clang Masami Hiramatsu
  1 sibling, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2021-05-11 15:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Anders Roxell, Leo Yan, linux-kernel, Nathan Chancellor,
	Nick Desaulniers

Move EXTRA_CFLAGS and EXTRA_WARNINGS at the end of CFLAGS so that
additional flags will be passed to the compiler correctly.

CFLAGS is composed by CORE_CFLAGS, INC_FLAGS, EXTRA_CFLAGS, and
EXTRA_WARNINGS in the following order;

CFLAGS = $EXTRA_CFLAGS $EXTRA_WARNINGS $CORE_CFLAGS $INC_FLAGS

But since CORE_CFLAGS includes "-Wall" and "-Wextra", the other -Wno-*
flags in EXTRA_CFLAGS and EXTRA_WARNINGS are overridden and ignored.

To fix this issue, move those EXTRA_* at the end of CFLAGS definition
as below.

CFLAGS = $CORE_CFLAGS $INC_FLAGS $EXTRA_CFLAGS $EXTRA_WARNINGS

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/perf/Makefile.config |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 406a9519145e..2ad46c66bc7b 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -16,7 +16,7 @@ $(shell printf "" > $(OUTPUT).config-detected)
 detected     = $(shell echo "$(1)=y"       >> $(OUTPUT).config-detected)
 detected_var = $(shell echo "$(1)=$($(1))" >> $(OUTPUT).config-detected)
 
-CFLAGS := $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
+CFLAGS :=
 
 include $(srctree)/tools/scripts/Makefile.arch
 
@@ -340,6 +340,7 @@ INC_FLAGS += -I$(srctree)/tools/lib/
 CORE_CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
 
 CFLAGS   += $(CORE_CFLAGS) $(INC_FLAGS)
+CFLAGS   += $(EXTRA_CFLAGS) $(filter-out -Wnested-externs,$(EXTRA_WARNINGS))
 CXXFLAGS += $(INC_FLAGS)
 
 LIBPERF_CFLAGS := $(CORE_CFLAGS) $(EXTRA_CFLAGS)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] tools: Add -Wno-missing-field-initializers to for clang
  2021-05-11 15:02 [PATCH 0/2] tools/perf: tools: Fix perf build issues Masami Hiramatsu
  2021-05-11 15:02 ` [PATCH 1/2] perf build: Move EXTRA_CFLAGS and EXTRA_WARNINGS at the end of CFLAGS Masami Hiramatsu
@ 2021-05-11 15:02 ` Masami Hiramatsu
  2021-05-11 18:23   ` Nick Desaulniers
  1 sibling, 1 reply; 4+ messages in thread
From: Masami Hiramatsu @ 2021-05-11 15:02 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Anders Roxell, Leo Yan, linux-kernel, Nathan Chancellor,
	Nick Desaulniers

Since clang's -Wmissing-field-initializers warns valid syntax of
initializing data structure (e.g. initializing static data
structure with single NULL, the rest of fields are initialized
with zero), it is better to disable this warning option
for clang for now.
This can stop building perf because -Werror is also specified.

Note that same issue on gcc has been fixed in 4.7.0, so we don't need
this for gcc.

 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 tools/scripts/Makefile.include |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index f9271f3ea912..4fd5d33ded03 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -89,6 +89,10 @@ ifeq ($(CC_NO_CLANG), 1)
 EXTRA_WARNINGS += -Wstrict-aliasing=3
 endif
 
+ifneq ($(CC_NO_CLANG), 1)
+EXTRA_WARNINGS += -Wno-missing-field-initializers
+endif
+
 # Hack to avoid type-punned warnings on old systems such as RHEL5:
 # We should be changing CFLAGS and checking gcc version, but this
 # will do for now and keep the above -Wstrict-aliasing=3 in place


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] tools: Add -Wno-missing-field-initializers to for clang
  2021-05-11 15:02 ` [PATCH 2/2] tools: Add -Wno-missing-field-initializers to for clang Masami Hiramatsu
@ 2021-05-11 18:23   ` Nick Desaulniers
  0 siblings, 0 replies; 4+ messages in thread
From: Nick Desaulniers @ 2021-05-11 18:23 UTC (permalink / raw)
  To: Masami Hiramatsu
  Cc: Arnaldo Carvalho de Melo, Anders Roxell, Leo Yan, LKML,
	Nathan Chancellor

On Tue, May 11, 2021 at 8:02 AM Masami Hiramatsu <mhiramat@kernel.org> wrote:
>
> Since clang's -Wmissing-field-initializers warns valid syntax of
> initializing data structure (e.g. initializing static data
> structure with single NULL, the rest of fields are initialized
> with zero), it is better to disable this warning option
> for clang for now.
> This can stop building perf because -Werror is also specified.
>
> Note that same issue on gcc has been fixed in 4.7.0, so we don't need
> this for gcc.
>
>  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750
>
> Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>

Seems fine, it's only enabled for the kernel at W=2 anyways.
Acked-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  tools/scripts/Makefile.include |    4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
> index f9271f3ea912..4fd5d33ded03 100644
> --- a/tools/scripts/Makefile.include
> +++ b/tools/scripts/Makefile.include
> @@ -89,6 +89,10 @@ ifeq ($(CC_NO_CLANG), 1)
>  EXTRA_WARNINGS += -Wstrict-aliasing=3
>  endif
>
> +ifneq ($(CC_NO_CLANG), 1)
> +EXTRA_WARNINGS += -Wno-missing-field-initializers
> +endif
> +
>  # Hack to avoid type-punned warnings on old systems such as RHEL5:
>  # We should be changing CFLAGS and checking gcc version, but this
>  # will do for now and keep the above -Wstrict-aliasing=3 in place
>


-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-11 18:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 15:02 [PATCH 0/2] tools/perf: tools: Fix perf build issues Masami Hiramatsu
2021-05-11 15:02 ` [PATCH 1/2] perf build: Move EXTRA_CFLAGS and EXTRA_WARNINGS at the end of CFLAGS Masami Hiramatsu
2021-05-11 15:02 ` [PATCH 2/2] tools: Add -Wno-missing-field-initializers to for clang Masami Hiramatsu
2021-05-11 18:23   ` Nick Desaulniers

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).