[PATCH] tools/perf: build issues with Clang on arm64 and CFLAGS
From: Masami Hiramatsu
Date: Fri May 07 2021 - 04:54:35 EST
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@xxxxxxxxxx>