Message ID | 20190417074754.23808-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | Makefile: ignore format truncation warning for gcc >= 7 only | expand |
Hi Christian, On 17/04/19 09:47, Christian Storm wrote: > gcc versions older than 7.x, e.g., travis' 5.4.0, do not > recognize the -Wno-format-truncation flag. Hence, add > this flag only if a gcc version 7.x onwards is used. > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > Makefile.flags | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/Makefile.flags b/Makefile.flags > index 7a87759..4ee12c9 100644 > --- a/Makefile.flags > +++ b/Makefile.flags > @@ -6,6 +6,12 @@ SWU_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) > export SWU_VER > SKIP_STRIP ?= n > > +ifneq ($(CC),clang) > +GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1) > +GCC_MINOR = $(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1) > +GCC_VERSION = $(GCC_MAJOR)$(GCC_MINOR) > +endif > + > # -std=gnu99 needed for [U]LLONG_MAX on some systems > KBUILD_CPPFLAGS += $(call cc-option,-std=gnu99,) > > @@ -22,8 +28,10 @@ KBUILD_CFLAGS += $(call cc-option,-Wunused-function -Wunused-value,) > KBUILD_CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,) > KBUILD_CFLAGS += $(call cc-option,-Wno-format-security,) > ifneq ($(CC),clang) > +ifeq ($(shell test $(GCC_VERSION) -ge 70 && echo 1), 1) > KBUILD_CFLAGS += $(call cc-option,-Wno-format-truncation,) > endif > +endif > # If you want to add more -Wsomething above, make sure that it is > # still possible to build bbox without warnings. > > I have not seen warnings on Travis, but this can be applied. On the other side I am also asking myself which is the added value brought by the build on Travis, for this and for other projects: I test myself with newer versions of toolchains that reports more warnings as the ancient 5.x. Acked-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
Hi Stefano, > On 17/04/19 09:47, Christian Storm wrote: > > gcc versions older than 7.x, e.g., travis' 5.4.0, do not > > recognize the -Wno-format-truncation flag. Hence, add > > this flag only if a gcc version 7.x onwards is used. > > > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > > --- > > Makefile.flags | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/Makefile.flags b/Makefile.flags > > index 7a87759..4ee12c9 100644 > > --- a/Makefile.flags > > +++ b/Makefile.flags > > @@ -6,6 +6,12 @@ SWU_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) > > export SWU_VER > > SKIP_STRIP ?= n > > > > +ifneq ($(CC),clang) > > +GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1) > > +GCC_MINOR = $(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1) > > +GCC_VERSION = $(GCC_MAJOR)$(GCC_MINOR) > > +endif > > + > > # -std=gnu99 needed for [U]LLONG_MAX on some systems > > KBUILD_CPPFLAGS += $(call cc-option,-std=gnu99,) > > > > @@ -22,8 +28,10 @@ KBUILD_CFLAGS += $(call cc-option,-Wunused-function -Wunused-value,) > > KBUILD_CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,) > > KBUILD_CFLAGS += $(call cc-option,-Wno-format-security,) > > ifneq ($(CC),clang) > > +ifeq ($(shell test $(GCC_VERSION) -ge 70 && echo 1), 1) > > KBUILD_CFLAGS += $(call cc-option,-Wno-format-truncation,) > > endif > > +endif > > # If you want to add more -Wsomething above, make sure that it is > > # still possible to build bbox without warnings. > > > > > > I have not seen warnings on Travis, but this can be applied. See here: https://travis-ci.org/siemens/swupdate/builds/520802753#L2276 I only recognized it by chance. In this version of gcc, it's triggered somewhat flaky. Sometimes it appears, sometimes not. Haven't looked into it deeply enough to understand the trigger though.. > On the other side I am also asking myself which is the added value brought by > the build on Travis, for this and for other projects: I test myself with > newer versions of toolchains that reports more warnings as the ancient 5.x. Yes, and even more so if you also use clang in addition to gcc. I do see some value in this as the systems SWUpdate is deployed to could use an older software stack, so, if something as old as travis's is happy, it's a good indication of being applicable to old stacks on the deployments as well :) Joking aside, as it's for free and provides some first indication, I think it has some value. At least I'm used to let travis run on my commits prior to submitting them to this ML. Kind regards, Christian
diff --git a/Makefile.flags b/Makefile.flags index 7a87759..4ee12c9 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -6,6 +6,12 @@ SWU_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) export SWU_VER SKIP_STRIP ?= n +ifneq ($(CC),clang) +GCC_MAJOR = $(shell echo __GNUC__ | $(CC) -E -x c - | tail -n 1) +GCC_MINOR = $(shell echo __GNUC_MINOR__ | $(CC) -E -x c - | tail -n 1) +GCC_VERSION = $(GCC_MAJOR)$(GCC_MINOR) +endif + # -std=gnu99 needed for [U]LLONG_MAX on some systems KBUILD_CPPFLAGS += $(call cc-option,-std=gnu99,) @@ -22,8 +28,10 @@ KBUILD_CFLAGS += $(call cc-option,-Wunused-function -Wunused-value,) KBUILD_CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,) KBUILD_CFLAGS += $(call cc-option,-Wno-format-security,) ifneq ($(CC),clang) +ifeq ($(shell test $(GCC_VERSION) -ge 70 && echo 1), 1) KBUILD_CFLAGS += $(call cc-option,-Wno-format-truncation,) endif +endif # If you want to add more -Wsomething above, make sure that it is # still possible to build bbox without warnings.
gcc versions older than 7.x, e.g., travis' 5.4.0, do not recognize the -Wno-format-truncation flag. Hence, add this flag only if a gcc version 7.x onwards is used. Signed-off-by: Christian Storm <christian.storm@siemens.com> --- Makefile.flags | 8 ++++++++ 1 file changed, 8 insertions(+)