> On May 11, 2016, at 5:08 AM, Shi, Steven <steven....@intel.com> wrote: > > Hi Andrew, > From your data, it looks the XCode LTO is not enabled correctly for IA32, but > correct for X64. Attachment has my build map files, and below are my build > commands. FYI. >
Sorry had a typo in the tools_def.txt, here are the numbers with -flto correctly added to the CC_FLAGS: > build -a IA32 -t XCODE5 -p OvmfPkg/OvmfPkgIa32.dsc -n 5 -m > MdeModulePkg/Core/Pei/PeiMain.inf -b RELEASE 25K > build -a IA32 -t XCODE5 -p OvmfPkg/OvmfPkgIa32.dsc -n 5 -m > MdeModulePkg/Core/Pei/PeiMain.inf -b DEBUG -DDEBUG_ON_SERIAL_PORT 45K > build -a X64 -t XCODE5 -p OvmfPkg/OvmfPkgX64.dsc -n 5 -m > MdeModulePkg/Core/Dxe/DxeMain.inf -b RELEASE 103K > build -a X64 -t XCODE5 -p OvmfPkg/OvmfPkgX64.dsc -n 5 -m > MdeModulePkg/Core/Dxe/DxeMain.inf -b DEBUG -DDEBUG_ON_SERIAL_PORT 133K When doing size optimizations it is often easier to start with smaller drivers. Can you send the sizes/map files for: > build -a IA32 -t XCODE5 -p OvmfPkg/OvmfPkgIa32.dsc -n 5 -m > IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf -b RELEASE 1220 > build -a IA32 -t XCODE5 -p OvmfPkg/OvmfPkgIa32.dsc -n 5 -m > IntelFrameworkModulePkg/Universal/StatusCode/Pei/StatusCodePei.inf -b DEBUG > -DDEBUG_ON_SERIAL_PORT 8228 > build -a X64 -t XCODE5 -p OvmfPkg/OvmfPkgX64.dsc -n 5 -m > PcAtChipsetPkg/8254TimerDxe/8254Timer.inf -b RELEASE 2464 > build -a X64 -t XCODE5 -p OvmfPkg/OvmfPkgX64.dsc -n 5 -m > PcAtChipsetPkg/8254TimerDxe/8254Timer.inf -b DEBUG -DDEBUG_ON_SERIAL_PORT 9088 I forgot to mention that X64 XCODE5/clang has a 5 byte overhead per function vs.VS2013x86 due to supporting stack unwind. The upside is the unexpected exception handler can print out a stack trace. VS2013x86 requires the debugger with symbols to unwind the stack. ~/work/Compiler>cat call.c int main () { return 0; } ~/work/Compiler>clang -Os call.c ~/work/Compiler>lldb a.out (lldb) target create "a.out" Current executable set to 'a.out' (x86_64). (lldb) dis -m -b -n main a.out`main a.out`main: a.out[0x100000f98] <+0>: 55 pushq %rbp a.out[0x100000f99] <+1>: 48 89 e5 movq %rsp, %rbp a.out[0x100000f9c] <+4>: 31 c0 xorl %eax, %eax a.out[0x100000f9e] <+6>: 5d popq %rbp a.out[0x100000f9f] <+7>: c3 retq Thanks, Andrew Fish > VS2013x86: > build -a IA32 -t VS2013x86 -p OvmfPkg\OvmfPkgIa32.dsc -n 5 -m > MdeModulePkg\Core\Pei\PeiMain.inf -b RELEASE > build -a IA32 -t VS2013x86 -p OvmfPkg\OvmfPkgIa32.dsc -n 5 -m > MdeModulePkg\Core\Pei\PeiMain.inf -b DEBUG -DDEBUG_ON_SERIAL_PORT > build -a X64 -t VS2013x86 -p OvmfPkg\OvmfPkgX64.dsc -n 5 -m > MdeModulePkg\Core\Dxe\DxeMain.inf -b RELEASE > build -a X64 -t VS2013x86 -p OvmfPkg\OvmfPkgX64.dsc -n 5 -m > MdeModulePkg\Core\Dxe\DxeMain.inf -b DEBUG -DDEBUG_ON_SERIAL_PORT > > CLANGLTO38: > build -a IA32 -t CLANGLTO38 -p OvmfPkg/OvmfPkgIa32.dsc -n 5 -m > MdeModulePkg/Core/Pei/PeiMain.inf -b RELEASE > build -a IA32 -t CLANGLTO38 -p OvmfPkg/OvmfPkgIa32.dsc -n 5 -m > MdeModulePkg/Core/Pei/PeiMain.inf -b DEBUG -DDEBUG_ON_SERIAL_PORT > build -a X64 -t CLANGLTO38 -p OvmfPkg/OvmfPkgX64.dsc -n 5 -m > MdeModulePkg/Core/Dxe/DxeMain.inf -b RELEASE > build -a X64 -t CLANGLTO38 -p OvmfPkg/OvmfPkgX64.dsc -n 5 -m > MdeModulePkg/Core/Dxe/DxeMain.inf -b DEBUG -DDEBUG_ON_SERIAL_PORT > > > > Steven Shi > Intel\SSG\STO\UEFI Firmware > > Tel: +86 021-61166522 > iNet: 821-6522 > > From: af...@apple.com [mailto:af...@apple.com] > Sent: Wednesday, May 11, 2016 2:03 AM > To: Shi, Steven <steven....@intel.com> > Cc: edk2-devel@lists.01.org > Subject: Re: [edk2] edk2 llvm branch > > > On May 10, 2016, at 8:05 AM, Shi, Steven > <steven....@intel.com<mailto:steven....@intel.com>> wrote: > > Hi Andrew, > Thank you for the suggestion. I will try your suggestion and response other > questions in your email later. I don't have XCODE5 environment, but could do > me a favor and let me know what current XCODE5 code size for PeiCore.efi and > DxeCore.efi in your side? In my side, as below data show, I see the LTO can > bring big code size improvement which is quite important for firmware in many > scenarios. > > I forgot to mention. LTO or not it is good to check to make sure the assembly > files are getting dead stripped. For example check to make sure you are not > getting all the assembly functions in the BaseLib included in your > executable. Some of the assembly is .S and some is .nasm so you may see > different behavior depending on which assembler was used. > > It is also useful to start looking at the smallest PEIM/DXE drivers 1st as it > may be easier to spot what is different. > > > Maybe it is also a good idea to enable LTO in XCODE. > > For Xcode you add -object_path_lto $(DEST_DIR_DEBUG)/$(BASE_NAME).lto to > *_XCODE5_*_DLINK_FLAGS. This places the intermediate link code gen in the > Build/ director vs. a temp director and is important for source level > debugging. To turn LTO on and off you add -flto to *_XCODE5_*_CC_FLAGS . > > We ended up making LTO a configurable build option, so we control it in the > DSC file. git > > [BuildOptions] > !if $(PEI_LTO_ENABLE) > XCODE:*_*_IA32_PLATFORM_FLAGS = -flto > !endif > > !if $(DXE_LTO_ENABLE) > XCODE:*_*_X64_PLATFORM_FLAGS = -flto > !endif > > I included the Xcode 6.3.2 Numbers: > > > > > IA32 DEBUG PeiCore.efi on Ovmf build code size example: > ToolChainName PeiCore.efi file size > VS2013x86: 40KB > CLANGLTO38: 42KB > Xcode 61K > > > GCCLTO53: 44KB > GCC49: 55KB > CLANG38: 60KB > > > IA32 RELEASE PeiCore.efi on Ovmf build code size example: > ToolChainName PeiCore.efi file size > VS2013x86: 20KB > GCCLTO53: 23KB > CLANGLTO38: 24KB > Xcode 31K > > > > GCC49: 27KB > Clang38: 29KB > > > X64 DEBUG DxeCore.efi on Ovmf build code size example: > ToolChainName .efi file size LZMA > Compressed size > VS2013x86: 137KB > 57KB > CLANGLTO38: 145KB > 61KB > Xcode 157K 68K > > > GCCLTO53: 161KB > 63KB > GCC49: 273KB 69KB > CLANG38: 205KB > 72KB > > > > X64 RELEASE DxeCore.efi on Ovmf build code size example: > ToolChainName .efi file size LZMA > Compressed size > VS2013x86: 95KB > 44KB > GCCLTO53: 101KB > 46KB > CLANGLTO38: 107KB > 48KB > Xcode 104K 49K > > > GCC49: 184KB 52KB > CLANG38: 133KB > 53KB > > > Can you send my linker map files for VS2013 & CLANGLTO38 off list. > > Thanks, > > Andrew Fish > > > Steven Shi > Intel\SSG\STO\UEFI Firmware > > Tel: +86 021-61166522 > iNet: 821-6522 > >> -----Original Message----- >> From: af...@apple.com<mailto:af...@apple.com> [mailto:af...@apple.com] >> Sent: Tuesday, May 10, 2016 1:12 PM >> To: Shi, Steven <steven....@intel.com<mailto:steven....@intel.com>> >> Cc: edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org> >> Subject: Re: [edk2] edk2 llvm branch >> >> > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel