Re: [kvm-unit-tests PATCH] Allow to compile without -Werror

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
  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@xxxxxxxxxx>

Thanks,

Paolo




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux