diff mbox series

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

Message ID 20220504224914.1654036-4-seanjc@google.com (mailing list archive)
State New, archived
Headers show
Series KVM: selftests: Overhaul APIs, purge VCPU_ID | expand

Commit Message

Sean Christopherson May 4, 2022, 10:47 p.m. UTC
Specify -Werror when compiling KVM's selftests, there's zero reason to
let warnings sneak into the selftests.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 tools/testing/selftests/kvm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Vitaly Kuznetsov May 5, 2022, 2:08 p.m. UTC | #1
Sean Christopherson <seanjc@google.com> 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@google.com>
> ---
>  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.
Sean Christopherson May 6, 2022, 9:37 p.m. UTC | #2
On Thu, May 05, 2022, Vitaly Kuznetsov wrote:
> Sean Christopherson <seanjc@google.com> 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@google.com>
> > ---
> >  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.

I've no objection to dropping this patch.  I mostly added it to ensure that I
didn't sneak in a warning in any of the intermediate patches, and I can accomplish
that by feeding in -Werror via EXTRA_CFLAGS.
diff mbox series

Patch

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)