Re: [PATCH 3/3] Basetools: turn off gcc12 warning

Bob Feng

Hi Gerd,

Could you provide a patch to fix this issue or revert the original commit?


-----Original Message-----
From: Rebecca Cran <rebecca@...>
Sent: Tuesday, March 29, 2022 5:30 AM
To:; kraxel@...
Cc: Pawel Polawski <ppolawsk@...>; Gao, Liming <gaoliming@...>; Chen, Christine <yuwei.chen@...>; Oliver Steffen <osteffen@...>; Feng, Bob C <bob.c.feng@...>
Subject: Re: [edk2-devel] [PATCH 3/3] Basetools: turn off gcc12 warning

This breaks building BaseTools with clang 13.1.6 on macOS:

/Applications/ -C DevicePath gcc  -c  -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/AArch64/ -MD -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-deprecated-declarations -Wno-self-assign -Wno-unused-result -nostdlib -g -O2  -Wno-error=stringop-overflow DevicePath.c -o DevicePath.o
error: unknown warning option '-Werror=stringop-overflow'; did you mean '-Werror=shift-overflow'? [-Werror,-Wunknown-warning-option]


Rebecca Cran

On 3/24/22 6:04 AM, Gerd Hoffmann wrote:
In function ‘SetDevicePathEndNode’,
inlined from ‘FileDevicePath’ at DevicePathUtilities.c:857:5:
DevicePathUtilities.c:321:3: error: writing 4 bytes into a region of size 1 [-Werror=stringop-overflow=]
321 | memcpy (Node, &mUefiDevicePathLibEndDevicePath, sizeof (mUefiDevicePathLibEndDevicePath));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from UefiDevicePathLib.h:22,
from DevicePathUtilities.c:16:
../Include/Protocol/DevicePath.h: In function ‘FileDevicePath’:
../Include/Protocol/DevicePath.h:51:9: note: destination object ‘Type’ of size 1
51 | UINT8 Type; ///< 0x01 Hardware Device Path.
| ^~~~

Signed-off-by: Gerd Hoffmann <kraxel@...>
BaseTools/Source/C/DevicePath/GNUmakefile | 3 +++
1 file changed, 3 insertions(+)

diff --git a/BaseTools/Source/C/DevicePath/GNUmakefile
index 7ca08af9662d..b05d2bddfa68 100644
--- a/BaseTools/Source/C/DevicePath/GNUmakefile
+++ b/BaseTools/Source/C/DevicePath/GNUmakefile
@@ -13,6 +13,9 @@ OBJECTS = DevicePath.o UefiDevicePathLib.o
DevicePathFromText.o DevicePathUtili

include $(MAKEROOT)/Makefiles/app.makefile

+# gcc 12 trips over device path handling BUILD_CFLAGS +=
LIBS = -lCommon
ifeq ($(CYGWIN), CYGWIN)
LIBS += -L/lib/e2fsprogs -luuid

Join to automatically receive all group messages.