From: "Ni, Ray" <ray.ni@intel.com>
To: devel@edk2.groups.io
Cc: Liming Gao <gaoliming@byosoft.com.cn>, Feng Bob C <bob.c.feng@intel.com>
Subject: [PATCH v2 4/6] BaseTools: Add new CLANG8ELF tool chain for new LLVM/CLANG8
Date: Wed, 2 Jun 2021 16:11:43 +0800 [thread overview]
Message-ID: <20210602081145.265-5-ray.ni@intel.com> (raw)
In-Reply-To: <20210602081145.265-1-ray.ni@intel.com>
From: Liming Gao <gaoliming@byosoft.com.cn>
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1603
LLVM/CLANG8 formal release http://releases.llvm.org/download.html#8.0.0
It can be downloaded and installed in Windows/Linux/Mac OS.
CLANG8ELF tool chain is added to generate ELF image, and convert to PE/COFF.
On Windows OS, set CLANG_HOST_BIN=n, set CLANG8_BIN=LLVM installed directory
For example:
set CLANG_HOST_BIN=n # use windows nmake
set CLANG8_BIN=C:\Program Files\LLVM\bin\
On Linux/Mac, set CLANG8_BIN=LLVM installed directory
This tool chain can be used to compile the firmware code. On windows OS,
Visual Studio is still required to compile BaseTools C tools and nmake.exe.
On Linux/Mac OS, gcc is used to compile BaseTools C tools. make is used
for makefile.
This tool chain is verified on OVMF Ia32, X64 and Ia32X64 to boot Shell.
This tool chain is verified in Windows/Linux and Mac OS.
Signed-off-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Feng Bob C <bob.c.feng@intel.com>
---
BaseTools/Conf/tools_def.template | 102 ++++++++++++++++++++++++++++++
1 file changed, 102 insertions(+)
diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 498696e583..c8ef1a1421 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -292,6 +292,10 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc
# Required to compile nasm source:
# nasm compiler from
# NASM -- http://www.nasm.us/
+# CLANG8ELF -Linux,Windows,Mac- Requires:
+# LLVM 8.0.0 or above, https://llvm.org/
+# On Windows OS, Visual Studio is required to be installed for nmake and compile BaseTools C tools.
+# Optional:
# Required to build platforms or ACPI tables:
# Intel(r) ACPI Compiler from
# https://acpica.org/downloads
@@ -2828,6 +2832,104 @@ NOOPT_CLANGPDB_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:RE
NOOPT_CLANGPDB_X64_DLINK2_FLAGS =
NOOPT_CLANGPDB_X64_GENFW_FLAGS = --keepexceptiontable
+# Clang 8.0.0 - This configuration is used to compile under Windows, Linux, Mac to
+# produce ELF image, and convert to PE/COFF image using LLVM/CLANG 8.0 with LTO
+#
+####################################################################################
+*_CLANG8ELF_*_*_FAMILY = GCC
+*_CLANG8ELF_*_*_BUILDRULEFAMILY = CLANGGCC
+*_CLANG8ELF_*_MAKE_PATH = ENV(CLANG_HOST_BIN)make
+*_CLANG8ELF_*_*_DLL = ENV(CLANG8_DLL)
+*_CLANG8ELF_*_ASL_PATH = DEF(UNIX_IASL_BIN)
+
+*_CLANG8ELF_*_APP_FLAGS =
+*_CLANG8ELF_*_ASL_FLAGS = DEF(IASL_FLAGS)
+*_CLANG8ELF_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
+
+DEFINE CLANG8ELF_IA32_PREFIX = ENV(CLANG8_BIN)
+DEFINE CLANG8ELF_X64_PREFIX = ENV(CLANG8_BIN)
+
+# LLVM/CLANG doesn't support -n link option. So, it can't share the same IA32_X64_DLINK_COMMON flag.
+# LLVM/CLANG doesn't support common page size. So, it can't share the same GccBase.lds script.
+DEFINE CLANG8ELF_IA32_X64_DLINK_COMMON = -nostdlib -Wl,-q,--gc-sections -z max-page-size=0x40
+DEFINE CLANG8ELF_DLINK2_FLAGS_COMMON = -Wl,--script=$(EDK_TOOLS_PATH)/Scripts/ClangBase.lds
+DEFINE CLANG8ELF_IA32_X64_ASLDLINK_FLAGS = DEF(CLANG8ELF_IA32_X64_DLINK_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0 DEF(CLANG8ELF_DLINK2_FLAGS_COMMON) -Wl,--entry,ReferenceAcpiTable -u ReferenceAcpiTable
+DEFINE CLANG8ELF_IA32_X64_DLINK_FLAGS = DEF(CLANG8ELF_IA32_X64_DLINK_COMMON) -Wl,--entry,$(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Wl,-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map,--whole-archive
+DEFINE CLANG8ELF_IA32_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x220 DEF(CLANG8ELF_DLINK2_FLAGS_COMMON)
+DEFINE CLANG8ELF_X64_DLINK2_FLAGS = -Wl,--defsym=PECOFF_HEADER_SIZE=0x228 DEF(CLANG8ELF_DLINK2_FLAGS_COMMON)
+
+###########################
+# CLANG8ELF IA32 definitions
+###########################
+*_CLANG8ELF_IA32_CC_PATH = DEF(CLANG8ELF_IA32_PREFIX)clang
+*_CLANG8ELF_IA32_SLINK_PATH = DEF(CLANG8ELF_IA32_PREFIX)llvm-ar
+*_CLANG8ELF_IA32_DLINK_PATH = DEF(CLANG8ELF_IA32_PREFIX)clang
+*_CLANG8ELF_IA32_ASLDLINK_PATH = DEF(CLANG8ELF_IA32_PREFIX)clang
+*_CLANG8ELF_IA32_ASM_PATH = DEF(CLANG8ELF_IA32_PREFIX)clang
+*_CLANG8ELF_IA32_PP_PATH = DEF(CLANG8ELF_IA32_PREFIX)clang
+*_CLANG8ELF_IA32_VFRPP_PATH = DEF(CLANG8ELF_IA32_PREFIX)clang
+*_CLANG8ELF_IA32_ASLCC_PATH = DEF(CLANG8ELF_IA32_PREFIX)clang
+*_CLANG8ELF_IA32_ASLPP_PATH = DEF(CLANG8ELF_IA32_PREFIX)clang
+*_CLANG8ELF_IA32_RC_PATH = DEF(CLANG8ELF_IA32_PREFIX)llvm-rc
+
+*_CLANG8ELF_IA32_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m32 -fno-lto DEF(CLANG38_IA32_TARGET)
+*_CLANG8ELF_IA32_ASLDLINK_FLAGS = DEF(CLANG8ELF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386 -fuse-ld=lld
+*_CLANG8ELF_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386 DEF(CLANG38_IA32_TARGET)
+*_CLANG8ELF_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
+*_CLANG8ELF_IA32_OBJCOPY_FLAGS =
+*_CLANG8ELF_IA32_NASM_FLAGS = -f elf32
+*_CLANG8ELF_IA32_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG38_IA32_TARGET)
+*_CLANG8ELF_IA32_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_IA32_TARGET)
+*_CLANG8ELF_IA32_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_IA32_TARGET)
+
+DEBUG_CLANG8ELF_IA32_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANG38_IA32_TARGET) -g
+DEBUG_CLANG8ELF_IA32_DLINK_FLAGS = DEF(CLANG8ELF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_i386 -Wl,--oformat,elf32-i386
+DEBUG_CLANG8ELF_IA32_DLINK2_FLAGS = DEF(CLANG8ELF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld
+
+RELEASE_CLANG8ELF_IA32_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANG38_IA32_TARGET)
+RELEASE_CLANG8ELF_IA32_DLINK_FLAGS = DEF(CLANG8ELF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_i386 -Wl,--oformat,elf32-i386
+RELEASE_CLANG8ELF_IA32_DLINK2_FLAGS = DEF(CLANG8ELF_IA32_DLINK2_FLAGS) -O3 -fuse-ld=lld
+
+NOOPT_CLANG8ELF_IA32_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m32 -O0 -march=i586 DEF(CLANG38_IA32_TARGET) -g
+NOOPT_CLANG8ELF_IA32_DLINK_FLAGS = DEF(CLANG8ELF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_i386 -Wl,--oformat,elf32-i386
+NOOPT_CLANG8ELF_IA32_DLINK2_FLAGS = DEF(CLANG8ELF_IA32_DLINK2_FLAGS) -O0 -fuse-ld=lld
+
+##########################
+# CLANG8ELF X64 definitions
+##########################
+*_CLANG8ELF_X64_CC_PATH = DEF(CLANG8ELF_X64_PREFIX)clang
+*_CLANG8ELF_X64_SLINK_PATH = DEF(CLANG8ELF_X64_PREFIX)llvm-ar
+*_CLANG8ELF_X64_DLINK_PATH = DEF(CLANG8ELF_X64_PREFIX)clang
+*_CLANG8ELF_X64_ASLDLINK_PATH = DEF(CLANG8ELF_X64_PREFIX)clang
+*_CLANG8ELF_X64_ASM_PATH = DEF(CLANG8ELF_X64_PREFIX)clang
+*_CLANG8ELF_X64_PP_PATH = DEF(CLANG8ELF_X64_PREFIX)clang
+*_CLANG8ELF_X64_VFRPP_PATH = DEF(CLANG8ELF_X64_PREFIX)clang
+*_CLANG8ELF_X64_ASLCC_PATH = DEF(CLANG8ELF_X64_PREFIX)clang
+*_CLANG8ELF_X64_ASLPP_PATH = DEF(CLANG8ELF_X64_PREFIX)clang
+*_CLANG8ELF_X64_RC_PATH = DEF(CLANG8ELF_X64_PREFIX)llvm-rc
+
+*_CLANG8ELF_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64 -fno-lto DEF(CLANG38_X64_TARGET)
+*_CLANG8ELF_X64_ASLDLINK_FLAGS = DEF(CLANG8ELF_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_x86_64 -fuse-ld=lld
+*_CLANG8ELF_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64 DEF(CLANG38_X64_TARGET)
+*_CLANG8ELF_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
+*_CLANG8ELF_X64_OBJCOPY_FLAGS =
+*_CLANG8ELF_X64_NASM_FLAGS = -f elf64
+*_CLANG8ELF_X64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG38_X64_TARGET)
+*_CLANG8ELF_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_X64_TARGET)
+*_CLANG8ELF_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_X64_TARGET)
+
+DEBUG_CLANG8ELF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET) -g
+DEBUG_CLANG8ELF_X64_DLINK_FLAGS = DEF(CLANG8ELF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
+DEBUG_CLANG8ELF_X64_DLINK2_FLAGS = DEF(CLANG8ELF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld
+
+RELEASE_CLANG8ELF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -Oz -flto DEF(CLANG38_X64_TARGET)
+RELEASE_CLANG8ELF_X64_DLINK_FLAGS = DEF(CLANG8ELF_IA32_X64_DLINK_FLAGS) -flto -Wl,-O3 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
+RELEASE_CLANG8ELF_X64_DLINK2_FLAGS = DEF(CLANG8ELF_X64_DLINK2_FLAGS) -O3 -fuse-ld=lld
+
+NOOPT_CLANG8ELF_X64_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -fpie -O0 DEF(CLANG38_X64_TARGET) -g
+NOOPT_CLANG8ELF_X64_DLINK_FLAGS = DEF(CLANG8ELF_IA32_X64_DLINK_FLAGS) -Wl,-O0 -Wl,-melf_x86_64 -Wl,--oformat,elf64-x86-64 -Wl,-pie -mcmodel=small -Wl,--apply-dynamic-relocs
+NOOPT_CLANG8ELF_X64_DLINK2_FLAGS = DEF(CLANG8ELF_X64_DLINK2_FLAGS) -O0 -fuse-ld=lld
+
#
#
# XCODE5 support
--
2.31.1.windows.1
next prev parent reply other threads:[~2021-06-02 8:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-02 8:11 [PATCH v2 0/6] Add CLANGDWARF toolchain for universal payload needs Ni, Ray
2021-06-02 8:11 ` [PATCH v2 1/6] BaseTools: Add ClangBase.lds for CLANG8 tool chain with max-page-size Ni, Ray
2021-06-02 8:11 ` [PATCH v2 2/6] BaseTools GenFw: Support CLANG8ELF with conversion ELF to PE/COFF image Ni, Ray
2021-06-04 13:31 ` [edk2-devel] " Leif Lindholm
2021-06-05 0:07 ` Ni, Ray
2021-06-05 1:19 ` Ni, Ray
2021-06-05 1:35 ` 回复: " gaoliming
2021-06-02 8:11 ` [PATCH v2 3/6] BaseTools: Update build_rule to skip CLANG resource section generation Ni, Ray
2021-06-02 8:11 ` Ni, Ray [this message]
2021-06-02 8:11 ` [PATCH v2 5/6] BaseTools: Update ClangBase.lds to keep dynamic section Ni, Ray
2021-06-02 8:11 ` [PATCH v2 6/6] BaseTools: Change CLANG8ELF to CLANGDWARF Ni, Ray
2021-06-04 5:42 ` 回复: [edk2-devel] [PATCH v2 0/6] Add CLANGDWARF toolchain for universal payload needs gaoliming
2021-06-04 8:57 ` Bob Feng
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=20210602081145.265-5-ray.ni@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