Skip to contentSkip to conversation

ovmf: Fix native build with gcc-12

PATCH In review Khem Raj 2 participants 5 messages May 13, 2022 – May 15, 2022 1 message not in the archive

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 ovmf: Fix native build with gcc-12

Host distros have started deploying gcc12 as well e.g. archlinux this build failure shows up which has been fixed upstream

In function ‘GetAlignmentFromFile’,
inlined from ‘main’ at GenFfs.c:816:20:
GenFfs.c:545:5: error: pointer ‘InFileHandle’ used after ‘fclose’ [-Werror=use-after-free]

  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 .../0001-BaseTools-fix-gcc12-warning-1.patch  | 51 +++++++++++++++++++
 .../0001-BaseTools-fix-gcc12-warning.patch    | 49 ++++++++++++++++++
 meta/recipes-core/ovmf/ovmf_git.bb            |  6 +++
 3 files changed, 106 insertions(+)
 create mode 100644 meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch
 create mode 100644 meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch new file +51 -0
new file mode 100644
index 00000000000..23366b4d078
@@ -0,0 +1,51 @@
+From b0a0b7b605aeb8106e7b50d1efeb746f401498cc Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <[email protected]>
+Date: Thu, 24 Mar 2022 20:04:35 +0800
+Subject: [PATCH] BaseTools: fix gcc12 warning
+
+Sdk/C/LzmaEnc.c: In function ?LzmaEnc_CodeOneMemBlock?:
+Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*p.rc.outStream? [-Werror=dangling-pointer=]
+ 2828 |   p->rc.outStream = &outStream.vt;
+      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
+ 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
+      |                            ^~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
+Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*(CLzmaEnc *)pp.rc.outStream? [-Werror=dangling-pointer=]
+ 2828 |   p->rc.outStream = &outStream.vt;
+      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
+ 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
+      |                            ^~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
+cc1: all warnings being treated as errors
+
+Upstream-Status: Backport [https://github.com/tianocore/edk2/commit/85021f8cf22d1bd4114803c6c610dea5ef0059f1]
+Signed-off-by: Gerd Hoffmann <[email protected]>
+Reviewed-by: Bob Feng <[email protected]>
+---
+ BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+index 4e9b499f8d..4b9f5fa692 100644
+--- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
++++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+@@ -2825,12 +2825,13 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit,
+ 
+   nowPos64 = p->nowPos64;
+   RangeEnc_Init(&p->rc);
+-  p->rc.outStream = &outStream.vt;
+ 
+   if (desiredPackSize == 0)
+     return SZ_ERROR_OUTPUT_EOF;
+ 
++  p->rc.outStream = &outStream.vt;
+   res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize);
++  p->rc.outStream = NULL;
+ 
+   *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
+   *destLen -= outStream.rem;
+-- 
+2.36.1
+
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch new file +49 -0

49 lines not on this page · raw message

meta/recipes-core/ovmf/ovmf_git.bb +6 -0
index b15d40eac83..84e3360a3af 100644
@@ -15,12 +15,18 @@ PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d)
 PACKAGECONFIG[secureboot] = ",,,"
 PACKAGECONFIG[tpm] = "-D TPM_ENABLE=TRUE,-D TPM_ENABLE=FALSE,,"
 
+# GCC12 trips on it
+#see https://src.fedoraproject.org/rpms/edk2/blob/rawhide/f/0032-Basetools-turn-off-gcc12-warning.patch
+BUILD_CFLAGS += "-Wno-error=stringop-overflow"
+
 SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https \
            file://0001-ovmf-update-path-to-native-BaseTools.patch \
            file://0002-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \
            file://0003-ovmf-Update-to-latest.patch \
            file://0005-debug-prefix-map.patch \
            file://0006-reproducible.patch \
+           file://0001-BaseTools-fix-gcc12-warning.patch \
+           file://0001-BaseTools-fix-gcc12-warning-1.patch \
            "
 
 PV = "edk2-stable202202"
Signature · 1 line
2.36.1
#1 lore raw
Quoted 143 lines · Khem Raj

Host distros have started deploying gcc12 as well e.g. archlinux this build failure shows up which has been fixed upstream

In function ‘GetAlignmentFromFile’,
inlined from ‘main’ at GenFfs.c:816:20:
GenFfs.c:545:5: error: pointer ‘InFileHandle’ used after ‘fclose’ [-Werror=use-after-free]

  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 .../0001-BaseTools-fix-gcc12-warning-1.patch  | 51 +++++++++++++++++++
 .../0001-BaseTools-fix-gcc12-warning.patch    | 49 ++++++++++++++++++
 meta/recipes-core/ovmf/ovmf_git.bb            |  6 +++
 3 files changed, 106 insertions(+)
 create mode 100644 meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch
 create mode 100644 meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch new file +51 -0
new file mode 100644
index 00000000000..23366b4d078
@@ -0,0 +1,51 @@
+From b0a0b7b605aeb8106e7b50d1efeb746f401498cc Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <[email protected]>
+Date: Thu, 24 Mar 2022 20:04:35 +0800
+Subject: [PATCH] BaseTools: fix gcc12 warning
+
+Sdk/C/LzmaEnc.c: In function ?LzmaEnc_CodeOneMemBlock?:
+Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*p.rc.outStream? [-Werror=dangling-pointer=]
+ 2828 |   p->rc.outStream = &outStream.vt;
+      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
+ 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
+      |                            ^~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
+Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*(CLzmaEnc *)pp.rc.outStream? [-Werror=dangling-pointer=]
+ 2828 |   p->rc.outStream = &outStream.vt;
+      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
+ 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
+      |                            ^~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
+cc1: all warnings being treated as errors
+
+Upstream-Status: Backport [https://github.com/tianocore/edk2/commit/85021f8cf22d1bd4114803c6c610dea5ef0059f1]
+Signed-off-by: Gerd Hoffmann <[email protected]>
+Reviewed-by: Bob Feng <[email protected]>
+---
+ BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+index 4e9b499f8d..4b9f5fa692 100644
+--- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
++++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+@@ -2825,12 +2825,13 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit,
+ 
+   nowPos64 = p->nowPos64;
+   RangeEnc_Init(&p->rc);
+-  p->rc.outStream = &outStream.vt;
+ 
+   if (desiredPackSize == 0)
+     return SZ_ERROR_OUTPUT_EOF;
+ 
++  p->rc.outStream = &outStream.vt;
+   res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize);
++  p->rc.outStream = NULL;
+ 
+   *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
+   *destLen -= outStream.rem;
+-- 
+2.36.1
+
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch new file +49 -0
new file mode 100644
index 00000000000..91c01647db2
@@ -0,0 +1,49 @@
+From 2435c17e56652479315853cec5b91fb0ea0911a3 Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <[email protected]>
+Date: Thu, 24 Mar 2022 20:04:34 +0800
+Subject: [PATCH] BaseTools: fix gcc12 warning
+
+GenFfs.c:545:5: error: pointer ?InFileHandle? used after ?fclose? [-Werror=use-after-free]
+  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
+      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+GenFfs.c:544:5: note: call to ?fclose? here
+  544 |     fclose (InFileHandle);
+      |     ^~~~~~~~~~~~~~~~~~~~~
+
+Upstream-Status: Backport [https://github.com/tianocore/edk2/commit/7b005f344e533cd913c3ca05b266f9872df886d1]
+Signed-off-by: Gerd Hoffmann <[email protected]>
+Reviewed-by: Bob Feng <[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 949025c333..d78d62ab36 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 for %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 d54a4f9e0a..b1d05367ec 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 for %s", InFile);
+     return EFI_OUT_OF_RESOURCES;
+   }
+   fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);
+-- 
+2.36.1
+
meta/recipes-core/ovmf/ovmf_git.bb +4 -0
index b15d40eac83..84e3360a3af 100644
@@ -15,12 +15,18 @@ PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d)
 PACKAGECONFIG[secureboot] = ",,,"
 PACKAGECONFIG[tpm] = "-D TPM_ENABLE=TRUE,-D TPM_ENABLE=FALSE,,"
 
+# GCC12 trips on it
+#see https://src.fedoraproject.org/rpms/edk2/blob/rawhide/f/0032-Basetools-turn-off-gcc12-warning.patch
+BUILD_CFLAGS += "-Wno-error=stringop-overflow"
+
 SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https \

meta/recipes-core/ovmf/ovmf_git.bb PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d) · line 32

Quoted 10 lines
meta/recipes-core/ovmf/ovmf_git.bb +2 -0
            file://0001-ovmf-update-path-to-native-BaseTools.patch \
            file://0002-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \
            file://0003-ovmf-Update-to-latest.patch \
            file://0005-debug-prefix-map.patch \
            file://0006-reproducible.patch \
+           file://0001-BaseTools-fix-gcc12-warning.patch \
+           file://0001-BaseTools-fix-gcc12-warning-1.patch \
            "
 
 PV = "edk2-stable202202"

I think this may cause the efi failures in:

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/3583/steps/14/logs/stdio

(and all the other similar oe-selftest runs)

Cheers,

Richard

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 153 lines · Richard Purdie via lists.openembedded.org
Quoted 152 lines · Khem Raj

Host distros have started deploying gcc12 as well e.g. archlinux this build failure shows up which has been fixed upstream

In function ‘GetAlignmentFromFile’,
inlined from ‘main’ at GenFfs.c:816:20:
GenFfs.c:545:5: error: pointer ‘InFileHandle’ used after ‘fclose’ [-Werror=use-after-free]

  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
---
 .../0001-BaseTools-fix-gcc12-warning-1.patch  | 51 +++++++++++++++++++
 .../0001-BaseTools-fix-gcc12-warning.patch    | 49 ++++++++++++++++++
 meta/recipes-core/ovmf/ovmf_git.bb            |  6 +++
 3 files changed, 106 insertions(+)
 create mode 100644 meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch
 create mode 100644 meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch new file +51 -0
new file mode 100644
index 00000000000..23366b4d078
@@ -0,0 +1,51 @@
+From b0a0b7b605aeb8106e7b50d1efeb746f401498cc Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <[email protected]>
+Date: Thu, 24 Mar 2022 20:04:35 +0800
+Subject: [PATCH] BaseTools: fix gcc12 warning
+
+Sdk/C/LzmaEnc.c: In function ?LzmaEnc_CodeOneMemBlock?:
+Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*p.rc.outStream? [-Werror=dangling-pointer=]
+ 2828 |   p->rc.outStream = &outStream.vt;
+      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
+ 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
+      |                            ^~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
+Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*(CLzmaEnc *)pp.rc.outStream? [-Werror=dangling-pointer=]
+ 2828 |   p->rc.outStream = &outStream.vt;
+      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
+ 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
+      |                            ^~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
+cc1: all warnings being treated as errors
+
+Upstream-Status: Backport [https://github.com/tianocore/edk2/commit/85021f8cf22d1bd4114803c6c610dea5ef0059f1]
+Signed-off-by: Gerd Hoffmann <[email protected]>
+Reviewed-by: Bob Feng <[email protected]>
+---
+ BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+index 4e9b499f8d..4b9f5fa692 100644
+--- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
++++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+@@ -2825,12 +2825,13 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit,
+ 
+   nowPos64 = p->nowPos64;
+   RangeEnc_Init(&p->rc);
+-  p->rc.outStream = &outStream.vt;
+ 
+   if (desiredPackSize == 0)
+     return SZ_ERROR_OUTPUT_EOF;
+ 
++  p->rc.outStream = &outStream.vt;
+   res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize);
++  p->rc.outStream = NULL;
+ 
+   *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
+   *destLen -= outStream.rem;
+-- 
+2.36.1
+
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch new file +49 -0
new file mode 100644
index 00000000000..91c01647db2
@@ -0,0 +1,49 @@
+From 2435c17e56652479315853cec5b91fb0ea0911a3 Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <[email protected]>
+Date: Thu, 24 Mar 2022 20:04:34 +0800
+Subject: [PATCH] BaseTools: fix gcc12 warning
+
+GenFfs.c:545:5: error: pointer ?InFileHandle? used after ?fclose? [-Werror=use-after-free]
+  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
+      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+GenFfs.c:544:5: note: call to ?fclose? here
+  544 |     fclose (InFileHandle);
+      |     ^~~~~~~~~~~~~~~~~~~~~
+
+Upstream-Status: Backport [https://github.com/tianocore/edk2/commit/7b005f344e533cd913c3ca05b266f9872df886d1]
+Signed-off-by: Gerd Hoffmann <[email protected]>
+Reviewed-by: Bob Feng <[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 949025c333..d78d62ab36 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 for %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 d54a4f9e0a..b1d05367ec 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 for %s", InFile);
+     return EFI_OUT_OF_RESOURCES;
+   }
+   fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);
+-- 
+2.36.1
+
meta/recipes-core/ovmf/ovmf_git.bb +6 -0
index b15d40eac83..84e3360a3af 100644
@@ -15,12 +15,18 @@ PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d)
 PACKAGECONFIG[secureboot] = ",,,"
 PACKAGECONFIG[tpm] = "-D TPM_ENABLE=TRUE,-D TPM_ENABLE=FALSE,,"
 
+# GCC12 trips on it
+#see https://src.fedoraproject.org/rpms/edk2/blob/rawhide/f/0032-Basetools-turn-off-gcc12-warning.patch
+BUILD_CFLAGS += "-Wno-error=stringop-overflow"
+
 SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=https \
            file://0001-ovmf-update-path-to-native-BaseTools.patch \
            file://0002-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \
            file://0003-ovmf-Update-to-latest.patch \
            file://0005-debug-prefix-map.patch \
            file://0006-reproducible.patch \
+           file://0001-BaseTools-fix-gcc12-warning.patch \
+           file://0001-BaseTools-fix-gcc12-warning-1.patch \
            "
 
Quoted 7 lines

meta/recipes-core/ovmf/ovmf_git.bb PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d) · line 32

Quoted 1 line
meta/recipes-core/ovmf/ovmf_git.bb +0 -0
 PV = "edk2-stable202202"

I think this may cause the efi failures in:

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/3583/steps/14/logs/stdio

(and all the other similar oe-selftest runs)

I'm going to retract that, further testing shows it is something else, still not sure what.

Cheers,

Richard

author
#4 lore raw
Quoted 195 lines · On Sat, May 14, 2022 at 2:31 PM <[email protected]> wrote:
Quoted 7 lines · Richard Purdie via lists.openembedded.org
Quoted 6 lines · Khem Raj

Host distros have started deploying gcc12 as well e.g. archlinux this build failure shows up which has been fixed upstream

In function ‘GetAlignmentFromFile’,
inlined from ‘main’ at GenFfs.c:816:20:
GenFfs.c:545:5: error: pointer ‘InFileHandle’ used after ‘fclose’

[-Werror=use-after-free]

Quoted 1 line
Quoted 1 line

545 | Error(NULL, 0, 4001, "Resource", "memory cannot be

allocated of %s", InFileHandle);

Quoted 1 line
Quoted 1 line
      |

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 8 lines
Quoted 8 lines
---
 .../0001-BaseTools-fix-gcc12-warning-1.patch  | 51 +++++++++++++++++++
 .../0001-BaseTools-fix-gcc12-warning.patch    | 49 ++++++++++++++++++
 meta/recipes-core/ovmf/ovmf_git.bb            |  6 +++
 3 files changed, 106 insertions(+)
 create mode 100644

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch

Quoted 1 line
Quoted 1 line
 create mode 100644

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch

Quoted 2 lines
Quoted 2 lines

diff --git

a/meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch b/meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch

Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 00000000000..23366b4d078
--- /dev/null
+++

b/meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch

Quoted 8 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch line 7

Quoted 8 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch new file +7 -0
@@ -0,0 +1,51 @@
+From b0a0b7b605aeb8106e7b50d1efeb746f401498cc Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <[email protected]>
+Date: Thu, 24 Mar 2022 20:04:35 +0800
+Subject: [PATCH] BaseTools: fix gcc12 warning
+
+Sdk/C/LzmaEnc.c: In function ?LzmaEnc_CodeOneMemBlock?:
+Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable

?outStream? in ?*p.rc.outStream? [-Werror=dangling-pointer=]

Quoted 7 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch

Quoted 7 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch new file +7 -0
+ 2828 |   p->rc.outStream = &outStream.vt;
+      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
+ 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
+      |                            ^~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
+Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable

?outStream? in ?*(CLzmaEnc *)pp.rc.outStream? [-Werror=dangling-pointer=]

Quoted 9 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch

Quoted 9 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch new file +9 -0
+ 2828 |   p->rc.outStream = &outStream.vt;
+      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
+ 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
+      |                            ^~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
+cc1: all warnings being treated as errors
+
+Upstream-Status: Backport [

https://github.com/tianocore/edk2/commit/85021f8cf22d1bd4114803c6c610dea5ef0059f1
]

Quoted 7 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch

Quoted 7 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch new file +7 -0
+Signed-off-by: Gerd Hoffmann <[email protected]>
+Reviewed-by: Bob Feng <[email protected]>
+---
+ BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c

b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c

Quoted 4 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch

Quoted 4 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch new file +4 -0
+index 4e9b499f8d..4b9f5fa692 100644
+--- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
++++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c
+@@ -2825,12 +2825,13 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle

pp, BoolInt reInit,

Quoted 10 lines
Quoted 10 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch new file +10 -0
+
+   nowPos64 = p->nowPos64;
+   RangeEnc_Init(&p->rc);
+-  p->rc.outStream = &outStream.vt;
+
+   if (desiredPackSize == 0)
+     return SZ_ERROR_OUTPUT_EOF;
+
++  p->rc.outStream = &outStream.vt;
+   res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize);
Quoted 8 lines
Quoted 8 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning-1.patch new file +7 -0
++  p->rc.outStream = NULL;
+
+   *unpackSize = (UInt32)(p->nowPos64 - nowPos64);
+   *destLen -= outStream.rem;
+--
+2.36.1
+

diff --git

a/meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch b/meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch

Quoted 4 lines
Quoted 4 lines

new file mode 100644
index 00000000000..91c01647db2
--- /dev/null
+++

b/meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch

Quoted 7 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch line 6

Quoted 7 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch new file +6 -0
@@ -0,0 +1,49 @@
+From 2435c17e56652479315853cec5b91fb0ea0911a3 Mon Sep 17 00:00:00 2001
+From: Gerd Hoffmann <[email protected]>
+Date: Thu, 24 Mar 2022 20:04:34 +0800
+Subject: [PATCH] BaseTools: fix gcc12 warning
+
+GenFfs.c:545:5: error: pointer ?InFileHandle? used after ?fclose?

[-Werror=use-after-free]

Quoted 1 line

Review line 7

Quoted 1 line
(quoted diff) +1 -0
+  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be

allocated of %s", InFileHandle);

Quoted 1 line

Review line 8

Quoted 1 line
(quoted diff) +1 -0
+      |

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 5 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch

Quoted 5 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch new file +5 -0
+GenFfs.c:544:5: note: call to ?fclose? here
+  544 |     fclose (InFileHandle);
+      |     ^~~~~~~~~~~~~~~~~~~~~
+
+Upstream-Status: Backport [

https://github.com/tianocore/edk2/commit/7b005f344e533cd913c3ca05b266f9872df886d1
]

Quoted 8 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch

Quoted 8 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch new file +8 -0
+Signed-off-by: Gerd Hoffmann <[email protected]>
+Reviewed-by: Bob Feng <[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

Quoted 4 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch

Quoted 4 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch new file +4 -0
+index 949025c333..d78d62ab36 100644
+--- a/BaseTools/Source/C/GenFfs/GenFfs.c
++++ b/BaseTools/Source/C/GenFfs/GenFfs.c
+@@ -542,7 +542,7 @@ GetAlignmentFromFile(char *InFile, UINT32

*Alignment)

Quoted 4 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch

Quoted 4 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.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);

Quoted 1 line

Review line 30

Quoted 1 line
(quoted diff) +1 -0
++    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for

%s", InFile);

Quoted 4 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch

Quoted 4 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.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

Quoted 4 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch

Quoted 4 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch new file +4 -0
+index d54a4f9e0a..b1d05367ec 100644
+--- a/BaseTools/Source/C/GenSec/GenSec.c
++++ b/BaseTools/Source/C/GenSec/GenSec.c
+@@ -1062,7 +1062,7 @@ GetAlignmentFromFile(char *InFile, UINT32

*Alignment)

Quoted 4 lines

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch

Quoted 4 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.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);

Quoted 1 line

Review line 43

Quoted 1 line
(quoted diff) +1 -0
++    Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for

%s", InFile);

Quoted 7 lines

Review

Quoted 7 lines
meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12-warning.patch new file +6 -0
+     return EFI_OUT_OF_RESOURCES;
+   }
+   fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);
+--
+2.36.1
+
(quoted diff) +0 -0

b/meta/recipes-core/ovmf/ovmf_git.bb

Quoted 4 lines

meta/recipes-core/ovmf/ovmf_git.bb PACKAGECONFIG +=

Quoted 4 lines

index b15d40eac83..84e3360a3af 100644

meta/recipes-core/ovmf/ovmf_git.bb +0 -0
@@ -15,12 +15,18 @@ PACKAGECONFIG +=

"${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d)

Quoted 5 lines

meta/recipes-core/ovmf/ovmf_git.bb PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d)

Quoted 5 lines
meta/recipes-core/ovmf/ovmf_git.bb +2 -0
 PACKAGECONFIG[secureboot] = ",,,"
 PACKAGECONFIG[tpm] = "-D TPM_ENABLE=TRUE,-D TPM_ENABLE=FALSE,,"
 
+# GCC12 trips on it
+#see

https://src.fedoraproject.org/rpms/edk2/blob/rawhide/f/0032-Basetools-turn-off-gcc12-warning.patch

Quoted 3 lines

meta/recipes-core/ovmf/ovmf_git.bb PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d)

Quoted 3 lines
meta/recipes-core/ovmf/ovmf_git.bb +2 -0
+BUILD_CFLAGS += "-Wno-error=stringop-overflow"
+
 SRC_URI = "gitsm://

github.com/tianocore/edk2.git;branch=master;protocol=https \

Quoted 2 lines

meta/recipes-core/ovmf/ovmf_git.bb PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d) · line 31

Quoted 2 lines
meta/recipes-core/ovmf/ovmf_git.bb +0 -0
            file://0001-ovmf-update-path-to-native-BaseTools.patch \
 

file://0002-BaseTools-makefile-adjust-to-build-in-under-bitbake.patch \

Quoted 7 lines
Quoted 7 lines
meta/recipes-core/ovmf/ovmf_git.bb +2 -0
            file://0003-ovmf-Update-to-latest.patch \
            file://0005-debug-prefix-map.patch \
            file://0006-reproducible.patch \
+           file://0001-BaseTools-fix-gcc12-warning.patch \
+           file://0001-BaseTools-fix-gcc12-warning-1.patch \
            "
 
Quoted 5 lines

meta/recipes-core/ovmf/ovmf_git.bb PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d) · line 32

Quoted 1 line
meta/recipes-core/ovmf/ovmf_git.bb +0 -0
 PV = "edk2-stable202202"

I think this may cause the efi failures in:

Quoted 6 lines

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/3583/steps/14/logs/stdio

Quoted 2 lines

(and all the other similar oe-selftest runs)

I'm going to retract that, further testing shows it is something else, still not sure what.

Right I was a little confused as well and was trying to reproduce locally here with and without this patch and the results were same

Quoted 7 lines

Cheers,

Richard

#5 lore raw
Quoted 218 lines · Khem Raj
Quoted 214 lines · On Sat, May 14, 2022 at 2:31 PM <[email protected]> wrote:
Quoted 211 lines · Richard Purdie via lists.openembedded.org
Quoted 196 lines · Khem Raj

Host distros have started deploying gcc12 as well e.g. archlinux
this build failure shows up which has been fixed upstream

In function ‘GetAlignmentFromFile’,
     inlined from ‘main’ at GenFfs.c:816:20:
GenFfs.c:545:5: error: pointer ‘InFileHandle’ used after ‘fclose’ [-Werror=use-after-free]
   545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~

---
  .../0001-BaseTools-fix-gcc12-warning-1.patch  | 51
+++++++++++++++++++
  .../0001-BaseTools-fix-gcc12-warning.patch    | 49
++++++++++++++++++
  meta/recipes-core/ovmf/ovmf_git.bb            |  6 +++

  3 files changed, 106 insertions(+)

  create mode 100644 meta/recipes-core/ovmf/ovmf/0001- BaseTools-fix-gcc12-warning-1.patch
  create mode 100644 meta/recipes-core/ovmf/ovmf/0001- BaseTools-fix-gcc12-warning.patch

(quoted diff) +0 -0

gcc12-warning-1.patch b/meta/recipes-core/ovmf/ovmf/0001- BaseTools-fix-gcc12-warning-1.patch
new file mode 100644
index 00000000000..23366b4d078

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +0 -0

warning-1.patch

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +1 -0
@@ -0,0 +1,51 @@
+From b0a0b7b605aeb8106e7b50d1efeb746f401498cc Mon Sep 17

00:00:00 2001

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +6 -0
+From: Gerd Hoffmann <[email protected]>
+Date: Thu, 24 Mar 2022 20:04:35 +0800
+Subject: [PATCH] BaseTools: fix gcc12 warning
+
+Sdk/C/LzmaEnc.c: In function ?LzmaEnc_CodeOneMemBlock?:
+Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local

variable ?outStream? in ?*p.rc.outStream? [-Werror=dangling- pointer=]
+ 2828 |   p->rc.outStream = &outStream.vt;
+      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +5 -0
+Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
+ 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
+      |                            ^~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
+Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local

variable ?outStream? in ?*(CLzmaEnc *)pp.rc.outStream? [- Werror=dangling-pointer=]
+ 2828 |   p->rc.outStream = &outStream.vt;
+      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +7 -0
+Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
+ 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
+      |                            ^~~~~~~~~
+Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
+cc1: all warnings being treated as errors
+
+Upstream-Status: Backport

[https://github.com/tianocore/edk2/commit/85021f8cf22d1bd411480
3c6c610dea5ef0059f1]

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +7 -0
+Signed-off-by: Gerd Hoffmann <[email protected]>
+Reviewed-by: Bob Feng <[email protected]>
+---
+ BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c

b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c +index 4e9b499f8d..4b9f5fa692 100644
+--- a/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c ++++ b/BaseTools/Source/C/LzmaCompress/Sdk/C/LzmaEnc.c +@@ -2825,12 +2825,13 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit, +
+   nowPos64 = p->nowPos64;
+   RangeEnc_Init(&p->rc);
+-  p->rc.outStream = &outStream.vt;
+
+   if (desiredPackSize == 0)
+     return SZ_ERROR_OUTPUT_EOF;
+
++  p->rc.outStream = &outStream.vt;
+   res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize);
++  p->rc.outStream = NULL;
+
+   *unpackSize = (UInt32)(p->nowPos64 - nowPos64); +   *destLen -= outStream.rem;
+--
+2.36.1

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +1 -0
+
(quoted diff) +0 -0

gcc12-warning.patch b/meta/recipes-core/ovmf/ovmf/0001- BaseTools-fix-gcc12-warning.patch
new file mode 100644
index 00000000000..91c01647db2

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +0 -0

warning.patch

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +1 -0
@@ -0,0 +1,49 @@
+From 2435c17e56652479315853cec5b91fb0ea0911a3 Mon Sep 17

00:00:00 2001

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +5 -0
+From: Gerd Hoffmann <[email protected]>
+Date: Thu, 24 Mar 2022 20:04:34 +0800
+Subject: [PATCH] BaseTools: fix gcc12 warning
+
+GenFfs.c:545:5: error: pointer ?InFileHandle? used after

?fclose? [-Werror=use-after-free]
+  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
+      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +5 -0
+GenFfs.c:544:5: note: call to ?fclose? here
+  544 |     fclose (InFileHandle);
+      |     ^~~~~~~~~~~~~~~~~~~~~
+
+Upstream-Status: Backport

[https://github.com/tianocore/edk2/commit/7b005f344e533cd913c3c
a05b266f9872df886d1]

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +8 -0
+Signed-off-by: Gerd Hoffmann <[email protected]>
+Reviewed-by: Bob Feng <[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 949025c333..d78d62ab36 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 for %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 d54a4f9e0a..b1d05367ec 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 for %s", InFile);
+     return EFI_OUT_OF_RESOURCES;
+   }
+   fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);
+--
+2.36.1

meta/recipes-core/ovmf/ovmf/0001-BaseTools-fix-gcc12- new file +1 -0
+
meta/recipes- renamed from meta/recipes-core/ovmf/ovmf_git.bb +0 -0

core/ovmf/ovmf_git.bb
index b15d40eac83..84e3360a3af 100644

meta/recipes-core/ovmf/ovmf_git.bb +0 -0
@@ -15,12 +15,18 @@ PACKAGECONFIG +=
 "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d)

  PACKAGECONFIG[secureboot] = ",,,"
  PACKAGECONFIG[tpm] = "-D TPM_ENABLE=TRUE,-D
TPM_ENABLE=FALSE,,"

meta/recipes-core/ovmf/ovmf_git.bb +2 -0
+# GCC12 trips on it
+#see

https://src.fedoraproject.org/rpms/edk2/blob/rawhide/f/0032-Basetools-turn-off-gcc12-warning.patch

meta/recipes-core/ovmf/ovmf_git.bb +2 -0
+BUILD_CFLAGS += "-Wno-error=stringop-overflow"
+

  SRC_URI = "gitsm://github.com/tianocore/edk2.git;branch=master;protocol=h ttps \
file://0001-ovmf-update-path-to-native-BaseTools.patch \
file://0002-BaseTools-makefile-adjust-to-build-in-under-bitbak e.patch \

Quoted 8 lines

             file://0003-ovmf-Update-to-latest.patch \
             file://0005-debug-prefix-map.patch \
             file://0006-reproducible.patch \
+           file://0001-BaseTools-fix-gcc12-warning.patch \
+           file://0001-BaseTools-fix-gcc12-warning-1.patch \
             "

  PV = "edk2-stable202202"

I think this may cause the efi failures in:

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/3583/steps/14/logs/stdio

(and all the other similar oe-selftest runs)

Quoted 8 lines
Quoted 4 lines

I'm going to retract that, further testing shows it is something else,
still not sure what.

Right I was a little confused as well and was trying to reproduce locally here with and without this patch and the results were same

It definitely wasn't this patch, sorry. It can sometimes be really hard to tell which failure is from which patch, it has taken me a few tries to isolate this one!

Cheers,

Richard