From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.45]) by mx.groups.io with SMTP id smtpd.web10.8755.1585305983777495137 for ; Fri, 27 Mar 2020 03:46:24 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: ispras.ru, ip: 83.149.199.45, mailfrom: cheptsov@ispras.ru) Received: from localhost.localdomain (unknown [77.232.9.83]) by mail.ispras.ru (Postfix) with ESMTPSA id 59EB6C0110; Fri, 27 Mar 2020 13:46:22 +0300 (MSK) From: "Vitaly Cheptsov" To: devel@edk2.groups.io Cc: Liming Gao , =?UTF-8?q?Marvin=20H=C3=A4user?= , Zhiguang Liu Subject: [PATCH 1/1] BaseTools: Use SEH exceptions in CLANGPDB for IA32 Date: Fri, 27 Mar 2020 13:45:59 +0300 Message-Id: <20200327104559.51216-2-cheptsov@ispras.ru> X-Mailer: git-send-email 2.24.1 (Apple Git-126) In-Reply-To: <20200327104559.51216-1-cheptsov@ispras.ru> References: <20200327104559.51216-1-cheptsov@ispras.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable From: Vitaly Cheptsov REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2628 This patch reduces the size of IA32 binaries by ensuring that no .debug_frame / .eh_frame sections are generated through forcing SEH exception model, which is already the default in clang for X64. EDK II does not support exceptions, and in future we should disable them instead of switching to some other variant. Currently this is not possible due to the following LLVM bugs: https://bugs.llvm.org/show_bug.cgi?id=3D45324 https://bugs.llvm.org/show_bug.cgi?id=3D45325 Upon applying this patch OvmfPkgIA32.dsc compilation in DEBUG mode gets the following size decrease with clang 9.0.1. Before: FV Space Information SECFV [11%Full] 212992 total, 24512 used, 188480 free PEIFV [22%Full] 917504 total, 203048 used, 714456 free DXEFV [36%Full] 11534336 total, 4215672 used, 7318664 free FVMAIN_COMPACT [37%Full] 3440640 total, 1287776 used, 2152864 free After: FV Space Information SECFV [10%Full] 212992 total, 22112 used, 190880 free PEIFV [19%Full] 917504 total, 176392 used, 741112 free DXEFV [31%Full] 11534336 total, 3657112 used, 7877224 free FVMAIN_COMPACT [33%Full] 3440640 total, 1153896 used, 2286744 free CC: Liming Gao CC: Marvin H=C3=A4user CC: Zhiguang Liu Signed-off-by: Vitaly Cheptsov --- BaseTools/Conf/tools_def.template | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.t= emplate index 2b17d3b297..88d7ab8cab 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -2759,7 +2759,7 @@ DEFINE CLANGPDB_IA32_TARGET =3D -target i686= -unknown-windows-gnu DEFINE CLANGPDB_X64_TARGET =3D -target x86_64-unknown-windows-gn= u=0D =0D DEFINE CLANGPDB_WARNING_OVERRIDES =3D -Wno-parentheses-equality -Wno-ta= utological-compare -Wno-tautological-constant-out-of-range-compare -Wno-emp= ty-body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option= -Wno-microsoft-enum-forward-reference=0D -DEFINE CLANGPDB_ALL_CC_FLAGS =3D DEF(GCC48_ALL_CC_FLAGS) DEF(CLANG= PDB_WARNING_OVERRIDES) -fno-stack-protector -funsigned-char -ftrap-function= =3Dundefined_behavior_has_been_optimized_away_by_clang -Wno-address -Wno-sh= ift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-redeclara= tion -Wno-null-dereference -mno-implicit-float -mms-bitfields -mno-stack-ar= g-probe -nostdlib -nostdlibinc=0D +DEFINE CLANGPDB_ALL_CC_FLAGS =3D DEF(GCC48_ALL_CC_FLAGS) DEF(CLANG= PDB_WARNING_OVERRIDES) -fno-stack-protector -funsigned-char -ftrap-function= =3Dundefined_behavior_has_been_optimized_away_by_clang -Wno-address -Wno-sh= ift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-redeclara= tion -Wno-null-dereference -mno-implicit-float -mms-bitfields -mno-stack-ar= g-probe -nostdlib -nostdlibinc -fseh-exceptions=0D =0D ###########################=0D # CLANGPDB IA32 definitions=0D @@ -2784,15 +2784,15 @@ DEFINE CLANGPDB_ALL_CC_FLAGS =3D DEF(GCC48_= ALL_CC_FLAGS) DEF(CLANGPDB_WARN *_CLANGPDB_IA32_VFRPP_FLAGS =3D DEF(GCC_VFRPP_FLAGS) DEF(CLANGPDB= _IA32_TARGET)=0D =0D DEBUG_CLANGPDB_IA32_CC_FLAGS =3D DEF(CLANGPDB_ALL_CC_FLAGS) -m32 -= Oz -flto -march=3Di586 DEF(CLANGPDB_IA32_TARGET) -gcodeview=0D -DEBUG_CLANGPDB_IA32_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:400= 1 /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION= :.pdata,D /MACHINE:X86 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT= _SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /lldmap=0D +DEBUG_CLANGPDB_IA32_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:400= 1 /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION= :.pdata,D /MACHINE:X86 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT= _SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=3D= wineh /lldmap=0D DEBUG_CLANGPDB_IA32_DLINK2_FLAGS =3D=0D =0D RELEASE_CLANGPDB_IA32_CC_FLAGS =3D DEF(CLANGPDB_ALL_CC_FLAGS) -m32 -= Oz -flto -march=3Di586 DEF(CLANGPDB_IA32_TARGET)=0D -RELEASE_CLANGPDB_IA32_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:400= 1 /IGNORE:4254 /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xda= ta,D /SECTION:.pdata,D /MACHINE:X86 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSY= STEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=3D.data /ll= dmap=0D +RELEASE_CLANGPDB_IA32_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:400= 1 /IGNORE:4254 /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xda= ta,D /SECTION:.pdata,D /MACHINE:X86 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSY= STEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=3D.data /MLL= VM:-exception-model=3Dwineh /lldmap=0D RELEASE_CLANGPDB_IA32_DLINK2_FLAGS =3D=0D =0D NOOPT_CLANGPDB_IA32_CC_FLAGS =3D DEF(CLANGPDB_ALL_CC_FLAGS) -m32 -= O0 -march=3Di586 DEF(CLANGPDB_IA32_TARGET) -gcodeview=0D -NOOPT_CLANGPDB_IA32_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:400= 1 /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION= :.pdata,D /MACHINE:X86 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT= _SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /lldmap=0D +NOOPT_CLANGPDB_IA32_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:400= 1 /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION= :.pdata,D /MACHINE:X86 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT= _SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /MLLVM:-exception-model=3D= wineh /lldmap=0D NOOPT_CLANGPDB_IA32_DLINK2_FLAGS =3D=0D =0D ##########################=0D @@ -2818,17 +2818,17 @@ NOOPT_CLANGPDB_IA32_DLINK2_FLAGS =3D *_CLANGPDB_X64_VFRPP_FLAGS =3D DEF(GCC_VFRPP_FLAGS) DEF(CLANGPDB_= X64_TARGET)=0D =0D DEBUG_CLANGPDB_X64_CC_FLAGS =3D DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-= DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -Oz -flto= DEF(CLANGPDB_X64_TARGET) -gcodeview -funwind-tables=0D -DEBUG_CLANGPDB_X64_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001= /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(= IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /= DEBUG:GHASH /lldmap=0D +DEBUG_CLANGPDB_X64_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001= /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(= IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /= DEBUG:GHASH /MLLVM:-exception-model=3Dwineh /lldmap=0D DEBUG_CLANGPDB_X64_DLINK2_FLAGS =3D=0D DEBUG_CLANGPDB_X64_GENFW_FLAGS =3D --keepexceptiontable=0D =0D RELEASE_CLANGPDB_X64_CC_FLAGS =3D DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-= DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -Oz -flto= DEF(CLANGPDB_X64_TARGET) -fno-unwind-tables=0D -RELEASE_CLANGPDB_X64_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001= /IGNORE:4254 /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdat= a,D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYS= TEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=3D.data /lld= map=0D +RELEASE_CLANGPDB_X64_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001= /IGNORE:4254 /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdat= a,D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYS= TEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=3D.data /MLLV= M:-exception-model=3Dwineh /lldmap=0D RELEASE_CLANGPDB_X64_DLINK2_FLAGS =3D=0D RELEASE_CLANGPDB_X64_GENFW_FLAGS =3D=0D =0D NOOPT_CLANGPDB_X64_CC_FLAGS =3D DEF(CLANGPDB_ALL_CC_FLAGS) -m64 "-= DEFIAPI=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -O0 DEF(C= LANGPDB_X64_TARGET) -gcodeview -funwind-tables=0D -NOOPT_CLANGPDB_X64_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001= /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(= IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /= DEBUG:GHASH /lldmap=0D +NOOPT_CLANGPDB_X64_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001= /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /Machine:X64 /DLL /ENTRY:$(= IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /= DEBUG:GHASH /MLLVM:-exception-model=3Dwineh /lldmap=0D NOOPT_CLANGPDB_X64_DLINK2_FLAGS =3D=0D NOOPT_CLANGPDB_X64_GENFW_FLAGS =3D --keepexceptiontable=0D =0D --=20 2.24.1 (Apple Git-126)