diff mbox series

[kvm-unit-tests] Allow to compile without -Werror

Message ID 20220322171504.941686-1-thuth@redhat.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests] Allow to compile without -Werror | expand

Commit Message

Thomas Huth March 22, 2022, 5:15 p.m. UTC
Newer compiler versions sometimes introduce new warnings - and compiling
with -Werror will fail there, of course. Thus users of the kvm-unit-tests
like the buildroot project have to disable the "-Werror" in the Makefile
with an additional patch, which is cumbersome.
Thus let's add a switch to the configure script that allows to explicitly
turn the -Werror switch on or off. And enable it only by default for
developer builds (i.e. in checked-out git repositories) ... and for
tarball releases, it's nicer if it is disabled by default, so that the
end users do not have to worry about this.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 See also the patch from the buildroot project:
 https://git.busybox.net/buildroot/tree/package/kvm-unit-tests/0001-Makefile-remove-Werror-to-avoid-build-failures.patch

 Makefile  |  2 +-
 configure | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini March 22, 2022, 5:22 p.m. UTC | #1
On 3/22/22 18:15, Thomas Huth wrote:
> Newer compiler versions sometimes introduce new warnings - and compiling
> with -Werror will fail there, of course. Thus users of the kvm-unit-tests
> like the buildroot project have to disable the "-Werror" in the Makefile
> with an additional patch, which is cumbersome.
> Thus let's add a switch to the configure script that allows to explicitly
> turn the -Werror switch on or off. And enable it only by default for
> developer builds (i.e. in checked-out git repositories) ... and for
> tarball releases, it's nicer if it is disabled by default, so that the
> end users do not have to worry about this.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   See also the patch from the buildroot project:
>   https://git.busybox.net/buildroot/tree/package/kvm-unit-tests/0001-Makefile-remove-Werror-to-avoid-build-failures.patch
> 
>   Makefile  |  2 +-
>   configure | 16 ++++++++++++++++
>   2 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 24686dd..6ed5dea 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -62,7 +62,7 @@ include $(SRCDIR)/$(TEST_DIR)/Makefile
>   
>   COMMON_CFLAGS += -g $(autodepend-flags) -fno-strict-aliasing -fno-common
>   COMMON_CFLAGS += -Wall -Wwrite-strings -Wempty-body -Wuninitialized
> -COMMON_CFLAGS += -Wignored-qualifiers -Werror -Wno-missing-braces
> +COMMON_CFLAGS += -Wignored-qualifiers -Wno-missing-braces $(CONFIG_WERROR)
>   
>   frame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer
>   fomit_frame_pointer := $(call cc-option, $(frame-pointer-flag), "")
> diff --git a/configure b/configure
> index c4fb4a2..86c3095 100755
> --- a/configure
> +++ b/configure
> @@ -31,6 +31,13 @@ page_size=
>   earlycon=
>   efi=
>   
> +# Enable -Werror by default for git repositories only (i.e. developer builds)
> +if [ -e "$srcdir"/.git ]; then
> +    werror=-Werror
> +else
> +    werror=
> +fi
> +
>   usage() {
>       cat <<-EOF
>   	Usage: $0 [options]
> @@ -75,6 +82,8 @@ usage() {
>   	                           Specify a PL011 compatible UART at address ADDR. Supported
>   	                           register stride is 32 bit only.
>   	    --[enable|disable]-efi Boot and run from UEFI (disabled by default, x86_64 only)
> +	    --[enable|disable]-werror
> +	                           Select whether to compile with the -Werror compiler flag
>   EOF
>       exit 1
>   }
> @@ -148,6 +157,12 @@ while [[ "$1" = -* ]]; do
>   	--disable-efi)
>   	    efi=n
>   	    ;;
> +	--enable-werror)
> +	    werror=-Werror
> +	    ;;
> +	--disable-werror)
> +	    werror=
> +	    ;;
>   	--help)
>   	    usage
>   	    ;;
> @@ -371,6 +386,7 @@ WA_DIVIDE=$wa_divide
>   GENPROTIMG=${GENPROTIMG-genprotimg}
>   HOST_KEY_DOCUMENT=$host_key_document
>   CONFIG_EFI=$efi
> +CONFIG_WERROR=$werror
>   GEN_SE_HEADER=$gen_se_header
>   EOF
>   if [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

Thanks,

Paolo
Claudio Imbrenda March 22, 2022, 7:44 p.m. UTC | #2
On Tue, 22 Mar 2022 18:15:04 +0100
Thomas Huth <thuth@redhat.com> wrote:

> Newer compiler versions sometimes introduce new warnings - and compiling
> with -Werror will fail there, of course. Thus users of the kvm-unit-tests
> like the buildroot project have to disable the "-Werror" in the Makefile
> with an additional patch, which is cumbersome.
> Thus let's add a switch to the configure script that allows to explicitly
> turn the -Werror switch on or off. And enable it only by default for
> developer builds (i.e. in checked-out git repositories) ... and for
> tarball releases, it's nicer if it is disabled by default, so that the
> end users do not have to worry about this.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

makes sense

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
>  See also the patch from the buildroot project:
>  https://git.busybox.net/buildroot/tree/package/kvm-unit-tests/0001-Makefile-remove-Werror-to-avoid-build-failures.patch
> 
>  Makefile  |  2 +-
>  configure | 16 ++++++++++++++++
>  2 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 24686dd..6ed5dea 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -62,7 +62,7 @@ include $(SRCDIR)/$(TEST_DIR)/Makefile
>  
>  COMMON_CFLAGS += -g $(autodepend-flags) -fno-strict-aliasing -fno-common
>  COMMON_CFLAGS += -Wall -Wwrite-strings -Wempty-body -Wuninitialized
> -COMMON_CFLAGS += -Wignored-qualifiers -Werror -Wno-missing-braces
> +COMMON_CFLAGS += -Wignored-qualifiers -Wno-missing-braces $(CONFIG_WERROR)
>  
>  frame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer
>  fomit_frame_pointer := $(call cc-option, $(frame-pointer-flag), "")
> diff --git a/configure b/configure
> index c4fb4a2..86c3095 100755
> --- a/configure
> +++ b/configure
> @@ -31,6 +31,13 @@ page_size=
>  earlycon=
>  efi=
>  
> +# Enable -Werror by default for git repositories only (i.e. developer builds)
> +if [ -e "$srcdir"/.git ]; then
> +    werror=-Werror
> +else
> +    werror=
> +fi
> +
>  usage() {
>      cat <<-EOF
>  	Usage: $0 [options]
> @@ -75,6 +82,8 @@ usage() {
>  	                           Specify a PL011 compatible UART at address ADDR. Supported
>  	                           register stride is 32 bit only.
>  	    --[enable|disable]-efi Boot and run from UEFI (disabled by default, x86_64 only)
> +	    --[enable|disable]-werror
> +	                           Select whether to compile with the -Werror compiler flag
>  EOF
>      exit 1
>  }
> @@ -148,6 +157,12 @@ while [[ "$1" = -* ]]; do
>  	--disable-efi)
>  	    efi=n
>  	    ;;
> +	--enable-werror)
> +	    werror=-Werror
> +	    ;;
> +	--disable-werror)
> +	    werror=
> +	    ;;
>  	--help)
>  	    usage
>  	    ;;
> @@ -371,6 +386,7 @@ WA_DIVIDE=$wa_divide
>  GENPROTIMG=${GENPROTIMG-genprotimg}
>  HOST_KEY_DOCUMENT=$host_key_document
>  CONFIG_EFI=$efi
> +CONFIG_WERROR=$werror
>  GEN_SE_HEADER=$gen_se_header
>  EOF
>  if [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
Andrew Jones March 23, 2022, 7:45 a.m. UTC | #3
On Tue, Mar 22, 2022 at 06:15:04PM +0100, Thomas Huth wrote:
> Newer compiler versions sometimes introduce new warnings - and compiling
> with -Werror will fail there, of course. Thus users of the kvm-unit-tests
> like the buildroot project have to disable the "-Werror" in the Makefile
> with an additional patch, which is cumbersome.
> Thus let's add a switch to the configure script that allows to explicitly
> turn the -Werror switch on or off. And enable it only by default for
> developer builds (i.e. in checked-out git repositories) ... and for
> tarball releases, it's nicer if it is disabled by default, so that the
> end users do not have to worry about this.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  See also the patch from the buildroot project:
>  https://git.busybox.net/buildroot/tree/package/kvm-unit-tests/0001-Makefile-remove-Werror-to-avoid-build-failures.patch
> 
>  Makefile  |  2 +-
>  configure | 16 ++++++++++++++++
>  2 files changed, 17 insertions(+), 1 deletion(-)
>
 
Reviewed-by: Andrew Jones <drjones@redhat.com>
Janosch Frank March 23, 2022, 8:05 a.m. UTC | #4
On 3/22/22 18:15, Thomas Huth wrote:
> Newer compiler versions sometimes introduce new warnings - and compiling
> with -Werror will fail there, of course. Thus users of the kvm-unit-tests
> like the buildroot project have to disable the "-Werror" in the Makefile
> with an additional patch, which is cumbersome.
> Thus let's add a switch to the configure script that allows to explicitly
> turn the -Werror switch on or off. And enable it only by default for
> developer builds (i.e. in checked-out git repositories) ... and for
> tarball releases, it's nicer if it is disabled by default, so that the
> end users do not have to worry about this.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

I'm tempted to introduce a -W-unused-* switch so the compiler doesn't 
annoy me anymore when I'm working on new things. But on the other hand 
I'd forget to disable it before submission :-)


Anyway:
Acked-by: Janosch Frank <frankja@linux.ibm.com>


> ---
>   See also the patch from the buildroot project:
>   https://git.busybox.net/buildroot/tree/package/kvm-unit-tests/0001-Makefile-remove-Werror-to-avoid-build-failures.patch
> 
>   Makefile  |  2 +-
>   configure | 16 ++++++++++++++++
>   2 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index 24686dd..6ed5dea 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -62,7 +62,7 @@ include $(SRCDIR)/$(TEST_DIR)/Makefile
>   
>   COMMON_CFLAGS += -g $(autodepend-flags) -fno-strict-aliasing -fno-common
>   COMMON_CFLAGS += -Wall -Wwrite-strings -Wempty-body -Wuninitialized
> -COMMON_CFLAGS += -Wignored-qualifiers -Werror -Wno-missing-braces
> +COMMON_CFLAGS += -Wignored-qualifiers -Wno-missing-braces $(CONFIG_WERROR)
>   
>   frame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer
>   fomit_frame_pointer := $(call cc-option, $(frame-pointer-flag), "")
> diff --git a/configure b/configure
> index c4fb4a2..86c3095 100755
> --- a/configure
> +++ b/configure
> @@ -31,6 +31,13 @@ page_size=
>   earlycon=
>   efi=
>   
> +# Enable -Werror by default for git repositories only (i.e. developer builds)
> +if [ -e "$srcdir"/.git ]; then
> +    werror=-Werror
> +else
> +    werror=
> +fi
> +
>   usage() {
>       cat <<-EOF
>   	Usage: $0 [options]
> @@ -75,6 +82,8 @@ usage() {
>   	                           Specify a PL011 compatible UART at address ADDR. Supported
>   	                           register stride is 32 bit only.
>   	    --[enable|disable]-efi Boot and run from UEFI (disabled by default, x86_64 only)
> +	    --[enable|disable]-werror
> +	                           Select whether to compile with the -Werror compiler flag
>   EOF
>       exit 1
>   }
> @@ -148,6 +157,12 @@ while [[ "$1" = -* ]]; do
>   	--disable-efi)
>   	    efi=n
>   	    ;;
> +	--enable-werror)
> +	    werror=-Werror
> +	    ;;
> +	--disable-werror)
> +	    werror=
> +	    ;;
>   	--help)
>   	    usage
>   	    ;;
> @@ -371,6 +386,7 @@ WA_DIVIDE=$wa_divide
>   GENPROTIMG=${GENPROTIMG-genprotimg}
>   HOST_KEY_DOCUMENT=$host_key_document
>   CONFIG_EFI=$efi
> +CONFIG_WERROR=$werror
>   GEN_SE_HEADER=$gen_se_header
>   EOF
>   if [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 24686dd..6ed5dea 100644
--- a/Makefile
+++ b/Makefile
@@ -62,7 +62,7 @@  include $(SRCDIR)/$(TEST_DIR)/Makefile
 
 COMMON_CFLAGS += -g $(autodepend-flags) -fno-strict-aliasing -fno-common
 COMMON_CFLAGS += -Wall -Wwrite-strings -Wempty-body -Wuninitialized
-COMMON_CFLAGS += -Wignored-qualifiers -Werror -Wno-missing-braces
+COMMON_CFLAGS += -Wignored-qualifiers -Wno-missing-braces $(CONFIG_WERROR)
 
 frame-pointer-flag=-f$(if $(KEEP_FRAME_POINTER),no-,)omit-frame-pointer
 fomit_frame_pointer := $(call cc-option, $(frame-pointer-flag), "")
diff --git a/configure b/configure
index c4fb4a2..86c3095 100755
--- a/configure
+++ b/configure
@@ -31,6 +31,13 @@  page_size=
 earlycon=
 efi=
 
+# Enable -Werror by default for git repositories only (i.e. developer builds)
+if [ -e "$srcdir"/.git ]; then
+    werror=-Werror
+else
+    werror=
+fi
+
 usage() {
     cat <<-EOF
 	Usage: $0 [options]
@@ -75,6 +82,8 @@  usage() {
 	                           Specify a PL011 compatible UART at address ADDR. Supported
 	                           register stride is 32 bit only.
 	    --[enable|disable]-efi Boot and run from UEFI (disabled by default, x86_64 only)
+	    --[enable|disable]-werror
+	                           Select whether to compile with the -Werror compiler flag
 EOF
     exit 1
 }
@@ -148,6 +157,12 @@  while [[ "$1" = -* ]]; do
 	--disable-efi)
 	    efi=n
 	    ;;
+	--enable-werror)
+	    werror=-Werror
+	    ;;
+	--disable-werror)
+	    werror=
+	    ;;
 	--help)
 	    usage
 	    ;;
@@ -371,6 +386,7 @@  WA_DIVIDE=$wa_divide
 GENPROTIMG=${GENPROTIMG-genprotimg}
 HOST_KEY_DOCUMENT=$host_key_document
 CONFIG_EFI=$efi
+CONFIG_WERROR=$werror
 GEN_SE_HEADER=$gen_se_header
 EOF
 if [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then