From 2f61f3547e3e854cb1b1a7752e2a5e4d38e07f74 Mon Sep 17 00:00:00 2001 From: Denis 'GNUtoo' Carikli Date: Fri, 6 May 2022 03:25:42 +0200 Subject: [PATCH] cbfstool: enable to disable -Werror in standalone builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With GCC 11.2, on GNU/Linux i686, if we run the following commands: $ cd util/cbfstool $ make the build fails with with the following error: host/lib/extract_vmlinuz.c: In function ‘ExtractVmlinuz’: host/lib/extract_vmlinuz.c:67:9: warning: ‘memcpy’ specified bound between 2147483648 and 4294967295 exceeds maximum object size 2147483647 [-Wstringop-overflow=] 67 | memcpy(vmlinuz, kpart_data + vmlinuz_header_offset, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 68 | vmlinuz_header_size); | ~~~~~~~~~~~~~~~~~~~~ Enabling to build cbfstool (and its dependencies like vboot where the above error comes from), we can enable users and distributions to build cbfstool with the distribution toolchain. For that they would need to pass WERROR='' to make, like that: $ cd util/cbfstool $ make WERROR='' Since util/cbfstool/lz4/Makefile isn't used during the build of a standalone cbfstool or a coreboot image, we can simply ignore the -Werror that are inside. Change-Id: I24f59661d3fc218d1e4cd4c36006172ead08b18d Signed-off-by: Denis 'GNUtoo' Carikli --- Description: This patch is needed to fix the cbfstool compilation on 32bit architectures. Forwarded: https://review.coreboot.org/c/coreboot/+/64131 Author: Denis 'GNUtoo' Carikli --- util/cbfstool/Makefile | 2 ++ util/cbfstool/Makefile.inc | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/util/cbfstool/Makefile b/util/cbfstool/Makefile index 034aca26a6be..6fc8cdf1635c 100644 --- a/util/cbfstool/Makefile +++ b/util/cbfstool/Makefile @@ -11,6 +11,8 @@ INSTALL ?= /usr/bin/env install OBJCOPY ?= objcopy override objutil := .. +WERROR ?= -Werror + VBOOT_SOURCE ?= $(top)/3rdparty/vboot VBOOT_HOST_BUILD ?= $(abspath $(objutil)/vboot_lib) diff --git a/util/cbfstool/Makefile.inc b/util/cbfstool/Makefile.inc index f3e6c75dced2..d35f734c8b16 100644 --- a/util/cbfstool/Makefile.inc +++ b/util/cbfstool/Makefile.inc @@ -1,3 +1,5 @@ +WERROR ?= -Werror + compressionobj := compressionobj += compress.o # LZ4 @@ -110,7 +112,7 @@ cse_serger_obj += common.o cse_serger_obj += cse_helpers.o cse_serger_obj += $(foreach var, $(bpdt_formats_obj), $(var)) -TOOLCFLAGS ?= -Werror -Wall -Wextra -Wshadow +TOOLCFLAGS ?= $(WERROR) -Wall -Wextra -Wshadow TOOLCFLAGS += -Wcast-qual -Wmissing-prototypes -Wredundant-decls -Wshadow TOOLCFLAGS += -Wstrict-prototypes -Wwrite-strings TOOLCFLAGS += -O2 @@ -156,6 +158,7 @@ $(VBOOT_HOSTLIB): PKG_CONFIG="true" \ V=$(V) \ DEBUG= \ + WERROR=$(WERROR) \ hostlib $(objutil)/cbfstool/%.o: $(objutil)/cbfstool/%.c -- 2.36.0