Allow to compile without -Werror
PATCH 1/1 Allow to compile without -Werror
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.
---
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(-)
Makefile +1 -1
@@ -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), "")
configure +16 -0
@@ -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
Signature · 1 line
2.27.0
Quoted 73 lines · Thomas Huth
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
Makefilewith 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 <[email protected]>---
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.patchMakefile | 2 +- configure | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)Makefile +1
-1@@ -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), "")configure +15
-0@@ -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 ;;
configure WA_DIVIDE=$wa_divide · line 392
Quoted 7 lines
configure +1
-0@@ -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
Thanks,
Paolo
Quoted 11 lines · On Tue, 22 Mar 2022 18:15:04 +0100 Thomas Huth <[email protected]> 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
Makefilewith 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 <[email protected]>
makes sense
Quoted 69 lines
---
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.patchMakefile | 2 +- configure | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)Makefile +1
-1@@ -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), "")configure +16
-0@@ -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
Quoted 10 lines · Thomas Huth
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
Makefilewith 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.
Quoted 9 lines
Signed-off-by Thomas Huth <[email protected]>---
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.patchMakefile | 2 +- configure | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)
Quoted 11 lines · Thomas Huth
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
Makefilewith 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 <[email protected]>
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:
Quoted 69 lines
---
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.patchMakefile | 2 +- configure | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-)Makefile +1
-1@@ -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), "")configure +16
-0@@ -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