linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/perf: build issues with Clang on arm64 and CFLAGS
@ 2021-05-07  8:54 Masami Hiramatsu
  2021-05-07  8:54 ` [PATCH] tools/perf: Fix a build error on arm64 with clang Masami Hiramatsu
  2021-05-10 12:14 ` [PATCH] tools/perf: build issues with Clang on arm64 and CFLAGS Arnaldo Carvalho de Melo
  0 siblings, 2 replies; 5+ messages in thread
From: Masami Hiramatsu @ 2021-05-07  8:54 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Anders Roxell, Leo Yan, Sergey Senozhatsky, linux-kernel

Hi Arnaldo,

Recently, I tested the perf build by clang on arm64 and found an issue
in arch/arm64/util/kvm-stat.c, related to missing-field-initializers warning.

----
 tools/perf $ make CC=clang LLVM=1 
...
arch/arm64/util/kvm-stat.c:74:9: error: missing field 'ops' initializer [-Werror,-Wmissing-field-initializers]
        { NULL },
               ^
1 error generated.
----

That error itself can be fixed easily by just adding field initializers
[1/1] Note that I didn't add Fixes tag, because I'm not sure clang build
of perf is officially supported or not, and this seems correct C code
to initialize a data structure with zero.(*)

And while investigating the error, I found another issue in the Makefile.config.

It seems to make CFLAGS from CORE_CFLAGS, INC_FLAGS, EXTRA_CFLAGS, 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-XXXX in
EXTRA_CFLAGS and EXTRA_WARNINGS are overriden and ignored.
So, I think it is better to define it as

CFLAGS = $CORE_CFLAGS $INC_FLAGS $EXTRA_CFLAGS $EXTRA_WARNINGS

But I also saw some configs tweaks CFLAGS directly. I think they should
modify EXTRA_CFLAGS.

My question is that this order is intentional or not. I might
miss something on it.

(*) BTW, there seems a discussion on the clang warning behavior,
 because gcc doesn't warn it anymore
 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750).
 It might be better to add -Wno-missing-field-initializers in case
 of CC=clang by default.


Thank you,

---

Masami Hiramatsu (1):
      tools/perf: Fix a build error on arm64 with clang


 tools/perf/arch/arm64/util/kvm-stat.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07  8:54 [PATCH] tools/perf: build issues with Clang on arm64 and CFLAGS Masami Hiramatsu
2021-05-07  8:54 ` [PATCH] tools/perf: Fix a build error on arm64 with clang Masami Hiramatsu
2021-05-09 12:50   ` Arnaldo Carvalho de Melo
2021-05-10 12:14 ` [PATCH] tools/perf: build issues with Clang on arm64 and CFLAGS Arnaldo Carvalho de Melo
2021-05-11 10:36   ` Masami Hiramatsu

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