From: "Liming Gao" <liming.gao@intel.com>
To: devel@edk2.groups.io
Subject: [Patch v2 02/11] BaseTools tools_def: Add CLANG9 tool chain to directly generate PE image
Date: Tue, 15 Oct 2019 08:26:41 +0800 [thread overview]
Message-ID: <1571099210-12432-3-git-send-email-liming.gao@intel.com> (raw)
In-Reply-To: <1571099210-12432-1-git-send-email-liming.gao@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
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 @@
<OutputFile>
$(OUTPUT_DIR)(+)$(MODULE_NAME).lib
- <Command.MSFT, Command.INTEL>
+ <Command.MSFT, Command.INTEL, Command.CLANGPE>
"$(SLINK)" $(SLINK_FLAGS) /OUT:${dst} @$(OBJECT_FILES_LIST)
<Command.GCC>
@@ -291,6 +291,9 @@
"$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK2_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST)
"$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST)
+ <Command.CLANGPE>
+ "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
+
<Command.GCC>
"$(DLINK)" -o ${dst} $(DLINK_FLAGS) -Wl,--start-group,@$(STATIC_LIBRARY_FILES_LIST),--end-group $(CC_FLAGS) $(DLINK2_FLAGS)
"$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
@@ -331,7 +334,7 @@
<OutputFile>
$(DEBUG_DIR)(+)$(MODULE_NAME)
- <Command.MSFT, Command.INTEL>
+ <Command.MSFT, Command.INTEL, Command.CLANGPE>
"$(DLINK)" $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST)
<Command.GCC>
@@ -355,7 +358,7 @@
<OutputFile>
$(OUTPUT_DIR)(+)$(MODULE_NAME).efi
- <Command.MSFT, Command.INTEL, Command.RVCT>
+ <Command.MSFT, Command.INTEL, Command.RVCT, Command.CLANGPE>
"$(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 @@
<Command.GCC>
"$(ASLCC)" -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src}
- "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+ "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS)
"$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
-
+
+ <Command.CLANGPE>
+ "$(ASLCC)" -c -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src}
+ "$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+ "$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
+
<Command.XCODE>
"$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(INC) ${src}
"$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
@@ -622,21 +630,19 @@
<InputFile>
*.hpk
- <OutputFile.MSFT, OutputFile.INTEL, OutputFile.GCC>
+ <OutputFile.MSFT, OutputFile.INTEL, OutputFile.GCC, OutputFile.CLANGPE>
$(OUTPUT_DIR)(+)$(MODULE_NAME)hii.lib
<OutputFile.XCODE, OutputFile.RVCT>
$(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
- <Command.MSFT, Command.INTEL>
+ <Command.MSFT, Command.INTEL, Command.CLANGPE>
"$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiipackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
"$(RC)" /Fo${dst} $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
<Command.GCC>
"$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
"$(RC)" $(RC_FLAGS) $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc ${dst}
-
+
<Command.XCODE, Command.RVCT>
GenFw -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES)
-
-
diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index fd6fca542d..e009f195b9 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -268,6 +268,15 @@ DEFINE DTC_BIN = 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.org/
+# 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 Development Kit (Microsoft WINDDK) version 3790.1830
@@ -2698,6 +2707,99 @@ DEFINE CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH6
RELEASE_CLANG38_AARCH64_CC_FLAGS = DEF(CLANG38_AARCH64_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -flto -O3
RELEASE_CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_DLINK_FLAGS) -flto -Wl,-O3 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64
+####################################################################################
+#
+# CLANG9 - This configuration is used to compile under Windows/Linux/Mac to produce
+# PE/COFF binaries using LLVM/Clang/LLD with Link Time Optimization enabled
+#
+####################################################################################
+*_CLANG9_*_*_FAMILY = GCC
+*_CLANG9_*_*_BUILDRULEFAMILY = CLANGPE
+*_CLANG9_*_MAKE_PATH = ENV(CLANG_HOST_BIN)make
+*_CLANG9_*_*_DLL = ENV(CLANG9_DLL)
+*_CLANG9_*_ASL_PATH = DEF(UNIX_IASL_BIN)
+
+*_CLANG9_*_APP_FLAGS =
+*_CLANG9_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_CLANG9_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_CLANG9_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+DEFINE CLANG9_IA32_PREFIX = ENV(CLANG9_BIN)
+DEFINE CLANG9_X64_PREFIX = ENV(CLANG9_BIN)
+
+DEFINE CLANG9_IA32_TARGET = -target i686-unknown-windows
+DEFINE CLANG9_X64_TARGET = -target x86_64-unknown-windows
+
+DEFINE CLANG9_WARNING_OVERRIDES = -Wno-parentheses-equality -Wno-tautological-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 = DEF(GCC48_ALL_CC_FLAGS) DEF(CLANG9_WARNING_OVERRIDES) -fno-stack-protector -mms-bitfields -Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas -Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables -mno-implicit-float -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference -fms-compatibility -mno-stack-arg-probe
+
+###########################
+# CLANG9 IA32 definitions
+###########################
+*_CLANG9_IA32_CC_PATH = DEF(CLANG9_IA32_PREFIX)clang
+*_CLANG9_IA32_SLINK_PATH = DEF(CLANG9_IA32_PREFIX)llvm-lib
+*_CLANG9_IA32_DLINK_PATH = DEF(CLANG9_IA32_PREFIX)lld-link
+*_CLANG9_IA32_ASLDLINK_PATH = DEF(CLANG9_IA32_PREFIX)lld-link
+*_CLANG9_IA32_ASM_PATH = DEF(CLANG9_IA32_PREFIX)clang
+*_CLANG9_IA32_PP_PATH = DEF(CLANG9_IA32_PREFIX)clang
+*_CLANG9_IA32_VFRPP_PATH = DEF(CLANG9_IA32_PREFIX)clang
+*_CLANG9_IA32_ASLCC_PATH = DEF(CLANG9_IA32_PREFIX)clang
+*_CLANG9_IA32_ASLPP_PATH = DEF(CLANG9_IA32_PREFIX)clang
+*_CLANG9_IA32_RC_PATH = DEF(CLANG9_IA32_PREFIX)llvm-rc
+
+*_CLANG9_IA32_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m32 -fno-lto DEF(CLANG9_IA32_TARGET)
+*_CLANG9_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386 DEF(CLANG9_IA32_TARGET)
+*_CLANG9_IA32_OBJCOPY_FLAGS =
+*_CLANG9_IA32_NASM_FLAGS = -f win32
+*_CLANG9_IA32_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG9_IA32_TARGET)
+*_CLANG9_IA32_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG9_IA32_TARGET)
+*_CLANG9_IA32_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG9_IA32_TARGET)
+
+DEBUG_CLANG9_IA32_CC_FLAGS = DEF(CLANG9_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANG9_IA32_TARGET) -gcodeview
+DEBUG_CLANG9_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /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
+DEBUG_CLANG9_IA32_DLINK2_FLAGS =
+
+RELEASE_CLANG9_IA32_CC_FLAGS = DEF(CLANG9_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANG9_IA32_TARGET)
+RELEASE_CLANG9_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /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 /MERGE:.rdata=.data /lldmap
+RELEASE_CLANG9_IA32_DLINK2_FLAGS =
+
+NOOPT_CLANG9_IA32_CC_FLAGS = DEF(CLANG9_ALL_CC_FLAGS) -m32 -O0 -march=i586 DEF(CLANG9_IA32_TARGET) -gcodeview
+NOOPT_CLANG9_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /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
+NOOPT_CLANG9_IA32_DLINK2_FLAGS =
+
+##########################
+# CLANGWIN X64 definitions
+##########################
+*_CLANG9_X64_CC_PATH = DEF(CLANG9_X64_PREFIX)clang
+*_CLANG9_X64_SLINK_PATH = DEF(CLANG9_X64_PREFIX)llvm-lib
+*_CLANG9_X64_DLINK_PATH = DEF(CLANG9_X64_PREFIX)lld-link
+*_CLANG9_X64_ASLDLINK_PATH = DEF(CLANG9_X64_PREFIX)lld-link
+*_CLANG9_X64_ASM_PATH = DEF(CLANG9_X64_PREFIX)clang
+*_CLANG9_X64_PP_PATH = DEF(CLANG9_X64_PREFIX)clang
+*_CLANG9_X64_VFRPP_PATH = DEF(CLANG9_X64_PREFIX)clang
+*_CLANG9_X64_ASLCC_PATH = DEF(CLANG9_X64_PREFIX)clang
+*_CLANG9_X64_ASLPP_PATH = DEF(CLANG9_X64_PREFIX)clang
+*_CLANG9_X64_RC_PATH = DEF(CLANG9_IA32_PREFIX)llvm-rc
+
+*_CLANG9_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64 -fno-lto DEF(CLANG9_X64_TARGET)
+*_CLANG9_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64 DEF(CLANG9_X64_TARGET)
+*_CLANG9_X64_OBJCOPY_FLAGS =
+*_CLANG9_X64_NASM_FLAGS = -f win64
+*_CLANG9_X64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG9_X64_TARGET)
+*_CLANG9_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG9_X64_TARGET)
+*_CLANG9_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG9_X64_TARGET)
+
+DEBUG_CLANG9_X64_CC_FLAGS = DEF(CLANG9_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANG9_X64_TARGET) -gcodeview
+DEBUG_CLANG9_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /lldmap
+DEBUG_CLANG9_X64_DLINK2_FLAGS =
+
+RELEASE_CLANG9_X64_CC_FLAGS = DEF(CLANG9_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANG9_X64_TARGET)
+RELEASE_CLANG9_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /MERGE:.rdata=.data /lldmap
+RELEASE_CLANG9_X64_DLINK2_FLAGS =
+
+NOOPT_CLANG9_X64_CC_FLAGS = DEF(CLANG9_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0 DEF(CLANG9_X64_TARGET) -gcodeview
+NOOPT_CLANG9_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /ALIGN:32 /FILEALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DEBUG:GHASH /lldmap
+NOOPT_CLANG9_X64_DLINK2_FLAGS =
#
--
2.13.0.windows.1
next prev parent reply other threads:[~2019-10-15 0:27 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-15 0:26 [Patch v2 00/11] New Cross OS tool chain CLANG9 Liming Gao
2019-10-15 0:26 ` [Patch v2 01/11] BaseTools tools_def.template: Remove unnecessary $(DEST_DIR_DEBUG) path Liming Gao
2019-10-16 8:59 ` [edk2-devel] " Bob Feng
2019-10-15 0:26 ` Liming Gao [this message]
2019-10-15 0:26 ` [Patch v2 03/11] BaseTools GenFw: Fix the issue to update the wrong size as SectionSize Liming Gao
2019-10-15 9:21 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-10-16 9:27 ` Bob Feng
2019-10-17 2:18 ` Liming Gao
2019-10-15 0:26 ` [Patch v2 04/11] MdePkg Base.h: Add definition for CLANG9 tool chain Liming Gao
2019-10-15 9:32 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-10-15 0:26 ` [Patch v2 05/11] MdePkg BaseIoLibIntrinsic: Remove __inline__ attribute for IO functions Liming Gao
2019-10-15 9:26 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-10-22 1:42 ` Michael D Kinney
2019-10-15 0:26 ` [Patch v2 06/11] MdeModulePkg LzmaCustomDecompressLib: Update macro to be same in CLANG tool Liming Gao
2019-10-16 2:05 ` [edk2-devel] " Wu, Hao A
2019-10-15 0:26 ` [Patch v2 07/11] MdeModulePkg RegularExpressionDxe: Disable warning for CLANG9 tool chain Liming Gao
2019-10-16 2:06 ` [edk2-devel] " Wu, Hao A
2019-10-15 0:26 ` [Patch v2 08/11] CryptoPkg: Append options to make CLANG9 tool chain pass build Liming Gao
2019-10-15 9:29 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-10-16 1:12 ` Wang, Jian J
2019-10-15 0:26 ` [Patch v2 09/11] CryptoPkg IntrinsicLib: Make _fltused always be used Liming Gao
2019-10-15 9:30 ` [edk2-devel] " Philippe Mathieu-Daudé
2019-10-16 1:10 ` Wang, Jian J
2019-10-15 0:26 ` [Patch v2 10/11] EmulatorPkg: Enable CLANG9 tool chain Liming Gao
2019-10-16 9:32 ` [edk2-devel] " Ni, Ray
2019-10-17 3:31 ` Liming Gao
2019-10-17 5:21 ` Ni, Ray
2019-10-15 0:26 ` [Patch v2 11/11] OvmfPkg: " Liming Gao
2019-10-15 7:36 ` [edk2-devel] [Patch v2 00/11] New Cross OS tool chain CLANG9 Laszlo Ersek
2019-10-16 0:55 ` Liming Gao
2019-10-16 9:19 ` Bob Feng
2019-10-17 2:15 ` Liming Gao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1571099210-12432-3-git-send-email-liming.gao@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox