From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.3470.1571300331853705382 for ; Thu, 17 Oct 2019 01:18:52 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: bob.c.feng@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Oct 2019 01:18:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,307,1566889200"; d="scan'208";a="202320919" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by FMSMGA003.fm.intel.com with ESMTP; 17 Oct 2019 01:18:51 -0700 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 17 Oct 2019 01:18:50 -0700 Received: from shsmsx105.ccr.corp.intel.com (10.239.4.158) by fmsmsx124.amr.corp.intel.com (10.18.125.39) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 17 Oct 2019 01:18:50 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.166]) by SHSMSX105.ccr.corp.intel.com ([169.254.11.96]) with mapi id 14.03.0439.000; Thu, 17 Oct 2019 16:18:48 +0800 From: "Bob Feng" To: "Gao, Liming" , "devel@edk2.groups.io" Subject: Re: [Patch v3 02/11] BaseTools tools_def: Add CLANG9 tool chain to directly generate PE image Thread-Topic: [Patch v3 02/11] BaseTools tools_def: Add CLANG9 tool chain to directly generate PE image Thread-Index: AQHVhLf6gMbeazog0Eeg+bc43L2iiqdefYCw Date: Thu, 17 Oct 2019 08:18:47 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D16154BC44@SHSMSX104.ccr.corp.intel.com> References: <1571295356-11608-1-git-send-email-liming.gao@intel.com> <1571295356-11608-3-git-send-email-liming.gao@intel.com> In-Reply-To: <1571295356-11608-3-git-send-email-liming.gao@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: bob.c.feng@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng =20 -----Original Message----- From: Gao, Liming=20 Sent: Thursday, October 17, 2019 2:56 PM To: devel@edk2.groups.io Cc: Feng, Bob C Subject: [Patch v3 02/11] BaseTools tools_def: Add CLANG9 tool chain to dir= ectly generate PE image BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1603 Signed-off-by: Liming Gao Cc: Bob Feng --- BaseTools/Conf/build_rule.template | 26 ++++++---- BaseTools/Conf/tools_= def.template | 102 +++++++++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+), 10 deletions(-) diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule= .template index db06d3a6b4..3a58ac8015 100755 --- a/BaseTools/Conf/build_rule.template +++ b/BaseTools/Conf/build_rule.template @@ -260,7 +260,7 @@ $(OUTPUT_DIR)(+)$(MODULE_NAME).lib =20 - + "$(SLINK)" $(SLINK_FLAGS) /OUT:${dst} @$(OBJECT_FILES_LIST) =20 @@ -291,6 +291,9 @@ "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK2_FLAGS) $(DLINK_SPAT= H) @$(STATIC_LIBRARY_FILES_LIST) "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIB= RARY_FILES_LIST) =20 + + "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH)=20 + @$(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS) + "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -Wl,--start-group,@$(STATIC_LI= BRARY_FILES_LIST),--end-group $(CC_FLAGS) $(DLINK2_FLAGS) "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst} @@ -331,7 +334,7 @@ $(DEBUG_DIR)(+)$(MODULE_NAME) =20 - + "$(DLINK)" $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_L= IST) =20 @@ -355,7 +358,7 @@ $(OUTPUT_DIR)(+)$(MODULE_NAME).efi =20 - + "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS) $(CP) ${dst} $(DEBUG_DIR) $(CP) ${dst} $(BIN_DIR)(+)$(MODULE_NAME_GUID).efi @@ -460,9 +463,14 @@ =20 "$(ASLCC)" -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLA= GS) $(ASLCC_FLAGS) $(INC) ${src} - "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLI= NK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj + "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll=20 + $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS)=20 + $(ASLCC_FLAGS) "$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $= (GENFW_FLAGS) - =20 + + + "$(ASLCC)" -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLA= GS) $(ASLCC_FLAGS) $(INC) ${src} + "$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLD= LINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj + "$(GENFW)" -o ${dst} -c=20 + $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS) + =20 "$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FL= AGS) $(INC) ${src} "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLI= NK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj @@ -622,21 +630,19 @@ *.hpk =20 - + $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.lib =20 $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc =20 - + "$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUI= D) --hiipackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS) "$(RC)" /Fo${dst} $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc =20 "$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUI= D) --hiibinpackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS) "$(RC)" $(RC_FLAGS) $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc ${dst} - =20 + GenFw -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --= hiibinpackage $(HII_BINARY_PACKAGES) - =20 - =20 diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.t= emplate index fd6fca542d..b4bc27ab25 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -268,6 +268,15 @@ DEFINE DTC_BIN =3D ENV(DTC_PREFIX)dtc # Required to build platforms or ACPI tables: # Intel(r) ACPI Compiler from # https://acpica.org/downloads +# CLANG9 -Linux, Windows, Mac- Requires: +# Clang 9 or above from http://releases.llvm.o= rg/ +# Optional: +# Required to compile nasm source: +# nasm compiler from +# NASM -- http://www.nasm.us/ +# Required to build platforms or ACPI tables: +# Intel(r) ACPI Compiler from +# https://acpica.org/downloads # VS2008x86 -win64- Requires: # Microsoft Visual Studio 2008 (x86) # Microsoft Windows Server 2003 Driver Develop= ment Kit (Microsoft WINDDK) version 3790.1830 @@ -2698,6 +2707,99 @@ DEFINE CLANG38_AARCH64_DLINK_FLAGS =3D DEF(CLANG38_= AARCH64_TARGET) DEF(GCC_AARCH6 RELEASE_CLANG38_AARCH64_CC_FLAGS =3D DEF(CLANG38_AARCH64_CC_FLAGS) $(AR= CHCC_FLAGS) $(PLATFORM_FLAGS) -flto -O3 RELEASE_CLANG38_AARCH64_DLINK_FLAGS =3D DEF(CLANG38_AARCH64_DLINK_FLAGS) -= flto -Wl,-O3 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin= -opt=3D-pass-through=3D-llto-aarch64 =20 +####################################################################### +############# +# +# CLANG9 - This configuration is used to compile under=20 +Windows/Linux/Mac to produce # PE/COFF binaries using LLVM/Clang/LLD=20 +with Link Time Optimization enabled #=20 +##########################################################################= ########## +*_CLANG9_*_*_FAMILY =3D GCC +*_CLANG9_*_*_BUILDRULEFAMILY =3D CLANGPE +*_CLANG9_*_MAKE_PATH =3D ENV(CLANG_HOST_BIN)make +*_CLANG9_*_*_DLL =3D ENV(CLANG9_DLL) +*_CLANG9_*_ASL_PATH =3D DEF(UNIX_IASL_BIN) + +*_CLANG9_*_APP_FLAGS =3D +*_CLANG9_*_ASL_FLAGS =3D DEF(DEFAULT_WIN_ASL_FLAGS) +*_CLANG9_*_ASL_OUTFLAGS =3D DEF(DEFAULT_WIN_ASL_OUTFLAGS) +*_CLANG9_*_ASLDLINK_FLAGS =3D DEF(MSFT_ASLDLINK_FLAGS) + +DEFINE CLANG9_IA32_PREFIX =3D ENV(CLANG9_BIN) +DEFINE CLANG9_X64_PREFIX =3D ENV(CLANG9_BIN) + +DEFINE CLANG9_IA32_TARGET =3D -target i686-unknown-windows +DEFINE CLANG9_X64_TARGET =3D -target x86_64-unknown-windows + +DEFINE CLANG9_WARNING_OVERRIDES =3D -Wno-parentheses-equality -Wno-taut= ological-compare -Wno-tautological-constant-out-of-range-compare -Wno-empty= -body -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option -= Wno-microsoft-enum-forward-reference +DEFINE CLANG9_ALL_CC_FLAGS =3D DEF(GCC48_ALL_CC_FLAGS) DEF(CLANG9_= WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields -Wno-address -Wno-sh= ift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-redeclara= tion -fno-asynchronous-unwind-tables -mno-implicit-float -ftrap-function= =3Dundefined_behavior_has_been_optimized_away_by_clang -funsigned-char -fno= -ms-extensions -Wno-null-dereference -fms-compatibility -mno-stack-arg-prob= e + +########################### +# CLANG9 IA32 definitions +########################### +*_CLANG9_IA32_CC_PATH =3D DEF(CLANG9_IA32_PREFIX)clang +*_CLANG9_IA32_SLINK_PATH =3D DEF(CLANG9_IA32_PREFIX)llvm-lib +*_CLANG9_IA32_DLINK_PATH =3D DEF(CLANG9_IA32_PREFIX)lld-link +*_CLANG9_IA32_ASLDLINK_PATH =3D DEF(CLANG9_IA32_PREFIX)lld-link +*_CLANG9_IA32_ASM_PATH =3D DEF(CLANG9_IA32_PREFIX)clang +*_CLANG9_IA32_PP_PATH =3D DEF(CLANG9_IA32_PREFIX)clang +*_CLANG9_IA32_VFRPP_PATH =3D DEF(CLANG9_IA32_PREFIX)clang +*_CLANG9_IA32_ASLCC_PATH =3D DEF(CLANG9_IA32_PREFIX)clang +*_CLANG9_IA32_ASLPP_PATH =3D DEF(CLANG9_IA32_PREFIX)clang +*_CLANG9_IA32_RC_PATH =3D DEF(CLANG9_IA32_PREFIX)llvm-rc + +*_CLANG9_IA32_ASLCC_FLAGS =3D DEF(GCC_ASLCC_FLAGS) -m32 -fno-lto = DEF(CLANG9_IA32_TARGET) +*_CLANG9_IA32_ASM_FLAGS =3D DEF(GCC5_ASM_FLAGS) -m32 -march=3Di= 386 DEF(CLANG9_IA32_TARGET) +*_CLANG9_IA32_OBJCOPY_FLAGS =3D +*_CLANG9_IA32_NASM_FLAGS =3D -f win32 +*_CLANG9_IA32_PP_FLAGS =3D DEF(GCC_PP_FLAGS) DEF(CLANG9_IA32_T= ARGET) +*_CLANG9_IA32_ASLPP_FLAGS =3D DEF(GCC_ASLPP_FLAGS) DEF(CLANG9_IA3= 2_TARGET) +*_CLANG9_IA32_VFRPP_FLAGS =3D DEF(GCC_VFRPP_FLAGS) DEF(CLANG9_IA3= 2_TARGET) + +DEBUG_CLANG9_IA32_CC_FLAGS =3D DEF(CLANG9_ALL_CC_FLAGS) -m32 -Oz -= flto -march=3Di586 DEF(CLANG9_IA32_TARGET) -gcodeview +DEBUG_CLANG9_IA32_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001 = /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_S= ERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /lldmap +DEBUG_CLANG9_IA32_DLINK2_FLAGS =3D + +RELEASE_CLANG9_IA32_CC_FLAGS =3D DEF(CLANG9_ALL_CC_FLAGS) -m32 -Oz -= flto -march=3Di586 DEF(CLANG9_IA32_TARGET) +RELEASE_CLANG9_IA32_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001 = /IGNORE:4254 /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata= ,D /SECTION:.pdata,D /MACHINE:X86 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYST= EM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=3D.data /lldm= ap +RELEASE_CLANG9_IA32_DLINK2_FLAGS =3D + +NOOPT_CLANG9_IA32_CC_FLAGS =3D DEF(CLANG9_ALL_CC_FLAGS) -m32 -O0 -= march=3Di586 DEF(CLANG9_IA32_TARGET) -gcodeview +NOOPT_CLANG9_IA32_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001 = /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_S= ERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /lldmap +NOOPT_CLANG9_IA32_DLINK2_FLAGS =3D + +########################## +# CLANGWIN X64 definitions +########################## +*_CLANG9_X64_CC_PATH =3D DEF(CLANG9_X64_PREFIX)clang +*_CLANG9_X64_SLINK_PATH =3D DEF(CLANG9_X64_PREFIX)llvm-lib +*_CLANG9_X64_DLINK_PATH =3D DEF(CLANG9_X64_PREFIX)lld-link +*_CLANG9_X64_ASLDLINK_PATH =3D DEF(CLANG9_X64_PREFIX)lld-link +*_CLANG9_X64_ASM_PATH =3D DEF(CLANG9_X64_PREFIX)clang +*_CLANG9_X64_PP_PATH =3D DEF(CLANG9_X64_PREFIX)clang +*_CLANG9_X64_VFRPP_PATH =3D DEF(CLANG9_X64_PREFIX)clang +*_CLANG9_X64_ASLCC_PATH =3D DEF(CLANG9_X64_PREFIX)clang +*_CLANG9_X64_ASLPP_PATH =3D DEF(CLANG9_X64_PREFIX)clang +*_CLANG9_X64_RC_PATH =3D DEF(CLANG9_IA32_PREFIX)llvm-rc + +*_CLANG9_X64_ASLCC_FLAGS =3D DEF(GCC_ASLCC_FLAGS) -m64 -fno-lto D= EF(CLANG9_X64_TARGET) +*_CLANG9_X64_ASM_FLAGS =3D DEF(GCC5_ASM_FLAGS) -m64 DEF(CLANG9_= X64_TARGET) +*_CLANG9_X64_OBJCOPY_FLAGS =3D +*_CLANG9_X64_NASM_FLAGS =3D -f win64 +*_CLANG9_X64_PP_FLAGS =3D DEF(GCC_PP_FLAGS) DEF(CLANG9_X64_TAR= GET) +*_CLANG9_X64_ASLPP_FLAGS =3D DEF(GCC_ASLPP_FLAGS) DEF(CLANG9_X64_= TARGET) +*_CLANG9_X64_VFRPP_FLAGS =3D DEF(GCC_VFRPP_FLAGS) DEF(CLANG9_X64_= TARGET) + +DEBUG_CLANG9_X64_CC_FLAGS =3D DEF(CLANG9_ALL_CC_FLAGS) -m64 "-DEFI= API=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -Oz -flto DEF= (CLANG9_X64_TARGET) -gcodeview +DEBUG_CLANG9_X64_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001 /= OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.p= data,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SE= RVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /lldmap +DEBUG_CLANG9_X64_DLINK2_FLAGS =3D + +RELEASE_CLANG9_X64_CC_FLAGS =3D DEF(CLANG9_ALL_CC_FLAGS) -m64 "-DEFI= API=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -Oz -flto DEF= (CLANG9_X64_TARGET) +RELEASE_CLANG9_X64_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001 /= IGNORE:4254 /OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,= D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTE= M:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=3D.data /lldma= p +RELEASE_CLANG9_X64_DLINK2_FLAGS =3D + +NOOPT_CLANG9_X64_CC_FLAGS =3D DEF(CLANG9_ALL_CC_FLAGS) -m64 "-DEFI= API=3D__attribute__((ms_abi))" -mno-red-zone -mcmodel=3Dsmall -O0 DEF(CLANG= 9_X64_TARGET) -gcodeview +NOOPT_CLANG9_X64_DLINK_FLAGS =3D /NOLOGO /NODEFAULTLIB /IGNORE:4001 /= OPT:REF /OPT:ICF=3D10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.p= data,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SE= RVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /lldmap +NOOPT_CLANG9_X64_DLINK2_FLAGS =3D =20 =20 # -- 2.13.0.windows.1