diff mbox

[v3] Allow warnings conditionally.

Message ID 1461201360-22387-1-git-send-email-alastair@au1.ibm.com
State Superseded
Headers show

Commit Message

Alastair D'Silva April 21, 2016, 1:16 a.m. UTC
From: Alastair D'Silva <alastair@d-silva.org>

When building in CI, we want to see all potential problems noted by compilers & static analysers that masquerade as a compiler, rather than halting on the first one.
This is especially important as we tend to implement different/stricter/expensive checks compared to a typical compiler, and as such, these may not be visible when performing a normal build.

This patch conditionally allows compiler warnings by passing ALLOW_WARNINGS=1 as a make variable. The default behaviour remains to fault on the first warning.

Signed-off-by: Alastair D'Silva <alastair@d-silva.org>

---
Changelog
v2: Resend without UTF8 corruption
v3: Rebase onto latest master
---
 Makefile.main              | 6 ++++--
 external/gard/rules.mk     | 5 ++++-
 external/opal-prd/Makefile | 5 ++++-
 external/shared/Makefile   | 5 ++++-
 4 files changed, 16 insertions(+), 5 deletions(-)

Comments

Michael Neuling April 21, 2016, 2:06 a.m. UTC | #1
On Thu, 2016-04-21 at 11:16 +1000, alastair@au1.ibm.com wrote:
> From: Alastair D'Silva <alastair@d-silva.org>
> 
> When building in CI, we want to see all potential problems noted by compilers & static analysers that masquerade as a compiler, rather than halting on the first one.
> This is especially important as we tend to implement different/stricter/expensive checks compared to a typical compiler, and as such, these may not be visible when performing a normal build.

Another quick one.. Can you limit the commit message 
to 80 cols? v1 didn't have these giant lines.

Mikey

> 
> This patch conditionally allows compiler warnings by passing ALLOW_WARNINGS=1 as a make variable. The default behaviour remains to fault on the first warning.
> 
> Signed-off-by: Alastair D'Silva <alastair@d-silva.org>
> 
> ---
> Changelog
> v2: Resend without UTF8 corruption
> v3: Rebase onto latest master
> ---
>  Makefile.main              | 6 ++++--
>  external/gard/rules.mk     | 5 ++++-
>  external/opal-prd/Makefile | 5 ++++-
>  external/shared/Makefile   | 5 ++++-
>  4 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/Makefile.main b/Makefile.main
> index 30c22be..ae15112 100644
> --- a/Makefile.main
> +++ b/Makefile.main
> @@ -27,8 +27,10 @@ CWARNS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
>  	  -Wmissing-prototypes -Wmissing-declarations \
>  	  -Wwrite-strings -Wcast-align \
>  	  -Winit-self \
> -	  -Wframe-larger-than=1024 \
> -	  -Werror
> +	  -Wframe-larger-than=1024
> +ifneq ($(ALLOW_WARNINGS),1)
> +CWARNS += -Werror
> +endif
>  
>  # Host tools and options
>  HOSTCC=gcc
> diff --git a/external/gard/rules.mk b/external/gard/rules.mk
> index 0dd14ed..16c9b08 100644
> --- a/external/gard/rules.mk
> +++ b/external/gard/rules.mk
> @@ -1,6 +1,9 @@
>  .DEFAULT_GOAL := all
>  
> -override CFLAGS += -O2 -Wall -Werror -I.
> +override CFLAGS += -O2 -Wall -I.
> +ifneq ($(ALLOW_WARNINGS),1)
> +override CFLAGS += -Werror
> +endif
>  OBJS      = version.o gard.o
>  LIBFLASH_OBJS     += libflash-file.o libflash-libflash.o libflash-libffs.o libflash-ecc.o libflash-blocklevel.o
>  OBJS     += $(LIBFLASH_OBJS)
> diff --git a/external/opal-prd/Makefile b/external/opal-prd/Makefile
> index 7482af3..a9c98e0 100644
> --- a/external/opal-prd/Makefile
> +++ b/external/opal-prd/Makefile
> @@ -1,4 +1,7 @@
> -CFLAGS += -m64 -Werror -Wall -g2 -ggdb
> +CFLAGS += -m64 -Wall -g2 -ggdb
> +ifneq ($(ALLOW_WARNINGS),1)
> +CFLAGS += -Werror
> +endif
>  LDFLAGS += -m64
>  ASFLAGS = -m64
>  CPPFLAGS += -I. -I../../include -I../../
> diff --git a/external/shared/Makefile b/external/shared/Makefile
> index 4c31657..d58658c 100644
> --- a/external/shared/Makefile
> +++ b/external/shared/Makefile
> @@ -8,7 +8,10 @@ INCDIR = $(PREFIX)/include/libflash
>  
>  VERSION = $(shell ../../make_version.sh)
>  
> -CFLAGS += -m64 -Werror -Wall -g2 -ggdb -I. -fPIC
> +CFLAGS += -m64 -Wall -g2 -ggdb -I. -fPIC
> +ifneq ($(ALLOW_WARNINGS),1)
> +CFLAGS += -Werror
> +endif
>  
>  .PHONY: links
>  links: libflash ccan common
diff mbox

Patch

diff --git a/Makefile.main b/Makefile.main
index 30c22be..ae15112 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -27,8 +27,10 @@  CWARNS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 	  -Wmissing-prototypes -Wmissing-declarations \
 	  -Wwrite-strings -Wcast-align \
 	  -Winit-self \
-	  -Wframe-larger-than=1024 \
-	  -Werror
+	  -Wframe-larger-than=1024
+ifneq ($(ALLOW_WARNINGS),1)
+CWARNS += -Werror
+endif
 
 # Host tools and options
 HOSTCC=gcc
diff --git a/external/gard/rules.mk b/external/gard/rules.mk
index 0dd14ed..16c9b08 100644
--- a/external/gard/rules.mk
+++ b/external/gard/rules.mk
@@ -1,6 +1,9 @@ 
 .DEFAULT_GOAL := all
 
-override CFLAGS += -O2 -Wall -Werror -I.
+override CFLAGS += -O2 -Wall -I.
+ifneq ($(ALLOW_WARNINGS),1)
+override CFLAGS += -Werror
+endif
 OBJS      = version.o gard.o
 LIBFLASH_OBJS     += libflash-file.o libflash-libflash.o libflash-libffs.o libflash-ecc.o libflash-blocklevel.o
 OBJS     += $(LIBFLASH_OBJS)
diff --git a/external/opal-prd/Makefile b/external/opal-prd/Makefile
index 7482af3..a9c98e0 100644
--- a/external/opal-prd/Makefile
+++ b/external/opal-prd/Makefile
@@ -1,4 +1,7 @@ 
-CFLAGS += -m64 -Werror -Wall -g2 -ggdb
+CFLAGS += -m64 -Wall -g2 -ggdb
+ifneq ($(ALLOW_WARNINGS),1)
+CFLAGS += -Werror
+endif
 LDFLAGS += -m64
 ASFLAGS = -m64
 CPPFLAGS += -I. -I../../include -I../../
diff --git a/external/shared/Makefile b/external/shared/Makefile
index 4c31657..d58658c 100644
--- a/external/shared/Makefile
+++ b/external/shared/Makefile
@@ -8,7 +8,10 @@  INCDIR = $(PREFIX)/include/libflash
 
 VERSION = $(shell ../../make_version.sh)
 
-CFLAGS += -m64 -Werror -Wall -g2 -ggdb -I. -fPIC
+CFLAGS += -m64 -Wall -g2 -ggdb -I. -fPIC
+ifneq ($(ALLOW_WARNINGS),1)
+CFLAGS += -Werror
+endif
 
 .PHONY: links
 links: libflash ccan common