recipes-core/ovmf: Fix build with gcc 12
PATCH 1/1 recipes-core/ovmf: Fix build with gcc 12
From: Bernhard Rosenkränzer <[email protected]>
edk2 doesn't compile with gcc 12 - due to 2 legitimate bugs (trying to use a file handle as if it were a string) and 2 new warnings in code using -Werror (they need further investigation to determine if they're legitimate bugs or false positives; in the mean time we can keep things building by disabling the warnings for the particular lines triggering them).
The proper fixes have already been submitted upstream at
https://github.com/tianocore/edk2/pull/2602
Will not submit the workarounds for the warnings upstream for now.
--- ...nfusion-between-file-handle-and-name.patch | 44 +++++++++++++++++++ ...orkaround-for-gcc-12-build-failure-2.patch | 33 ++++++++++++++ ...-workaround-for-gcc-12-build-failure.patch | 28 ++++++++++++ meta/recipes-core/ovmf/ovmf_git.bb | 3 ++ 4 files changed, 108 insertions(+) create mode 100644 meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch create mode 100644 meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patch create mode 100644 meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patch
meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch new file +44 -0
@@ -0,0 +1,44 @@ +From 74e7ad4e400ea3f942805e70df4d3ed6990759f3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <[email protected]> +Date: Tue, 8 Mar 2022 18:56:23 +0100 +Subject: [PATCH] GenFfs: Don't treat a file handle as a string +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The current code tries to print the file handle as a string on error. +Do what it is meant to do instead: Print the file name. + +Upstream-Status: Submitted [https://github.com/tianocore/edk2/pull/2602] +Signed-off-by: Bernhard Rosenkränzer <[email protected]> +--- + BaseTools/Source/C/GenFfs/GenFfs.c | 2 +- + BaseTools/Source/C/GenSec/GenSec.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenFfs/GenFfs.c +index 949025c33325..06e009e279ce 100644 +--- a/BaseTools/Source/C/GenFfs/GenFfs.c ++++ b/BaseTools/Source/C/GenFfs/GenFfs.c +@@ -542,7 +542,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment) + PeFileBuffer = (UINT8 *) malloc (PeFileSize); + if (PeFileBuffer == NULL) { + fclose (InFileHandle); +- Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); ++ Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFile); + return EFI_OUT_OF_RESOURCES; + } + fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); +diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c +index d54a4f9e0a7d..1ad92de1d50e 100644 +--- a/BaseTools/Source/C/GenSec/GenSec.c ++++ b/BaseTools/Source/C/GenSec/GenSec.c +@@ -1062,7 +1062,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment) + PeFileBuffer = (UINT8 *) malloc (PeFileSize); + if (PeFileBuffer == NULL) { + fclose (InFileHandle); +- Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle); ++ Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFile); + return EFI_OUT_OF_RESOURCES; + } + fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);
meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patch new file +33 -0
@@ -0,0 +1,33 @@ +From: Bernhard Rosenkränzer <[email protected]> +Date: Fri, 18 Mar 2022 17:28:47 +0100 +Subject: [PATCH] Disable gcc >= 12 stringop-overflow warning + +gcc 12 warns about a stringop-overflow with SetDevicePathEndNode +potentially copying 4 bytes to an area of 1 byte. +Since edk2 is built with -Werror, this breaks the build. + +It is not immedaitely clear whether this is a false warning or if +SetDevicePathEndNode is being used incorrectly somewhere, but since +the code seems to work, ignore the warning for the time being to +keep things buildable. + +This should be investigated properly at some point. + +Upstream-Status: Inappropriate [Workaround to keep things going, should be fixed properly] +Signed-off-by: Bernhard Rosenkränzer <[email protected]> + +diff --git a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c b/BaseTools/Source/C/DevicePath/DevicePathUtilities.c +index 2ffefa8cee..32c02bdf82 100644 +--- a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c ++++ b/BaseTools/Source/C/DevicePath/DevicePathUtilities.c +@@ -318,7 +318,10 @@ SetDevicePathEndNode ( + ) + { + ASSERT (Node != NULL); ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wstringop-overflow" + memcpy (Node, &mUefiDevicePathLibEndDevicePath, sizeof (mUefiDevicePathLibEndDevicePath)); ++#pragma GCC diagnostic pop + } + + /**
meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patch new file +28 -0
@@ -0,0 +1,28 @@ +From: Bernhard Rosenkränzer <[email protected]> +Date: Fri, 18 Mar 2022 17:28:47 +0100 +Subject: [PATCH] Disable gcc >= 12 dangling-pointer warning + +gcc 12 warns about a pointer into outStream being preserved after outStream +goes out of scope. Since edk2 is built with -Werror, this breaks the build. + +This exact use happens to work with all compilers currently used, +so ignore the warning for the time being to keep things buildable. + +Upstream-Status: Inappropriate [Workaround to keep things going, should be fixed properly] +Signed-off-by: Bernhard Rosenkränzer <[email protected]> + +diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c +index 4e9b499f8d..5f0e75eeda 100644 +--- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c ++++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c +@@ -2825,7 +2825,10 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit, + + nowPos64 = p->nowPos64; + RangeEnc_Init(&p->rc); ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wdangling-pointer" + p->rc.outStream = &outStream.vt; ++#pragma GCC diagnostic pop + + if (desiredPackSize == 0) + return SZ_ERROR_OUTPUT_EOF;
meta/recipes-core/ovmf/ovmf_git.bb +3 -0
@@ -21,6 +21,9 @@ SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https \ file://0003-ovmf-Update-to-latest.patch \ file://0005-debug-prefix-map.patch \ file://0006-reproducible.patch \ + file://edk2-fix-confusion-between-file-handle-and-name.patch \ + file://edk2-workaround-for-gcc-12-build-failure.patch \ + file://edk2-workaround-for-gcc-12-build-failure-2.patch " PV = "edk2-stable202202"
Signature · 1 line
2.35.1
Just disable Werror with appropriate comments describing why we are Doing it until the issues are fixed
Quoted 208 lines · Bernhard Rosenkränzer via lists.openembedded.org
From: Bernhard Rosenkränzer <[email protected]>
edk2 doesn't compile with gcc 12 - due to 2 legitimate bugs (trying to use a file handle as if it were a string) and 2 new warnings in code using -Werror (they need further investigation to determine if they're legitimate bugs or false positives; in the mean time we can keep things building by disabling the warnings for the particular lines triggering them).
The proper fixes have already been submitted upstream at
https://github.com/tianocore/edk2/pull/2602
Will not submit the workarounds for the warnings upstream for now.Signed-off-by: Bernhard Rosenkränzer <
[email protected]>--- ...nfusion-between-file-handle-and-name.patch | 44 +++++++++++++++++++ ...orkaround-for-gcc-12-build-failure-2.patch | 33 ++++++++++++++ ...-workaround-for-gcc-12-build-failure.patch | 28 ++++++++++++ meta/recipes-core/ovmf/ovmf_git.bb | 3 ++ 4 files changed, 108 insertions(+) create mode 100644 meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch create mode 100644 meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patch create mode 100644
meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patchdiff --git
a/meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patchb/meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patchnew file mode 100644
index 0000000000..98023f93c2
---/dev/null
+++b/meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patchmeta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch new file +19
-0@@ -0,0 +1,44 @@ +From 74e7ad4e400ea3f942805e70df4d3ed6990759f3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <[email protected]> +Date: Tue, 8 Mar 2022 18:56:23 +0100 +Subject: [PATCH] GenFfs: Don't treat a file handle as a string +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The current code tries to print the file handle as a string on error. +Do what it is meant to do instead: Print the file name. + +Upstream-Status: Submitted [https://github.com/tianocore/edk2/pull/2602] +Signed-off-by: Bernhard Rosenkränzer <[email protected]> +--- + BaseTools/Source/C/GenFfs/GenFfs.c | 2 +- + BaseTools/Source/C/GenSec/GenSec.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c
b/BaseTools/Source/C/GenFfs/GenFfs.cmeta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch new file +8
-0+index 949025c33325..06e009e279ce 100644 +--- a/BaseTools/Source/C/GenFfs/GenFfs.c ++++ b/BaseTools/Source/C/GenFfs/GenFfs.c +@@ -542,7 +542,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment) + PeFileBuffer = (UINT8 *) malloc (PeFileSize); + if (PeFileBuffer == NULL) { + fclose (InFileHandle); +- Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of%s", InFileHandle);
++ Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of
%s", InFile);meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch new file +4
-0+ return EFI_OUT_OF_RESOURCES; + } + fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle); +diff --git a/BaseTools/Source/C/GenSec/GenSec.c
b/BaseTools/Source/C/GenSec/GenSec.c
+indexd54a4f9e0a7d..1ad92de1d50e100644
+---a/BaseTools/Source/C/GenSec/GenSec.c
++++b/BaseTools/Source/C/GenSec/GenSec.c
+@@ -1062,7 +1062,7 @@GetAlignmentFromFile(char *InFile, UINT32 *Alignment)meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch new file +4
-0+ PeFileBuffer = (UINT8 *) malloc (PeFileSize); + if (PeFileBuffer == NULL) { + fclose (InFileHandle); +- Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of%s", InFileHandle);
++ Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of
%s", InFile);meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch new file +3
-0+ return EFI_OUT_OF_RESOURCES; + } + fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);diff --git
a/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patchb/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patchnew file mode 100644
index 0000000000..e7b7269d82
---/dev/null
+++b/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patchmeta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patch new file +16
-0@@ -0,0 +1,33 @@ +From: Bernhard Rosenkränzer <[email protected]> +Date: Fri, 18 Mar 2022 17:28:47 +0100 +Subject: [PATCH] Disable gcc >= 12 stringop-overflow warning + +gcc 12 warns about a stringop-overflow with SetDevicePathEndNode +potentially copying 4 bytes to an area of 1 byte. +Since edk2 is built with -Werror, this breaks the build. + +It is not immedaitely clear whether this is a false warning or if +SetDevicePathEndNode is being used incorrectly somewhere, but since +the code seems to work, ignore the warning for the time being to +keep things buildable. + +This should be investigated properly at some point. + +Upstream-Status: Inappropriate [Workaround to keep things going, shouldbe fixed properly]
+Signed-off-by: Bernhard Rosenkränzer <
[email protected]>(quoted diff) +2
-0+ +diff --git a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c
b/BaseTools/Source/C/DevicePath/DevicePathUtilities.cmeta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patch new file +10
-0+index 2ffefa8cee..32c02bdf82 100644 +--- a/BaseTools/Source/C/DevicePath/DevicePathUtilities.c ++++ b/BaseTools/Source/C/DevicePath/DevicePathUtilities.c +@@ -318,7 +318,10 @@ SetDevicePathEndNode ( + ) + { + ASSERT (Node != NULL); ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wstringop-overflow" + memcpy (Node, &mUefiDevicePathLibEndDevicePath, sizeof(mUefiDevicePathLibEndDevicePath));
++#pragma GCC diagnostic pop
+ }
+
+ /**
diff --gita/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patchb/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patchnew file mode 100644
index 0000000000..048112e3fc
---/dev/null
+++b/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patchmeta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patch new file +5
-0@@ -0,0 +1,28 @@ +From: Bernhard Rosenkränzer <[email protected]> +Date: Fri, 18 Mar 2022 17:28:47 +0100 +Subject: [PATCH] Disable gcc >= 12 dangling-pointer warning + +gcc 12 warns about a pointer into outStream being preserved afteroutStream
+goes out of scope. Since edk2 is built with -Werror, this breaks the build.meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patch new file +5
-0+ +This exact use happens to work with all compilers currently used, +so ignore the warning for the time being to keep things buildable. + +Upstream-Status: Inappropriate [Workaround to keep things going, shouldbe fixed properly]
+Signed-off-by: Bernhard Rosenkränzer <
[email protected]>(quoted diff) +2
-0+ +diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+index4e9b499f8d..5f0e75eeda100644
+---a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
++++b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+@@ -2825,7 +2825,10 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit,meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patch new file +10
-0+ + nowPos64 = p->nowPos64; + RangeEnc_Init(&p->rc); ++#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Wdangling-pointer" + p->rc.outStream = &outStream.vt; ++#pragma GCC diagnostic pop + + if (desiredPackSize == 0) + return SZ_ERROR_OUTPUT_EOF;meta/recipes-core/ovmf/ renamed from meta/recipes-core/ovmf/ovmf_git.bb +0
-0ovmf_git.bb
indexb15d40eac8..5f255b46b2100644meta/recipes-core/ovmf/ovmf_git.bb +3
-0@@ -21,6 +21,9 @@ SRC_URI = "gitsm:// github.com/tianocore/edk2.git;branch=master;protocol=https \ file://0003-ovmf-Update-to-latest.patch \ file://0005-debug-prefix-map.patch \ file://0006-reproducible.patch \ + file://edk2-fix-confusion-between-file-handle-and-name.patch \ + file://edk2-workaround-for-gcc-12-build-failure.patch \ + file://edk2-workaround-for-gcc-12-build-failure-2.patch "PV = "edk2-stable202202"
--
2.35.1-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#163472):
https://lists.openembedded.org/g/openembedded-core/message/163472
Mute This Topic: https://lists.openembedded.org/mt/89892121/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-