Hi,

Compiling iPXE with GCC version 12 fails.

People of SUSE consider it a false positive and silence the warning.

That workaround is available in a public git repository. Get it by

  git remote add suse https://github.com/openSUSE/qemu-ipxe
  git fetch suse
  git cherry-pick 1dcf6506629ae

Or `git am` the attachment.



Regards
Geert Stappers
-- 
Silence is hard to parse
>From 5383328f303bf9a4f7f837acda49d844f901812a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Li=C5=A1ka?= <martin.li...@suse.com>
Date: Tue, 22 Mar 2022 10:52:19 +0100
Subject: [PATCH] Silence GCC 12 spurious warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Git-commit: 0000000000000000000000000000000000000000
References: bsc#1197018

With GCC 12, build fails like this:

[ 6245s]     inlined from 'memcpy_user' at
arch/x86/include/librm.h:155:2,
[ 6245s]     inlined from 'copy_from_user' at
include/ipxe/uaccess.h:338:2,
[ 6245s]     inlined from 'acpi_sx_zsdt' at core/acpi.c:217:3:
[ 6245s] arch/x86/include/bits/string.h:79:32: error: array subscript
'union <anonymous>[0]' is partly outside array bounds of 'union
<anonymous>[1]' [-Werror=array-bounds]
[ 6245s]    79 |                 dest_u->u32[0] = src_u->u32[0];
[ 6245s]       |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
[ 6245s] core/acpi.c: In function 'acpi_sx_zsdt':
[ 6245s] core/acpi.c:191:11: note: object 'buf' of size 4
[ 6245s]   191 |         } buf;
[ 6245s]       |           ^~~

Which is a false positive reported by GCC compiler:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98503

Silence the watning.

Signed-off-by: Martin Liška <martin.li...@suse.com>
Signed-off-by: Dario Faggioli <dfaggi...@suse.com>
---
 src/Makefile.housekeeping | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping
index 9bf34b2e..41bf1896 100644
--- a/src/Makefile.housekeeping
+++ b/src/Makefile.housekeeping
@@ -188,6 +188,19 @@ WNAPM_TEST = $(CC) -Wno-address-of-packed-member -x c -c /dev/null \
 WNAPM_FLAGS := $(shell $(WNAPM_TEST) && \
 		 $(ECHO) '-Wno-address-of-packed-member')
 WORKAROUND_CFLAGS += $(WNAPM_FLAGS)
+
+# gcc 12.1 generates false positive warnings.  Inhibit the warnings.
+WNAB_TEST = $(CC) -Wno-array-bounds -x c -c /dev/null \
+		   -o /dev/null >/dev/null 2>&1
+WNAB_FLAGS := $(shell $(WNAB_TEST) && \
+	      $(ECHO) '-Wno-array-bounds')
+WORKAROUND_CFLAGS += $(WNAB_FLAGS)
+
+WNDP_TEST = $(CC) -Wno-dangling-pointer-x c -c /dev/null \
+		  -o /dev/null >/dev/null 2>&1
+WNDP_FLAGS := $(shell $(WNAB_TEST) && \
+	       $(ECHO) '-Wno-dangling-pointer')
+WORKAROUND_CFLAGS += $(WNDP_FLAGS)
 endif
 
 # Some versions of gas choke on division operators, treating them as
-- 
2.36.1

_______________________________________________
ipxe-devel mailing list
ipxe-devel@lists.ipxe.org
https://lists.ipxe.org/mailman/listinfo/ipxe-devel

Reply via email to