I successfully resolved the build issue by adding the flag 
-Wno-maybe-uninitialized in the BaseTools/Conf/tools_def.template file. 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. Here's the link to the successful build log: 
https://build.tarsier-infra.com/package/live_build_log/home:ouuleilei:branches:openEuler:Mainline/edk2/openEuler_Mainline_standard_riscv64_gcc/riscv64.







-----原始郵件-----
發件人:"Andrew (EFI) Fish" <af...@apple.com>
發送時間:2023-08-17 19:45:01 (星期四)
收件人: devel@edk2.groups.io, wang...@iscas.ac.cn
抄送: "Kinney, Michael D" <michael.d.kin...@intel.com>
主題: Re: [edk2-devel] Can RELEASE target disable -Werror CC_FLAG?


Can you add -Wno-maybe-uninitialized to compiler flags to work around the error?
On Aug 16, 2023, at 11:31 PM, 汪流 <wang...@iscas.ac.cn> wrote:



This is the failed build log: 
https://build.tarsier-infra.com/package/live_build_log/home:ouuleilei:branches:openEuler:Mainline/edk2/openEuler_Mainline_standard_riscv64_gcc/riscv64

    arch:        riscv64

    gcc version: 10.3.1









-----原始郵件-----
發件人:"Kinney, Michael D" <michael.d.kin...@intel.com>
發送時間:2023-08-17 01:50:37 (星期四)
收件人: "Andrew (EFI) Fish" <af...@apple.com>, edk2-devel-groups-io 
<devel@edk2.groups.io>
抄送: "wang...@iscas.ac.cn" <wang...@iscas.ac.cn>, "Kinney, Michael D" 
<michael.d.kin...@intel.com>
主題: RE: [edk2-devel] Can RELEASE target disable -Werror CC_FLAG?



Hi Andrew,

 

There are compiler flags we set to suppress some of these types of specific 
warnings to avoid disable warnings as errors.

 

For example, this commit to tools_def.template:

 

https://github.com/tianocore/edk2/commit/8e985ac3fdb2b117968ac1fa1f54666e166af8ac

 

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.

 

Mike

 

From: Andrew (EFI) Fish <af...@apple.com>
Sent: Wednesday, August 16, 2023 10:41 AM
To: edk2-devel-groups-io <devel@edk2.groups.io>; Kinney, Michael D 
<michael.d.kin...@intel.com>
Cc: wang...@iscas.ac.cn
Subject: Re: [edk2-devel] Can RELEASE target disable -Werror CC_FLAG?

 

Mike,

 

I seem to remember it was a maybe-uninitialized 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. 

 

      ASSERT (Prot != NULL);

      // 

      // EFI_ALREADY_STARTED is not an error for bus driver.

      // Return the corresponding protocol interface.

      // 

      *Interface = Prot->Interface;

 

Thanks,

 

Andrew Fish





On Aug 16, 2023, at 10:02 AM, Michael D Kinney <michael.d.kin...@intel.com> 
wrote:

 

Can you provide the specific build error?

 

So far, we have not had to relax that flag for any RELEASE builds.

 

Thanks,

 

Mike

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of ??
Sent: Wednesday, August 16, 2023 12:46 AM
To: Andrew (EFI) Fish <af...@apple.com>
Cc: edk2-devel-groups-io <devel@edk2.groups.io>
Subject: Re: [edk2-devel] Can RELEASE target disable -Werror CC_FLAG?

 

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.

 

--- 
OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc | 2 +- 
1 file changed, 1 insertion(+), 1 deletion(-) 

diff --git a/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc 
b/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc 
index 28d9af4..ac3b5ec 100644 
--- a/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc 
+++ b/OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc 
@@ -54,7 +54,7 @@ 
!include MdePkg/MdeLibs.dsc.inc 

[BuildOptions] 
-  GCC:RELEASE_*_*_CC_FLAGS       = -DMDEPKG_NDEBUG 
+  GCC:RELEASE_*_*_CC_FLAGS       = -flto 
!ifdef $(SOURCE_DEBUG_ENABLE) 
  GCC:*_*_RISCV64_GENFW_FLAGS    = --keepexceptiontable 
!endif 
-- 
2.39.1




I have added the LTO flag and dropped MDEPKG_NDEBUG in the .dsc file, it 
compiled successfully, the build 
log:https://build.tarsier-infra.com/package/live_build_log/home:ouuleilei:branches:openEuler:Mainline/edk2/openEuler_Mainline_standard_riscv64_gcc/riscv64

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.

 

 

 

 

-----原始郵件-----
發件人:"Andrew (EFI) Fish" <af...@apple.com>
發送時間:2023-08-10 21:50:55 (星期四)
收件人: edk2-devel-groups-io <devel@edk2.groups.io>, wang...@iscas.ac.cn
抄送: 
主題: Re: [edk2-devel] Can RELEASE target disable -Werror CC_FLAG?

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?

 

/home/abuild/rpmbuild/BUILD/edk2-edk2-stable202305/MdeModulePkg/Core/Dxe/Hand/Handle.c:1183:24:
 error: ‘Prot’ may be used uninitialized [-Werror=maybe-uninitialized]

      ASSERT (Prot != NULL);

      // 

      // EFI_ALREADY_STARTED is not an error for bus driver.

      // Return the corresponding protocol interface.

      // 

      *Interface = Prot->Interface;

 

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.  

 

Maybe we should just have the error checks in all paths?

 

Thanks, 

 

Andrew Fish 






On Aug 10, 2023, at 6:44 AM, 汪流 <wang...@iscas.ac.cn> wrote:

 

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.
My build target was release. I think the flag should used in the debug ,not in 
release.
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

This is my packet log:    

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/build/home:ouuleilei:branches:home:ouuleilei:branches:openEuler:Mainline/openEuler_Mainline_standard_riscv64_gcc/riscv64/edk2-test/_log

 



 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#107912): https://edk2.groups.io/g/devel/message/107912
Mute This Topic: https://groups.io/mt/100663199/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to