Re: [PATCH 003/128] KVM: selftests: Unconditionally compile KVM selftests with -Werror

From: Vitaly Kuznetsov
Date: Thu May 05 2022 - 10:09:06 EST


Sean Christopherson <seanjc@xxxxxxxxxx> writes:

> Specify -Werror when compiling KVM's selftests, there's zero reason to
> let warnings sneak into the selftests.
>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> ---
> tools/testing/selftests/kvm/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile
> index af582d168621..c8efaaeb0885 100644
> --- a/tools/testing/selftests/kvm/Makefile
> +++ b/tools/testing/selftests/kvm/Makefile
> @@ -153,7 +153,7 @@ LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/x86/include
> else
> LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include
> endif
> -CFLAGS += -Wall -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
> +CFLAGS += -Wall -Werror -Wstrict-prototypes -Wuninitialized -O2 -g -std=gnu99 \
> -fno-stack-protector -fno-PIE -I$(LINUX_TOOL_INCLUDE) \
> -I$(LINUX_TOOL_ARCH_INCLUDE) -I$(LINUX_HDR_PATH) -Iinclude \
> -I$(<D) -Iinclude/$(UNAME_M) -I.. $(EXTRA_CFLAGS) $(KHDR_INCLUDES)

"-Werror" in kvm-unit-tests is a constant source of pain as different
GCC versions tend to produce different warnings. It's going to be even
worse for selftests: e.g. bisecting an 'old' kernel on a system with
somewhat 'newer' compiler and selftests don't even build.

Personally, I'd prefer "-Werror" to be an acceptance criteria for
upstream patches (e.g. if something produces warnings on Paolo's
setup -- the patch doesn't get accepted) but not the hardcoded default
in Makefile.

--
Vitaly