<p>
<span style="font-family:MingLiU;">I successfully resolved the build issue by adding the flag -Wno-maybe-uninitialized in the BaseTools/Conf/tools_def.template file.</span><span style="font-family:MingLiU;"> I have also submitted a patch email to the mailing list with the subject: '[edk2-devel] [PATCH] BaseTools/Conf/tools_def.template: Fix uninitialized variable error. </span><span style="font-family:MingLiU;">Here's the link to the successful build log: </span><span style="font-family:MingLiU;">https://build.tarsier-infra.com/package/live_build_log/home:ouuleilei:branches:openEuler:Mainline/edk2/openEuler_Mainline_standard_riscv64_gcc/riscv64.</span>
</p>
<p>
<span style="font-family:MingLiU;"><br>
</span>
</p>
<p>
<br>
</p>
<blockquote name="replyContent" class="ReferenceQuote" style="font-family:MingLiU;padding-left:5px;margin-left:5px;border-left:2px solid #B6B6B6;margin-right:0px;">
-----原始郵件-----<br>
<b>發件人:</b><span id="rc_from">"Andrew (EFI) Fish" <afish@apple.com></span><br>
<b>發送時間:</b><span id="rc_senttime">2023-08-17 19:45:01 (星期四)</span><br>
<b>收件人:</b> devel@edk2.groups.io, wangliu@iscas.ac.cn<br>
<b>抄送:</b> "Kinney, Michael D" <michael.d.kinney@intel.com><br>
<b>主題:</b> Re: [edk2-devel] Can RELEASE target disable -Werror CC_FLAG?<br>
<br>
<div dir="auto">
Can you add -Wno-maybe-uninitialized to compiler flags to work around the error?<br>
<br>
<div dir="ltr"></div>
<div dir="ltr">
<br>
<blockquote type="cite">
On Aug 16, 2023, at 11:31 PM, 汪流 <wangliu@iscas.ac.cn> wrote:<br>
<br>
</blockquote>
</div>
<blockquote type="cite">
<div dir="ltr">
<p>
<span style="font-family:MingLiU;">This is the failed build log: </span><span style="font-family:MingLiU;">https://build.tarsier-infra.com/package/live_build_log/home:ouuleilei:branches:openEuler:Mainline/edk2/openEuler_Mainline_standard_riscv64_gcc/riscv64</span>
</p>
<p>
<span style="font-family:MingLiU;"> arch: riscv64</span>
</p>
<p>
<span style="font-family:MingLiU;"> gcc version: 10.3.1</span>
</p>
<p>
<br>
</p>
<p>
<br>
</p>
<br>
<br>
<blockquote name="replyContent" class="ReferenceQuote" style="font-family:MingLiU;padding-left:5px;margin-left:5px;border-left:2px solid #B6B6B6;margin-right:0px;">
-----原始郵件-----<br>
<b>發件人:</b><span id="rc_from">"Kinney, Michael D" <michael.d.kinney@intel.com></span><br>
<b>發送時間:</b><span id="rc_senttime">2023-08-17 01:50:37 (星期四)</span><br>
<b>收件人:</b> "Andrew (EFI) Fish" <afish@apple.com>, edk2-devel-groups-io <devel@edk2.groups.io><br>
<b>抄送:</b> "wangliu@iscas.ac.cn" <wangliu@iscas.ac.cn>, "Kinney, Michael D" <michael.d.kinney@intel.com><br>
<b>主題:</b> RE: [edk2-devel] Can RELEASE target disable -Werror CC_FLAG?<br>
<br>
<div xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<style></style>
<div lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word;">
<div class="WordSection1">
<p class="MsoNormal">
Hi Andrew,<o:p></o:p>
</p>
<p class="MsoNormal">
<o:p> </o:p>
</p>
<p class="MsoNormal">
There are compiler flags we set to suppress some of these types of specific warnings to avoid disable warnings as errors.
<o:p></o:p>
</p>
<p class="MsoNormal">
<o:p> </o:p>
</p>
<p class="MsoNormal">
For example, this commit to tools_def.template:<o:p></o:p>
</p>
<p class="MsoNormal">
<o:p> </o:p>
</p>
<p class="MsoNormal" style="text-indent:.5in;">
<a href="https://github.com/tianocore/edk2/commit/8e985ac3fdb2b117968ac1fa1f54666e166af8ac">https://github.com/tianocore/edk2/commit/8e985ac3fdb2b117968ac1fa1f54666e166af8ac</a><o:p></o:p>
</p>
<p class="MsoNormal">
<o:p> </o:p>
</p>
<p class="MsoNormal">
I would like to see the compiler, version, arch, log info with the specific warning being flagged to see if we can apply the techniques we have been able to apply in the past.<o:p></o:p>
</p>
<p class="MsoNormal">
<o:p> </o:p>
</p>
<p class="MsoNormal">
Mike<o:p></o:p>
</p>
<p class="MsoNormal">
<o:p> </o:p>
</p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt;">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in;">
<p class="MsoNormal">
<b>From:</b> Andrew (EFI) Fish <afish@apple.com> <br>
<b>Sent:</b> Wednesday, August 16, 2023 10:41 AM<br>
<b>To:</b> edk2-devel-groups-io <devel@edk2.groups.io>; Kinney, Michael D <michael.d.kinney@intel.com><br>
<b>Cc:</b> wangliu@iscas.ac.cn<br>
<b>Subject:</b> Re: [edk2-devel] Can RELEASE target disable -Werror CC_FLAG<span style="font-family:"MS Gothic";">?</span><o:p></o:p>
</p>
</div>
</div>
<p class="MsoNormal">
<o:p> </o:p>
</p>
<p class="MsoNormal">
Mike,<o:p></o:p>
</p>
<div>
<p class="MsoNormal">
<o:p> </o:p>
</p>
</div>
<div>
<p class="MsoNormal">
I seem to remember it was a m<span style="font-size:8.5pt;font-family:Consolas;color:#212529;background:#F8F9FA;">aybe-uninitialized</span> compiler error. The DEBUG build did not hit it due to the NULL check in the ASSERT. The NULL check
only exists if ASSERT() is enabled. So if ASSERT is disabled this code in the DXE Core will dereference a NULL pointer. <o:p></o:p>
</p>
</div>
<div>
<p class="MsoNormal">
<o:p> </o:p>
</p>
</div>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt;">
<div style="border:none;border-left:solid windowtext 1.5pt;padding:0in 0in 0in 4.0pt;border-color:currentcolor currentcolor currentcolor blue;border-image:none;">
<blockquote style="border:none;border-left:solid windowtext 1.5pt;padding:0in 0in 0in 4.0pt;margin-left:3.75pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;">
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> ASSERT (Prot != NULL);</span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> // </span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> // EFI_ALREADY_STARTED is not an error for bus driver.</span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> // Return the corresponding protocol interface.</span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> // </span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> *Interface = Prot->Interface;</span><o:p></o:p>
</p>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal">
<o:p> </o:p>
</p>
</div>
<div>
<p class="MsoNormal">
Thanks,<o:p></o:p>
</p>
</div>
<div>
<p class="MsoNormal">
<o:p> </o:p>
</p>
</div>
<div>
<p class="MsoNormal">
Andrew Fish<o:p></o:p>
</p>
<div>
<p class="MsoNormal">
<br>
<br>
<o:p></o:p>
</p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt;">
<div>
<p class="MsoNormal">
On Aug 16, 2023, at 10:02 AM, Michael D Kinney <<a href="mailto:michael.d.kinney@intel.com">michael.d.kinney@intel.com</a>> wrote:<o:p></o:p>
</p>
</div>
<p class="MsoNormal">
<o:p> </o:p>
</p>
<div>
<div>
<p class="MsoNormal">
Can you provide the specific build error?<o:p></o:p>
</p>
</div>
<div>
<p class="MsoNormal">
<o:p></o:p>
</p>
</div>
<div>
<p class="MsoNormal">
So far, we have not had to relax that flag for any RELEASE builds.<o:p></o:p>
</p>
</div>
<div>
<p class="MsoNormal">
<o:p></o:p>
</p>
</div>
<div>
<p class="MsoNormal">
Thanks,<o:p></o:p>
</p>
</div>
<div>
<p class="MsoNormal">
<o:p></o:p>
</p>
</div>
<div>
<p class="MsoNormal">
Mike<o:p></o:p>
</p>
</div>
<div>
<p class="MsoNormal">
<o:p></o:p>
</p>
</div>
<div style="border:none;border-left:solid windowtext 1.5pt;padding:0in 0in 0in 4.0pt;border-color:currentcolor currentcolor currentcolor blue;border-image:none;">
<div>
<div style="border:none;border-top:solid windowtext 1.0pt;padding:3.0pt 0in 0in 0in;border-color:currentcolor currentcolor;border-image:none;">
<div>
<p class="MsoNormal">
<b>From:</b><span class="apple-converted-space"> </span><a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a><span class="apple-converted-space"> </span><<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>><span class="apple-converted-space"> </span><b>On
Behalf Of<span class="apple-converted-space"> </span></b>??<br>
<b>Sent:</b><span class="apple-converted-space"> </span>Wednesday, August 16, 2023 12:46 AM<br>
<b>To:</b><span class="apple-converted-space"> </span>Andrew (EFI) Fish <<a href="mailto:afish@apple.com">afish@apple.com</a>><br>
<b>Cc:</b><span class="apple-converted-space"> </span>edk2-devel-groups-io <<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>><br>
<b>Subject:</b><span class="apple-converted-space"> </span>Re: [edk2-devel] Can RELEASE target disable -Werror CC_FLAG<span style="font-family:"MS Gothic";">?</span><o:p></o:p>
</p>
</div>
</div>
</div>
<div>
<p class="MsoNormal">
<o:p></o:p>
</p>
</div>
<p>
<span style="font-size:9.0pt;font-family:MingLiU;">Yes, the RELEASE build compiler flags should be relaxed, all error checks that the DEBUG target should do, it doesn't belong to the RELEASE's job.</span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;"><o:p></o:p></span>
</p>
<p>
<span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;"> <o:p></o:p></span>
</p>
<p style="margin-bottom:12.0pt;">
<span style="font-size:9.0pt;font-family:MingLiU;">---<span class="apple-converted-space"> </span><br>
OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc | 2 +-<span class="apple-converted-space"> </span><br>
1 file changed, 1 insertion(+), 1 deletion(-)<span class="apple-converted-space"> </span><br>
<br>
diff --git a/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc b/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc<span class="apple-converted-space"> </span><br>
index 28d9af4..ac3b5ec 100644<span class="apple-converted-space"> </span><br>
--- a/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc<span class="apple-converted-space"> </span><br>
+++ b/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc<span class="apple-converted-space"> </span><br>
@@ -54,7 +54,7 @@<span class="apple-converted-space"> </span><br>
!include MdePkg/MdeLibs.dsc.inc<span class="apple-converted-space"> </span><br>
<br>
[BuildOptions]<span class="apple-converted-space"> </span><br>
- GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG<span class="apple-converted-space"> </span><br>
+ GCC:RELEASE_*_*_CC_FLAGS = -flto<span class="apple-converted-space"> </span><br>
!ifdef $(SOURCE_DEBUG_ENABLE)<span class="apple-converted-space"> </span><br>
GCC:*_*_RISCV64_GENFW_FLAGS = --keepexceptiontable<span class="apple-converted-space"> </span><br>
!endif<span class="apple-converted-space"> </span><br>
--<span class="apple-converted-space"> </span><br>
2.39.1<br>
<br>
<br>
</span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;"><o:p></o:p></span>
</p>
<p>
<span style="font-size:9.0pt;font-family:MingLiU;">I have added the LTO flag and dropped MDEPKG_NDEBUG in the .dsc file, it compiled successfully, the build log:<a href="https://build.tarsier-infra.com/package/live_build_log/home:ouuleilei:branches:openEuler:Mainline/edk2/openEuler_Mainline_standard_riscv64_gcc/riscv64">https://build.tarsier-infra.com/package/live_build_log/home:ouuleilei:branches:openEuler:Mainline/edk2/openEuler_Mainline_standard_riscv64_gcc/riscv64</a></span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;"><o:p></o:p></span>
</p>
<p>
<span style="font-size:9.0pt;font-family:MingLiU;">Do you have other way to add LTO flag to compile that don't change the source code, i tried to use environment variable, like exported CFLAGS=-flto to compile, but the compiler doesn't work with it.</span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;"><o:p></o:p></span>
</p>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> </span><o:p></o:p>
</p>
</div>
</div>
<p>
<span style="font-size:9.0pt;font-family:MingLiU;"> </span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;"><o:p></o:p></span>
</p>
<p>
<span style="font-size:9.0pt;font-family:MingLiU;"> </span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;"><o:p></o:p></span>
</p>
<p>
<span style="font-size:9.0pt;font-family:MingLiU;"> </span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;"><o:p></o:p></span>
</p>
<blockquote style="border:none;border-left:solid windowtext 1.5pt;padding:0in 0in 0in 4.0pt;margin-left:3.75pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt;border-color:currentcolor currentcolor currentcolor #B6B6B6;border-image:none;" name="replyContent">
<p class="MsoNormal" style="margin-bottom:12.0pt;">
<span style="font-family:MingLiU;">-----原始郵件-----<br>
<b>發件人:</b>"Andrew (EFI) Fish" <<a href="mailto:afish@apple.com">afish@apple.com</a>><br>
<b>發送時間:</b>2023-08-10 21:50:55 (星期四)<br>
<b>收件人:</b><span class="apple-converted-space"> </span>edk2-devel-groups-io <<a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a>>,<span class="apple-converted-space"> </span><a href="mailto:wangliu@iscas.ac.cn">wangliu@iscas.ac.cn</a><br>
<b>抄送:</b><span class="apple-converted-space"> </span><br>
<b>主題:</b><span class="apple-converted-space"> </span>Re: [edk2-devel] Can RELEASE target disable -Werror CC_FLAG?</span><o:p></o:p>
</p>
<div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;">I think that you are advocating that since we have code that error checks on DEBUG and not RELEASE builds we should relax the RELEASE build compiler flags?</span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> </span><o:p></o:p>
</p>
</div>
</div>
<div>
<pre style="background:#F8F9FA;margin:1rem;box-sizing:border-box;white-space:pre-wrap;caret-color:#212529;padding:1.5rem !important;overflow:auto;" id="log-space"><span style="font-size:8.5pt;font-family:Consolas;color:#212529;">/home/abuild/rpmbuild/BUILD/edk2-edk2-stable202305/MdeModulePkg/Core/Dxe/Hand/Handle.c:1183:24: error: ‘Prot’ may be used uninitialized [-Werror=maybe-uninitialized]</span><o:p></o:p></pre>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> ASSERT (Prot != NULL);</span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> //<span class="apple-converted-space"> </span></span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> // EFI_ALREADY_STARTED is not an error for bus driver.</span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> // Return the corresponding protocol interface.</span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> //<span class="apple-converted-space"> </span></span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> *Interface = Prot->Interface;</span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> </span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;">A given platform can add ASSERT into release builds if it wants. I’ve actually done that for power on before. If your compiler supports LTO you are not required to set MDEPKG_NDEBUG on RELEASE builds, and
you can used a PCD to configure your debug level, per build type. <span class="apple-converted-space"> </span></span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> </span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;">Maybe we should just have the error checks in all paths?</span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> </span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;">Thanks,<span class="apple-converted-space"> </span></span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> </span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;">Andrew Fish<span class="apple-converted-space"> </span></span><o:p></o:p>
</p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"><br>
<br>
<br>
</span><o:p></o:p>
</p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt;">
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;">On Aug 10, 2023, at 6:44 AM, 汪流 <<a href="mailto:wangliu@iscas.ac.cn">wangliu@iscas.ac.cn</a>> wrote:</span><o:p></o:p>
</p>
</div>
</div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> </span><o:p></o:p>
</p>
</div>
<div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;">I want to build a rpm package for edk2-stable202305 on riscv64, however I get some uninitialized variable error, I have found that the reason is -Werror flag.<br>
My build target was release. I think the flag should used in the debug ,not in release.<br>
My build command: build -t GCC5 -n $NCPUS -b RELEASE -a RISCV64 -p OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc -D SECURE_BOOT_ENABLE=TRUE -D TPM_ENABLE=TRUE -D TPM_CONFIG_ENABLE=TRUE</span><o:p></o:p>
</p>
</div>
<p>
<span style="font-size:9.0pt;font-family:MingLiU;">This is my packet log: <span class="apple-converted-space"> </span></span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;"><o:p></o:p></span>
</p>
<p>
<span style="font-size:9.0pt;font-family:MingLiU;"><a href="https://build.tarsier-infra.com/package/live_build_log/home:ouuleilei:branches:home:ouuleilei:branches:openEuler:Mainline/edk2-test/openEuler_Mainline_standard_riscv64_gcc/riscv64">https://build.tarsier-infra.com/package/live_build_log/home:ouuleilei:branches:home:ouuleilei:branches:openEuler:Mainline/edk2-test/openEuler_Mainline_standard_riscv64_gcc/riscv64</a></span><span style="font-size:9.0pt;font-family:"Helvetica",sans-serif;"><o:p></o:p></span>
</p>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"><a href="https://build.tarsier-infra.com/build/home:ouuleilei:branches:home:ouuleilei:branches:openEuler:Mainline/openEuler_Mainline_standard_riscv64_gcc/riscv64/edk2-test/_log">https://build.tarsier-infra.com/build/home:ouuleilei:branches:home:ouuleilei:branches:openEuler:Mainline/openEuler_Mainline_standard_riscv64_gcc/riscv64/edk2-test/_log</a></span><o:p></o:p>
</p>
</div>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal">
<span style="font-family:MingLiU;"> </span><o:p></o:p>
</p>
</div>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal">
</o:p></span>
</p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal">
<o:p> </o:p>
</p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
<div width="1" style="color:white;clear:both">_._,_._,_</div>
<hr>
Groups.io Links:<p>
You receive all messages sent to this group.
<p>
<a target="_blank" href="https://edk2.groups.io/g/devel/message/107912">View/Reply Online (#107912)</a> |
|
<a target="_blank" href="https://groups.io/mt/100663199/1813853">Mute This Topic</a>
| <a href="https://edk2.groups.io/g/devel/post">New Topic</a>
<br>
<a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> |
<a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |
<a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>
[edk2-devel-archive@redhat.com]<br>
<div width="1" style="color:white;clear:both">_._,_._,_</div>