The gcc 8 compiler introduces a warning for certain string manipulation functions, flagging usages which _may_ not be intended. An audit of the ipxe sources indicates all usages of strncat and strncpy are as intended, so the warnings currently issues are not helpful, especially if warnings are considered errors.
This patch adds detection of gcc's support for -Wno-stringop-truncation to the build system, and if detected, uses that option to avoid the warning. Signed-off-by: Bruce Rogers <brog...@suse.com> --- src/Makefile.housekeeping | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index 00b07926..252a580f 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -131,6 +131,7 @@ eval : # WORKAROUND_CFLAGS := +WORKAROUND_HOST_CFLAGS := WORKAROUND_ASFLAGS := WORKAROUND_LDFLAGS := @@ -177,6 +178,14 @@ ifeq ($(CCTYPE),gcc) WNA_TEST = $(CC) -Wno-address -x c -c /dev/null -o /dev/null >/dev/null 2>&1 WNA_FLAGS := $(shell $(WNA_TEST) && $(ECHO) '-Wno-address') WORKAROUND_CFLAGS += $(WNA_FLAGS) + +# gcc 8.0 generates warnings for certain suspect string operations. Our sources +# have been vetted for correct usage. Turn off these warnings. +WNST_TEST = $(CC) -Wno-stringop-truncation -x c -c /dev/null -o /dev/null \ + >/dev/null 2>&1 +WNST_FLAGS := $(shell $(WNST_TEST) && $(ECHO) '-Wno-stringop-truncation') +WORKAROUND_CFLAGS += $(WNST_FLAGS) +WORKAROUND_HOST_CFLAGS += $(WNST_FLAGS) endif # Some versions of gas choke on division operators, treating them as @@ -437,7 +446,7 @@ endif CFLAGS += $(WORKAROUND_CFLAGS) $(EXTRA_CFLAGS) ASFLAGS += $(WORKAROUND_ASFLAGS) $(EXTRA_ASFLAGS) LDFLAGS += $(WORKAROUND_LDFLAGS) $(EXTRA_LDFLAGS) -HOST_CFLAGS += -O2 -g +HOST_CFLAGS += $(WORKAROUND_HOST_CFLAGS) -O2 -g # Inhibit -Werror if NO_WERROR is specified on make command line # -- 2.16.3 _______________________________________________ ipxe-devel mailing list ipxe-devel@lists.ipxe.org https://lists.ipxe.org/mailman/listinfo.cgi/ipxe-devel