[Bug 1230425] New: Using shorter name of build root folder can build out a smaller ovmf image
https://bugzilla.suse.com/show_bug.cgi?id=1230425 Bug ID: 1230425 Summary: Using shorter name of build root folder can build out a smaller ovmf image Classification: openSUSE Product: openSUSE Tumbleweed Version: Slowroll Hardware: Other OS: Other Status: NEW Severity: Normal Priority: P5 - None Component: Virtualization:Other Assignee: virt-bugs@suse.de Reporter: jlee@suse.com QA Contact: qa-bugs@suse.de Target Milestone: --- Found By: --- Blocker: --- This situation be found when I am porting edk2-stable202405 ovmf to Tumbleweed. The built out FV image size is too big for FD_SIZE_2MB config. It shows the following build error on OBS: Generating PEIFV FV ### Generating DXEFV FV ############ ['GenFv', '-a', '/home/joeyli/tmp/tmp/edk2-edk2-stable202405/Build/OvmfX64/DEBUG_GCC5/FV/Ffs/FVMAIN_COMPACT.inf', '-o', '/home/joeyli/tmp/tmp/edk2-edk2-stable202405/Build/OvmfX64/DEBUG_GCC5/FV/FVMAI Return Value = 2 GenFv: ERROR 3000: Invalid the required fv image size 0x1ac300 exceeds the set fv image size 0x1ac000 This error can also be reproduced by local build. Then I start to checking the binary of *.ffs files which are the source of FV image. e.g. Build/OvmfX64/DEBUG_GCC5/FV/Ffs/D6A2CB7F-6A18-4e2f-B43B-9920A733700ADxeCore/D6A2CB7F-6A18-4e2f-B43B-9920A733700ASEC1.1.pe32 In pe32 binary, it has many strings which are copied from the name of build root folder. e.g. ^@!(((INTN)(RETURN_STATUS)(Status)) < 0)^@/home/joeyli/tmp/tmp/edk2/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c^@DisableNullDetectionAtTheEndOfDxe(): end^M ^@/home/joeyli/tmp/tmp/edk2/MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.c^@!!!!!!!! ImageRecord not found !!!!!!!! So, if I used a build root folder with short name. I can reduce the size of the final FV image for FD_SIZE_2MB config. -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1230425 Joey Lee <jlee@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|virt-bugs@suse.de |jlee@suse.com -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1230425 https://bugzilla.suse.com/show_bug.cgi?id=1230425#c1 --- Comment #1 from Joey Lee <jlee@suse.com> --- After tracing edk2 code, I found that the _ASSERT macro used __FILE_NAME__ and __FILE__ extension for getting the filename of source code: MdePkg/Include/Library/DebugLib.h #if defined (_ASSERT) #undef _ASSERT #endif #if defined (__clang__) && defined (__FILE_NAME__) #define _ASSERT(Expression) UnitTestDebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression)) #else #define _ASSERT(Expression) UnitTestDebugAssert (__FILE__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression)) #endif #else #if defined (__clang__) && defined (__FILE_NAME__) #define _ASSERT(Expression) DebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression)) #else #define _ASSERT(Expression) DebugAssert (__FILE__, DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression)) #endif #endif That's why pe32+ binary file has many build root folder name. And longer build root name will produce bigger FV image. -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1230425 https://bugzilla.suse.com/show_bug.cgi?id=1230425#c2 --- Comment #2 from Joey Lee <jlee@suse.com> --- The __FILE_NAME__ be supported by gcc-12: Bug 42579 - [PATCH] support for obtaining file basename https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42579 We can move to gcc-12 for reducing the size of fv image. I will submit patch to edk2 mainline to remove the checking of __clang__ in _ASSERT macro. Before my patch be merged to mainline. I direct use shorter build root name (using edk2/ instead of edk2-edk2-stable202402/) when building ovmf RPM on OBS. -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1230425 https://bugzilla.suse.com/show_bug.cgi?id=1230425#c3 --- Comment #3 from Joey Lee <jlee@suse.com> --- I filed a merge request to edk2 mainline: https://github.com/tianocore/edk2/pull/6193 -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1230425 https://bugzilla.suse.com/show_bug.cgi?id=1230425#c4 --- Comment #4 from Joey Lee <jlee@suse.com> --- (In reply to Joey Lee from comment #3)
I filed a merge request to edk2 mainline:
The patch be merged to mainline: commit 5c8bdb190f6dd79f38ef6191754c9a26892f8d26 Author: Chun-Yi Lee <jlee@suse.com> Date: Thu Sep 12 14:32:05 2024 +0800 MdePkg DebugLib: Enable FILE NAME as DEBUG ASSERT for GCC12 Using __FILE_NAME__ is useful for reducing the size of debug image and it's also good for reproducable builds. The gcc-12 also supported this macro. Ref: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=1a9b3f04c11eb467a8dc504a37dad... This patch removed the checking of __clang__ when using __FILE_NAME__. References: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42579 Signed-off-by: Chun-Yi Lee <jlee@suse.com> -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1230425 https://bugzilla.suse.com/show_bug.cgi?id=1230425#c5 --- Comment #5 from Joey Lee <jlee@suse.com> --- Then we should find a good timing for switching to gcc12. My plan is that SLE16. Before this we should still use gcc-7 in 15-SP7. -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1230425 Maintenance Automation <maint-coord+maintenance-robot@suse.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |IN_PROGRESS -- You are receiving this mail because: You are on the CC list for the bug.
https://bugzilla.suse.com/show_bug.cgi?id=1230425 https://bugzilla.suse.com/show_bug.cgi?id=1230425#c9 --- Comment #9 from Joey Lee <jlee@suse.com> --- (In reply to Joey Lee from comment #5)
Then we should find a good timing for switching to gcc12. My plan is that SLE16. Before this we should still use gcc-7 in 15-SP7.
Finally I choice gcc-12 for building ovmf on 15-SP7: ------------------------------------------------------------------- Mon Oct 21 06:26:22 UTC 2024 - Joey Lee <jlee@suse.com> - Update to edk2-stable202408 - Features (https://github.com/tianocore/edk2/releases): ... - We also got image size issue when cross compiling x86_64 FD_SIZE_2MB image on aarch64 environment. So using x86_64-suse-linux-gcc-12 on SLE15-SP7 or Leap 15.4 codebases. Here is the pseudocode in ovmf.spec: ifnarch x86_64 BuildRequires: cross-x86_64-binutils if sle_version >= 150500 && sle_version <= 150700 BuildRequires: cross-x86_64-gcc12 else BuildRequires: cross-x86_64-gcc+gcc_version endif endif - The x86_64-suse-linux-gcc-12 be auto-linked to x86_64-suse-linux-gcc after installed cross-x86_64-gcc12. So we don't need to add any downstream patch for corss compiling x86_64 2MB image on aarch64. ------------------------------------------------------------------- Wed Oct 9 06:10:52 UTC 2024 - Joey Lee <jlee@suse.com> - Using gcc12 for building x86_64 ovmf image: As the item 'Changed the approach for creating the edk2 source code tarball' in 'Update to edk2-stable202405' change log. We modified the folder name in edk2-edk2-stable%{version}.tar.gz source code tarball to avoid the size problem against FD_SIZE_2MB config. (bsc#1230425) We can use gcc-12 to avoid the size problem because gcc-12 supported __FILE_NAME__ macro for reproducing the size of firmware image. So we applied the above 5c8bdb190f6d patch and aldo the following SLE15-SP7/ Leap 15.7 specific patch for setting the gcc-12 as the default compiler for x86_64 ovmf: - ovmf-BaseTools-Using-gcc12-for-building-image.patch 'BaseTools: Using gcc12 for building x86_64 ovmf image' - This patch only be applied to x86_64 image when building on SUSE 15.5/15.6/15.7 codebases. Here is the pseudocode in ovmf.spec: ifarch x86_64 if sle_version >= 150500 && sle_version <= 150700 Patch13 ovmf-BaseTools-Using-gcc12-for-building-image.patch endif endif The main target is SLE15-SP7 and Leap 15.7. The SUSE 15.5/15.6 is for building in Virtualization development project on OBS: -- You are receiving this mail because: You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@suse.com