* [PATCH] recipes-core/ovmf: Fix build with gcc 12
@ 2022-03-19 16:55 Bernhard Rosenkränzer
2022-03-19 19:04 ` [OE-core] " Khem Raj
0 siblings, 1 reply; 2+ messages in thread
From: Bernhard Rosenkränzer @ 2022-03-19 16:55 UTC (permalink / raw)
To: openembedded-core; +Cc: Bernhard Rosenkränzer
From: Bernhard Rosenkränzer <bernhard.rosenkraenzer.ext@huawei.com>
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 <bernhard.rosenkraenzer.ext@huawei.com>
---
...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
diff --git a/meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch b/meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch
new file mode 100644
index 0000000000..98023f93c2
--- /dev/null
+++ b/meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch
@@ -0,0 +1,44 @@
+From 74e7ad4e400ea3f942805e70df4d3ed6990759f3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
+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 <bero@lindev.ch>
+---
+ 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);
diff --git a/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patch b/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patch
new file mode 100644
index 0000000000..e7b7269d82
--- /dev/null
+++ b/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patch
@@ -0,0 +1,33 @@
+From: Bernhard Rosenkränzer <bernhard.rosenkraenzer.ext@huawei.com>
+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 <bernhard.rosenkraenzer.ext@huawei.com>
+
+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
+ }
+
+ /**
diff --git a/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patch b/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patch
new file mode 100644
index 0000000000..048112e3fc
--- /dev/null
+++ b/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patch
@@ -0,0 +1,28 @@
+From: Bernhard Rosenkränzer <bernhard.rosenkraenzer.ext@huawei.com>
+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 <bernhard.rosenkraenzer.ext@huawei.com>
+
+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;
diff --git a/meta/recipes-core/ovmf/ovmf_git.bb b/meta/recipes-core/ovmf/ovmf_git.bb
index b15d40eac8..5f255b46b2 100644
--- a/meta/recipes-core/ovmf/ovmf_git.bb
+++ b/meta/recipes-core/ovmf/ovmf_git.bb
@@ -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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [OE-core] [PATCH] recipes-core/ovmf: Fix build with gcc 12
2022-03-19 16:55 [PATCH] recipes-core/ovmf: Fix build with gcc 12 Bernhard Rosenkränzer
@ 2022-03-19 19:04 ` Khem Raj
0 siblings, 0 replies; 2+ messages in thread
From: Khem Raj @ 2022-03-19 19:04 UTC (permalink / raw)
To: bero; +Cc: Bernhard Rosenkränzer, openembedded-core
[-- Attachment #1: Type: text/plain, Size: 9020 bytes --]
Just disable Werror with appropriate comments describing why we are
Doing it until the issues are fixed
On Sat, Mar 19, 2022 at 9:55 AM Bernhard Rosenkränzer via
lists.openembedded.org <bero=lindev.ch@lists.openembedded.org> wrote:
> From: Bernhard Rosenkränzer <bernhard.rosenkraenzer.ext@huawei.com>
>
> 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 <
> bernhard.rosenkraenzer.ext@huawei.com>
> ---
> ...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
>
> diff --git
> a/meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch
> b/meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch
> new file mode 100644
> index 0000000000..98023f93c2
> --- /dev/null
> +++
> b/meta/recipes-core/ovmf/ovmf/edk2-fix-confusion-between-file-handle-and-name.patch
> @@ -0,0 +1,44 @@
> +From 74e7ad4e400ea3f942805e70df4d3ed6990759f3 Mon Sep 17 00:00:00 2001
> +From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?= <bero@lindev.ch>
> +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 <bero@lindev.ch>
> +---
> + 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);
> diff --git
> a/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patch
> b/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patch
> new file mode 100644
> index 0000000000..e7b7269d82
> --- /dev/null
> +++
> b/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure-2.patch
> @@ -0,0 +1,33 @@
> +From: Bernhard Rosenkränzer <bernhard.rosenkraenzer.ext@huawei.com>
> +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 <
> bernhard.rosenkraenzer.ext@huawei.com>
> +
> +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
> + }
> +
> + /**
> diff --git
> a/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patch
> b/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patch
> new file mode 100644
> index 0000000000..048112e3fc
> --- /dev/null
> +++
> b/meta/recipes-core/ovmf/ovmf/edk2-workaround-for-gcc-12-build-failure.patch
> @@ -0,0 +1,28 @@
> +From: Bernhard Rosenkränzer <bernhard.rosenkraenzer.ext@huawei.com>
> +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 <
> bernhard.rosenkraenzer.ext@huawei.com>
> +
> +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;
> diff --git a/meta/recipes-core/ovmf/ovmf_git.bb b/meta/recipes-core/ovmf/
> ovmf_git.bb
> index b15d40eac8..5f255b46b2 100644
> --- a/meta/recipes-core/ovmf/ovmf_git.bb
> +++ b/meta/recipes-core/ovmf/ovmf_git.bb
> @@ -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: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
[-- Attachment #2: Type: text/html, Size: 11571 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-19 19:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-19 16:55 [PATCH] recipes-core/ovmf: Fix build with gcc 12 Bernhard Rosenkränzer
2022-03-19 19:04 ` [OE-core] " Khem Raj
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.