From e56ce7a02b7b0b9bb53a4ff3bf98ea3254e49c82 Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 10:04:27 +0800 Subject: [PATCH 01/13] BaseTools tools_def.template: Remove unnecessary $(DEST_DIR_DEBUG) path $(DEST_DIR_DEBUG) path is in Include directory. It is not required to be specified again. Signed-off-by: Liming Gao --- BaseTools/Conf/tools_def.template | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template index 8f0e6cb6c2cb..fda7806707d2 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -331,8 +331,8 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc # *_*_EBC_SLINK_PATH = C:\Program Files\Intel\EBC\Bin\link.exe # # *_*_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC -# *_*_EBC_PP_FLAGS = /nologo /E /TC /FI$(DEST_DIR_DEBUG)/AutoGen.h -# *_*_EBC_CC_FLAGS = /nologo /FAcs /c /W3 /WX /FI$(DEST_DIR_DEBUG)/AutoGen.h +# *_*_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h +# *_*_EBC_CC_FLAGS = /nologo /FAcs /c /W3 /WX /FIAutoGen.h # *_*_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /MACHINE:EBC /OPT:REF /NODEFAULTLIB /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /ALIGN:32 /DRIVER # #################################################################################### @@ -1724,13 +1724,13 @@ DEFINE GCC_IA32_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _Ref DEFINE GCC_ARM_ASLDLINK_FLAGS = DEF(GCC_ARM_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS) DEFINE GCC_AARCH64_ASLDLINK_FLAGS = DEF(GCC_AARCH64_DLINK_FLAGS) -Wl,--entry,ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT) DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS) DEFINE GCC_IA32_X64_DLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _$(IMAGE_ENTRY_POINT) --file-alignment 0x20 --section-alignment 0x20 -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map -DEFINE GCC_ASM_FLAGS = -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h -DEFINE GCC_PP_FLAGS = -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h -DEFINE GCC_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h +DEFINE GCC_ASM_FLAGS = -c -x assembler -imacros AutoGen.h +DEFINE GCC_PP_FLAGS = -E -x assembler-with-cpp -include AutoGen.h +DEFINE GCC_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include $(MODULE_NAME)StrDefs.h DEFINE GCC_ASLPP_FLAGS = -x c -E -include AutoGen.h DEFINE GCC_ASLCC_FLAGS = -x c DEFINE GCC_WINDRES_FLAGS = -J rc -O coff -DEFINE GCC_DTCPP_FLAGS = -E -x assembler-with-cpp -imacros $(DEST_DIR_DEBUG)/AutoGen.h -nostdinc -undef +DEFINE GCC_DTCPP_FLAGS = -E -x assembler-with-cpp -imacros AutoGen.h -nostdinc -undef DEFINE GCC_IA32_RC_FLAGS = -I binary -O elf32-i386 -B i386 --rename-section .data=.hii DEFINE GCC_X64_RC_FLAGS = -I binary -O elf64-x86-64 -B i386 --rename-section .data=.hii DEFINE GCC_ARM_RC_FLAGS = -I binary -O elf32-littlearm -B arm --rename-section .data=.hii @@ -2590,8 +2590,8 @@ RELEASE_XCODE5_X64_DLINK_FLAGS = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _ NOOPT_XCODE5_X64_ASM_FLAGS = -arch x86_64 -g RELEASE_XCODE5_X64_ASM_FLAGS = -arch x86_64 *_XCODE5_X64_NASM_FLAGS = -f macho64 -*_XCODE5_*_PP_FLAGS = -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h -*_XCODE5_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE -include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h +*_XCODE5_*_PP_FLAGS = -E -x assembler-with-cpp -include AutoGen.h +*_XCODE5_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE -include $(MODULE_NAME)StrDefs.h DEBUG_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -gdwarf -Os -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS) NOOPT_XCODE5_X64_CC_FLAGS = -target x86_64-pc-win32-macho -c -g -gdwarf -O0 -Wall -Werror -Wextra -include AutoGen.h -funsigned-char -fno-ms-extensions -fno-stack-protector -fno-builtin -fshort-wchar -mno-implicit-float -mms-bitfields -Wno-unused-parameter -Wno-missing-braces -Wno-missing-field-initializers -Wno-tautological-compare -Wno-sign-compare -Wno-varargs -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -D NO_MSABI_VA_FUNCS $(PLATFORM_FLAGS) @@ -2630,7 +2630,7 @@ RELEASE_RVCT_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) DEF(RVCT_ALL_DLINK_FLAGS) *_RVCT_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_ASM_FLAGS) *_RVCT_ARM_PP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E --preinclude AutoGen.h -*_RVCT_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h +*_RVCT_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude $(MODULE_NAME)StrDefs.h *_RVCT_ARM_MAKE_PATH = nmake /NOLOGO *_RVCT_ARM_SLINK_FLAGS = --partial -o DEBUG_RVCT_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_CC_FLAGS) -O1 -g @@ -2671,7 +2671,7 @@ RELEASE_RVCTLINUX_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) DEF(RVCT_ALL_DLINK_FLAG *_RVCTLINUX_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_ASM_FLAGS) *_RVCTLINUX_ARM_PP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -*_RVCTLINUX_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h +*_RVCTLINUX_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude $(MODULE_NAME)StrDefs.h *_RVCTLINUX_ARM_SLINK_FLAGS = --partial -o DEBUG_RVCTLINUX_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_CC_FLAGS) -O1 -g RELEASE_RVCTLINUX_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) --diag_suppress=550 DEF(RVCT_ALL_CC_FLAGS) -O2 @@ -2718,7 +2718,7 @@ RELEASE_RVCTCYGWIN_ARM_DLINK_FLAGS = "$(DLINKPATH_FLAG)" $(ARCHDLINK_FLAGS) *_RVCTCYGWIN_ARM_ASM_FLAGS = "$(ASMPATH_FLAG)" $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_ASM_FLAGS) *_RVCTCYGWIN_ARM_PP_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -*_RVCTCYGWIN_ARM_VFRPP_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude `cygpath -m $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h` +*_RVCTCYGWIN_ARM_VFRPP_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude `cygpath -m $(MODULE_NAME)StrDefs.h` *_RVCTCYGWIN_ARM_MAKE_PATH = make *_RVCTCYGWIN_ARM_SLINK_FLAGS = "$(SLINKPATH_FLAG)" --partial -o DEBUG_RVCTCYGWIN_ARM_CC_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(RVCT_ALL_CC_FLAGS) -O1 -g From b1a07735e2b86704fb5ffd584077e6df00f2df34 Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 09:54:08 +0800 Subject: [PATCH 02/13] Add CLANG9PE tool chain to directly generate PE image Signed-off-by: Liming Gao --- BaseTools/Conf/build_rule.template | 22 +++++-- BaseTools/Conf/tools_def.template | 102 +++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+), 7 deletions(-) diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule.template index db06d3a6b45a..fb8a20f25acc 100755 --- a/BaseTools/Conf/build_rule.template +++ b/BaseTools/Conf/build_rule.template @@ -260,7 +260,7 @@ $(OUTPUT_DIR)(+)$(MODULE_NAME).lib - + "$(SLINK)" $(SLINK_FLAGS) /OUT:${dst} @$(OBJECT_FILES_LIST) @@ -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) + + "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS) + "$(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 @@ $(DEBUG_DIR)(+)$(MODULE_NAME) - + "$(DLINK)" $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) @@ -355,7 +358,7 @@ $(OUTPUT_DIR)(+)$(MODULE_NAME).efi - + "$(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 @@ "$(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) - + + + "$(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) + "$(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 @@ -628,7 +636,7 @@ $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc - + "$(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 @@ -636,7 +644,7 @@ "$(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} - + 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 fda7806707d2..e3f3c6bdcfe7 100755 --- a/BaseTools/Conf/tools_def.template +++ b/BaseTools/Conf/tools_def.template @@ -249,6 +249,15 @@ DEFINE DTC_BIN = ENV(DTC_PREFIX)dtc # Required to build platforms or ACPI tables: # Intel(r) ACPI Compiler from # https://acpica.org/downloads +# CLANG9PE -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 @@ -2516,6 +2525,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 PE - This configuration is used to compile under Windows/Linux/Mac to produce +# PE/COFF binaries using LLVM/Clang/LLD with Link Time Optimization enabled +# +#################################################################################### +*_CLANG9PE_*_*_FAMILY = GCC +*_CLANG9PE_*_*_BUILDRULEFAMILY = CLANGPE +*_CLANG9PE_*_MAKE_PATH = ENV(CLANG_HOST_BIN)make +*_CLANG9PE_*_*_DLL = ENV(CLANG9PE_DLL) +*_CLANG9PE_*_ASL_PATH = DEF(UNIX_IASL_BIN) + +*_CLANG9PE_*_APP_FLAGS = +*_CLANG9PE_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS) +*_CLANG9PE_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS) +*_CLANG9PE_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS) + +DEFINE CLANG9PE_IA32_PREFIX = ENV(CLANG9PE_BIN) +DEFINE CLANG9PE_X64_PREFIX = ENV(CLANG9PE_BIN) + +DEFINE CLANG9PE_IA32_TARGET = -target i686-unknown-windows +DEFINE CLANG9PE_X64_TARGET = -target x86_64-unknown-windows + +DEFINE CLANG9PE_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 CLANG9PE_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) DEF(CLANG9PE_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 + +########################### +# CLANG9PE IA32 definitions +########################### +*_CLANG9PE_IA32_CC_PATH = DEF(CLANG9PE_IA32_PREFIX)clang +*_CLANG9PE_IA32_SLINK_PATH = DEF(CLANG9PE_IA32_PREFIX)llvm-lib +*_CLANG9PE_IA32_DLINK_PATH = DEF(CLANG9PE_IA32_PREFIX)lld-link +*_CLANG9PE_IA32_ASLDLINK_PATH = DEF(CLANG9PE_IA32_PREFIX)lld-link +*_CLANG9PE_IA32_ASM_PATH = DEF(CLANG9PE_IA32_PREFIX)clang +*_CLANG9PE_IA32_PP_PATH = DEF(CLANG9PE_IA32_PREFIX)clang +*_CLANG9PE_IA32_VFRPP_PATH = DEF(CLANG9PE_IA32_PREFIX)clang +*_CLANG9PE_IA32_ASLCC_PATH = DEF(CLANG9PE_IA32_PREFIX)clang +*_CLANG9PE_IA32_ASLPP_PATH = DEF(CLANG9PE_IA32_PREFIX)clang +*_CLANG9PE_IA32_RC_PATH = DEF(CLANG9PE_IA32_PREFIX)llvm-rc + +*_CLANG9PE_IA32_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m32 -fno-lto DEF(CLANG9PE_IA32_TARGET) +*_CLANG9PE_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386 DEF(CLANG9PE_IA32_TARGET) +*_CLANG9PE_IA32_OBJCOPY_FLAGS = +*_CLANG9PE_IA32_NASM_FLAGS = -f win32 +*_CLANG9PE_IA32_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG9PE_IA32_TARGET) +*_CLANG9PE_IA32_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG9PE_IA32_TARGET) +*_CLANG9PE_IA32_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG9PE_IA32_TARGET) + +DEBUG_CLANG9PE_IA32_CC_FLAGS = DEF(CLANG9PE_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANG9PE_IA32_TARGET) -gcodeview +DEBUG_CLANG9PE_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_CLANG9PE_IA32_DLINK2_FLAGS = + +RELEASE_CLANG9PE_IA32_CC_FLAGS = DEF(CLANG9PE_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANG9PE_IA32_TARGET) +RELEASE_CLANG9PE_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_CLANG9PE_IA32_DLINK2_FLAGS = + +NOOPT_CLANG9PE_IA32_CC_FLAGS = DEF(CLANG9PE_ALL_CC_FLAGS) -m32 -O0 -march=i586 DEF(CLANG9PE_IA32_TARGET) -gcodeview +NOOPT_CLANG9PE_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_CLANG9PE_IA32_DLINK2_FLAGS = + +########################## +# CLANGWIN X64 definitions +########################## +*_CLANG9PE_X64_CC_PATH = DEF(CLANG9PE_X64_PREFIX)clang +*_CLANG9PE_X64_SLINK_PATH = DEF(CLANG9PE_X64_PREFIX)llvm-lib +*_CLANG9PE_X64_DLINK_PATH = DEF(CLANG9PE_X64_PREFIX)lld-link +*_CLANG9PE_X64_ASLDLINK_PATH = DEF(CLANG9PE_X64_PREFIX)lld-link +*_CLANG9PE_X64_ASM_PATH = DEF(CLANG9PE_X64_PREFIX)clang +*_CLANG9PE_X64_PP_PATH = DEF(CLANG9PE_X64_PREFIX)clang +*_CLANG9PE_X64_VFRPP_PATH = DEF(CLANG9PE_X64_PREFIX)clang +*_CLANG9PE_X64_ASLCC_PATH = DEF(CLANG9PE_X64_PREFIX)clang +*_CLANG9PE_X64_ASLPP_PATH = DEF(CLANG9PE_X64_PREFIX)clang +*_CLANG9PE_X64_RC_PATH = DEF(CLANG9PE_IA32_PREFIX)llvm-rc + +*_CLANG9PE_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64 -fno-lto DEF(CLANG9PE_X64_TARGET) +*_CLANG9PE_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64 DEF(CLANG9PE_X64_TARGET) +*_CLANG9PE_X64_OBJCOPY_FLAGS = +*_CLANG9PE_X64_NASM_FLAGS = -f win64 +*_CLANG9PE_X64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG9PE_X64_TARGET) +*_CLANG9PE_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG9PE_X64_TARGET) +*_CLANG9PE_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG9PE_X64_TARGET) + +DEBUG_CLANG9PE_X64_CC_FLAGS = DEF(CLANG9PE_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANG9PE_X64_TARGET) -gcodeview +DEBUG_CLANG9PE_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_CLANG9PE_X64_DLINK2_FLAGS = + +RELEASE_CLANG9PE_X64_CC_FLAGS = DEF(CLANG9PE_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -Oz -flto DEF(CLANG9PE_X64_TARGET) +RELEASE_CLANG9PE_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_CLANG9PE_X64_DLINK2_FLAGS = + +NOOPT_CLANG9PE_X64_CC_FLAGS = DEF(CLANG9PE_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -mno-red-zone -mcmodel=small -O0 DEF(CLANG9PE_X64_TARGET) -gcodeview +NOOPT_CLANG9PE_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_CLANG9PE_X64_DLINK2_FLAGS = # From e9dec70b475f62aaa851354942da788ea3132d81 Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 09:57:08 +0800 Subject: [PATCH 03/13] BaseTools GenFw: Fix the issue to update the wrong size as SectionSize Signed-off-by: Liming Gao --- BaseTools/Source/C/GenFw/GenFw.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/BaseTools/Source/C/GenFw/GenFw.c b/BaseTools/Source/C/GenFw/GenFw.c index c99782b78eca..d8d3360c2440 100644 --- a/BaseTools/Source/C/GenFw/GenFw.c +++ b/BaseTools/Source/C/GenFw/GenFw.c @@ -653,7 +653,11 @@ PeCoffConvertImageToXip ( // // Make the size of raw data in section header alignment. // - SectionHeader->SizeOfRawData = (SectionHeader->Misc.VirtualSize + PeHdr->Pe32.OptionalHeader.FileAlignment - 1) & (~(PeHdr->Pe32.OptionalHeader.FileAlignment - 1)); + SectionSize = (SectionHeader->Misc.VirtualSize + PeHdr->Pe32.OptionalHeader.FileAlignment - 1) & (~(PeHdr->Pe32.OptionalHeader.FileAlignment - 1)); + if (SectionSize < SectionHeader->SizeOfRawData) { + SectionHeader->SizeOfRawData = SectionSize; + } + SectionHeader->PointerToRawData = SectionHeader->VirtualAddress; } @@ -999,7 +1003,7 @@ Routine Description: CopyMem ( FileBuffer + SectionHeader->PointerToRawData, (VOID*) (UINTN) (ImageContext.ImageAddress + SectionHeader->VirtualAddress), - SectionHeader->SizeOfRawData + SectionHeader->SizeOfRawData < SectionHeader->Misc.VirtualSize ? SectionHeader->SizeOfRawData : SectionHeader->Misc.VirtualSize ); } From 05f5a37c1e7c65feba68e9e4fa0811e91d8c99a5 Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 09:58:28 +0800 Subject: [PATCH 04/13] MdePkg Base: Add definition for CLANG9PE tool chain CLANG9PE tool chain defines __clang__ macro only, doesn't define __GNUC__ macro. But, it uses some same definitions with GCC. So, update base definition for CLANG9PE tool chain. Signed-off-by: Liming Gao --- MdePkg/Include/Base.h | 6 +++--- MdePkg/Include/Ia32/ProcessorBind.h | 4 ++-- MdePkg/Include/X64/ProcessorBind.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index ce20b5f01dce..9498dfe0d9fe 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -673,9 +673,9 @@ typedef char* VA_LIST; #define VA_END(Marker) (Marker = (VA_LIST) 0) #define VA_COPY(Dest, Start) ((void)((Dest) = (Start))) -#elif defined(__GNUC__) +#elif defined(__GNUC__) || defined(__clang__) -#if defined(MDE_CPU_X64) && !defined(NO_MSABI_VA_FUNCS) +#if defined(MDE_CPU_X64) && !defined(NO_MSABI_VA_FUNCS) && !defined(__clang__) // // X64 only. Use MS ABI version of GCC built-in macros for variable argument lists. // @@ -1270,7 +1270,7 @@ typedef UINTN RETURN_STATUS; **/ #define RETURN_ADDRESS(L) ((L == 0) ? _ReturnAddress() : (VOID *) 0) -#elif defined(__GNUC__) +#elif defined (__GNUC__) || defined (__clang__) void * __builtin_return_address (unsigned int level); /** Get the return address of the calling function. diff --git a/MdePkg/Include/Ia32/ProcessorBind.h b/MdePkg/Include/Ia32/ProcessorBind.h index 497c58b33b73..fa4b7e8e98cb 100644 --- a/MdePkg/Include/Ia32/ProcessorBind.h +++ b/MdePkg/Include/Ia32/ProcessorBind.h @@ -281,7 +281,7 @@ typedef INT32 INTN; /// Microsoft* compiler specific method for EFIAPI calling convention. /// #define EFIAPI __cdecl -#elif defined(__GNUC__) +#elif defined(__GNUC__) || defined(__clang__) /// /// GCC specific method for EFIAPI calling convention. /// @@ -294,7 +294,7 @@ typedef INT32 INTN; #define EFIAPI #endif -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) /// /// For GNU assembly code, .global or .globl can declare global symbols. /// Define this macro to unify the usage. diff --git a/MdePkg/Include/X64/ProcessorBind.h b/MdePkg/Include/X64/ProcessorBind.h index 6f65acd60939..387e9c5c9c19 100644 --- a/MdePkg/Include/X64/ProcessorBind.h +++ b/MdePkg/Include/X64/ProcessorBind.h @@ -313,7 +313,7 @@ typedef INT64 INTN; #define EFIAPI #endif -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) /// /// For GNU assembly code, .global or .globl can declare global symbols. /// Define this macro to unify the usage. From 42ee1f8b25cb33ccb086a790ba0ca336c666cb5e Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 10:43:22 +0800 Subject: [PATCH 05/13] MdePkg BaseIoLibIntrinsic: Remove __inline__ attribute for IO functions __inline__ attribute will make the functions not be exposed as the library interface. It will cause CLANG9 compiler fail. Signed-off-by: Liming Gao --- MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c b/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c index 055f0a947ece..b3a1a2025663 100644 --- a/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c +++ b/MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c @@ -32,7 +32,6 @@ @return The value read. **/ -__inline__ UINT8 EFIAPI IoRead8 ( @@ -60,7 +59,6 @@ IoRead8 ( @return The value written the I/O port. **/ -__inline__ UINT8 EFIAPI IoWrite8 ( @@ -87,7 +85,6 @@ IoWrite8 ( @return The value read. **/ -__inline__ UINT16 EFIAPI IoRead16 ( @@ -117,7 +114,6 @@ IoRead16 ( @return The value written the I/O port. **/ -__inline__ UINT16 EFIAPI IoWrite16 ( @@ -145,7 +141,6 @@ IoWrite16 ( @return The value read. **/ -__inline__ UINT32 EFIAPI IoRead32 ( @@ -175,7 +170,6 @@ IoRead32 ( @return The value written the I/O port. **/ -__inline__ UINT32 EFIAPI IoWrite32 ( From 42f2b397b70b86fa29c970cf110c826fe8cadec2 Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 09:58:48 +0800 Subject: [PATCH 06/13] MdePkg DebugLib: Enable FILE NAME as DEBUG ASSERT for CLANG This change will make the generated image not include the absolute file path. If so, the generated image can be reproduced in the different root directory. Signed-off-by: Liming Gao --- MdePkg/Include/Library/DebugLib.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MdePkg/Include/Library/DebugLib.h b/MdePkg/Include/Library/DebugLib.h index f1d55cf62b0e..3c54e07ab6ae 100644 --- a/MdePkg/Include/Library/DebugLib.h +++ b/MdePkg/Include/Library/DebugLib.h @@ -289,8 +289,11 @@ DebugPrintLevelEnabled ( @param Expression Boolean expression that evaluated to FALSE **/ +#ifdef __clang__ +#define _ASSERT(Expression) DebugAssert (__FILE_NAME__, __LINE__, #Expression) +#else #define _ASSERT(Expression) DebugAssert (__FILE__, __LINE__, #Expression) - +#endif /** Internal worker macro that calls DebugPrint(). From 1208ed64c508a49a86e05251536870199204bbad Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 09:59:56 +0800 Subject: [PATCH 07/13] MdeModulePkg LzmaCustomDecompressLib: Update macro to be same in CLANG tool Define the same macro in the different OS. It can make CLANG generate the same image in the different host OS. Signed-off-by: Liming Gao --- MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h index a5fcb50baea3..3ce087ecf710 100644 --- a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h +++ b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/7zTypes.h @@ -118,7 +118,7 @@ typedef int Bool; #define MY_STD_CALL #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #if _MSC_VER >= 1300 #define MY_NO_INLINE __declspec(noinline) From b969c0e53605e912242aca4dda069f8a46ec7dda Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 14:41:40 +0800 Subject: [PATCH 08/13] MdeModulePkg RegularExpressionDxe: Disable warning for CLANG9PE tool chain Signed-off-by: Liming Gao --- .../Universal/RegularExpressionDxe/RegularExpressionDxe.inf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf index 883d5f112765..818f1f79b129 100644 --- a/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf +++ b/MdeModulePkg/Universal/RegularExpressionDxe/RegularExpressionDxe.inf @@ -107,6 +107,9 @@ # Oniguruma: tag_end in parse_callout_of_name GCC:*_*_*_CC_FLAGS = -Wno-error=maybe-uninitialized + # Oniguruma: implicit conversion from 'UINTN' (aka 'unsigned long long') to 'long' + GCC:*_CLANG9PE_*_CC_FLAGS = -Wno-error=constant-conversion + # Not add -Wno-error=maybe-uninitialized option for XCODE # XCODE doesn't know this option XCODE:*_*_*_CC_FLAGS = From 598e84df455fb9693e6b96f6b3716a7200dc5818 Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 10:12:20 +0800 Subject: [PATCH 09/13] CryptoPkg: Append options to make CLANG9PE tool chain pass build Disable warning reported from CLANG9. Signed-off-by: Liming Gao --- CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf | 1 + CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf | 1 + CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf | 1 + CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf | 1 + CryptoPkg/Library/OpensslLib/OpensslLib.inf | 1 + CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf | 1 + 6 files changed, 6 insertions(+) diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf index 8d4988e8c6b4..a9b3fc513c09 100644 --- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf +++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf @@ -101,5 +101,6 @@ GCC:*_CLANG35_*_CC_FLAGS = -std=c99 GCC:*_CLANG38_*_CC_FLAGS = -std=c99 + GCC:*_CLANG9PE_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types XCODE:*_*_*_CC_FLAGS = -std=c99 diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf index 3da8bd848017..11cfcbf726a3 100644 --- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf +++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf @@ -96,5 +96,6 @@ GCC:*_CLANG35_*_CC_FLAGS = -std=c99 GCC:*_CLANG38_*_CC_FLAGS = -std=c99 + GCC:*_CLANG9PE_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types XCODE:*_*_*_CC_FLAGS = -std=c99 diff --git a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf index 21a481eb7767..d1afd0ea6d1c 100644 --- a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf +++ b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf @@ -107,5 +107,6 @@ GCC:*_CLANG35_*_CC_FLAGS = -std=c99 GCC:*_CLANG38_*_CC_FLAGS = -std=c99 + GCC:*_CLANG9PE_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types XCODE:*_*_*_CC_FLAGS = -std=c99 diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf index 7c187e21b3b9..0eeefb75affe 100644 --- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf +++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf @@ -104,3 +104,4 @@ GCC:*_CLANG35_*_CC_FLAGS = -std=c99 GCC:*_CLANG38_*_CC_FLAGS = -std=c99 + GCC:*_CLANG9PE_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf b/CryptoPkg/Library/OpensslLib/OpensslLib.inf index 7432321fd431..9cb7e71a5b69 100644 --- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf +++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf @@ -662,6 +662,7 @@ GCC:*_*_AARCH64_CC_FLAGS = $(OPENSSL_FLAGS) -Wno-error=maybe-uninitialized -Wno-format -Wno-error=unused-but-set-variable GCC:*_CLANG35_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized GCC:*_CLANG38_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized + GCC:*_CLANG9PE_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized -Wno-error=incompatible-pointer-types -Wno-error=pointer-sign -Wno-error=implicit-function-declaration -Wno-error=ignored-pragma-optimize # suppress the following warnings in openssl so we don't break the build with warnings-as-errors: # 1295: Deprecated declaration - give arg types diff --git a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf index 8134b45eda25..ba0ca95d61e0 100644 --- a/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf +++ b/CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf @@ -610,6 +610,7 @@ GCC:*_*_AARCH64_CC_FLAGS = $(OPENSSL_FLAGS) -Wno-error=maybe-uninitialized -Wno-format -Wno-error=unused-but-set-variable GCC:*_CLANG35_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized GCC:*_CLANG38_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized + GCC:*_CLANG9PE_*_CC_FLAGS = -std=c99 -Wno-error=uninitialized -Wno-error=incompatible-pointer-types -Wno-error=pointer-sign -Wno-error=implicit-function-declaration -Wno-error=ignored-pragma-optimize # suppress the following warnings in openssl so we don't break the build with warnings-as-errors: # 1295: Deprecated declaration - give arg types From 2a0f6e5fb3d9ca45964f58c051326e4b8bcce7f8 Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 15:12:24 +0800 Subject: [PATCH 10/13] CryptoPkg IntrinsicLib: Make _fltused always be used With this change, global variable _fltused will not be removed by LTO Signed-off-by: Liming Gao --- CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c b/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c index 6e4d4a68cc3f..94fe341bec9d 100644 --- a/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c +++ b/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c @@ -2,7 +2,7 @@ Intrinsic Memory Routines Wrapper Implementation for OpenSSL-based Cryptographic Library. -Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -13,9 +13,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent typedef UINTN size_t; +#if defined(__GNUC__) || defined(__clang__) + #define GLOBAL_USED __attribute__((used)) +#else + #define GLOBAL_USED +#endif + /* OpenSSL will use floating point support, and C compiler produces the _fltused symbol by default. Simply define this symbol here to satisfy the linker. */ -int _fltused = 1; +int GLOBAL_USED _fltused = 1; /* Sets buffers to a specified character */ void * memset (void *dest, int ch, size_t count) From 9688a62424a5f3ae72f935dc307d781f186f7bfa Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 16:37:28 +0800 Subject: [PATCH 11/13] EmulatorPkg: Enable CLANG9PE tool chain 1. Append CLANG CC and LINK flags 2. Modify WinHost to move PCD getting in the late position Signed-off-by: Liming Gao --- EmulatorPkg/EmulatorPkg.dsc | 8 ++++++-- EmulatorPkg/EmulatorPkg.fdf | 2 +- EmulatorPkg/Win/Host/WinHost.c | 11 +++++++---- EmulatorPkg/Win/Host/WinHost.inf | 6 ++++++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc index 20f118771393..9d978f46dc56 100644 --- a/EmulatorPkg/EmulatorPkg.dsc +++ b/EmulatorPkg/EmulatorPkg.dsc @@ -237,7 +237,7 @@ [Components] !if "IA32" in $(ARCH) || "X64" in $(ARCH) - !if "MSFT" in $(FAMILY) + !if "MSFT" in $(FAMILY) || "CLANG9PE" in $(TOOL_CHAIN_TAG) ## # Emulator, OS WIN application ## @@ -377,7 +377,7 @@ FatPkg/EnhancedFatDxe/Fat.inf -!if "XCODE5" not in $(TOOL_CHAIN_TAG) +!if "XCODE5" not in $(TOOL_CHAIN_TAG) and "CLANG9PE" not in $(TOOL_CHAIN_TAG) ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf { gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE @@ -419,7 +419,11 @@ MSFT:DEBUG_*_*_CC_FLAGS = /Od /Oy- MSFT:NOOPT_*_*_CC_FLAGS = /Od /Oy- + CLANGPE:DEBUG_*_*_CC_FLAGS =-O0 -D UNICODE -Wno-unused-command-line-argument -Wno-incompatible-pointer-types -Wno-enum-conversion -Wno-incompatible-pointer-types -Wno-sometimes-uninitialized -Wno-constant-conversion -Wno-main-return-type MSFT:*_*_*_DLINK_FLAGS = /ALIGN:4096 /FILEALIGN:4096 /SUBSYSTEM:CONSOLE MSFT:DEBUG_*_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x10000 MSFT:NOOPT_*_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x10000 + CLANGPE:*_*_*_DLINK_FLAGS = /ALIGN:4096 /FILEALIGN:4096 /SUBSYSTEM:CONSOLE + CLANGPE:DEBUG_*_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x10000 + CLANGPE:NOOPT_*_*_DLINK_FLAGS = /EXPORT:InitializeDriver=$(IMAGE_ENTRY_POINT) /BASE:0x10000 diff --git a/EmulatorPkg/EmulatorPkg.fdf b/EmulatorPkg/EmulatorPkg.fdf index 295f6f1db8ab..473289ca72a5 100644 --- a/EmulatorPkg/EmulatorPkg.fdf +++ b/EmulatorPkg/EmulatorPkg.fdf @@ -196,7 +196,7 @@ INF EmulatorPkg/EmuSnpDxe/EmuSnpDxe.inf INF FatPkg/EnhancedFatDxe/Fat.inf -!if "XCODE5" not in $(TOOL_CHAIN_TAG) +!if "XCODE5" not in $(TOOL_CHAIN_TAG) and "CLANG9PE" not in $(TOOL_CHAIN_TAG) INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf !endif INF ShellPkg/Application/Shell/Shell.inf diff --git a/EmulatorPkg/Win/Host/WinHost.c b/EmulatorPkg/Win/Host/WinHost.c index 9aba3c89593d..d51a96de7b31 100644 --- a/EmulatorPkg/Win/Host/WinHost.c +++ b/EmulatorPkg/Win/Host/WinHost.c @@ -356,7 +356,7 @@ Routine Description: INTN EFIAPI main ( - IN INTN Argc, + IN INT Argc, IN CHAR8 **Argv, IN CHAR8 **Envp ) @@ -405,9 +405,6 @@ Routine Description: AdjustTokenPrivileges(Token, FALSE, &TokenPrivileges, 0, (PTOKEN_PRIVILEGES) NULL, 0); } - MemorySizeStr = (CHAR16 *) PcdGetPtr (PcdEmuMemorySize); - FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume); - SecPrint ("\n\rEDK II WIN Host Emulation Environment from http://www.tianocore.org/edk2/\n\r"); // @@ -423,6 +420,12 @@ Routine Description: SetProcessAffinityMask (GetCurrentProcess (), (INTN)(BIT0 << LowBit)); } } + + // + // Move PCD getting late + // + MemorySizeStr = (CHAR16 *) PcdGetPtr (PcdEmuMemorySize); + FirmwareVolumesStr = (CHAR16 *) PcdGetPtr (PcdEmuFirmwareVolume); // // Make some Windows calls to Set the process to the highest priority in the diff --git a/EmulatorPkg/Win/Host/WinHost.inf b/EmulatorPkg/Win/Host/WinHost.inf index 631d5a647022..dad9278fa3d6 100644 --- a/EmulatorPkg/Win/Host/WinHost.inf +++ b/EmulatorPkg/Win/Host/WinHost.inf @@ -95,3 +95,9 @@ MSFT:*_VS2017_X64_DLINK_FLAGS = /LIBPATH:"%VCToolsInstallDir%lib\x64" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /MAP /OPT:REF /DEBUG /MACHINE:AMD64 /LTCG Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib MSFT:*_*_X64_ASM_FLAGS == /nologo /W3 /WX /c /Cx /Zd /W0 /Zi MSFT:*_*_X64_ASMLINK_FLAGS == /link /nologo + + CLANGPE:*_*_X64_DLINK_FLAGS == /out:"$(BIN_DIR)\$(BASE_NAME).exe" /base:0x10000000 /pdb:"$(BIN_DIR)\$(BASE_NAME).pdb" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x64" /LIBPATH:"%VCToolsInstallDir%lib\x64" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /OPT:REF /DEBUG /MACHINE:AMD64 Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib /lldmap /EXPORT:InitializeDriver=_ModuleEntryPoint + CLANGPE:*_*_X64_CC_FLAGS == -m64 -g -fshort-wchar -fno-strict-aliasing -Wall -c -include AutoGen.h -D _CRT_SECURE_NO_WARNINGS -Wnonportable-include-path -D UNICODE -D _CRT_SECURE_NO_DEPRECATE + + CLANGPE:*_*_IA32_DLINK_FLAGS == /out:"$(BIN_DIR)\$(BASE_NAME).exe" /base:0x10000000 /pdb:"$(BIN_DIR)\$(BASE_NAME).pdb" /LIBPATH:"%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x86" /LIBPATH:"%WindowsSdkDir%lib\%WindowsSDKLibVersion%\um\x86" /LIBPATH:"%VCToolsInstallDir%ib\x86" /NOLOGO /SUBSYSTEM:CONSOLE /NODEFAULTLIB /IGNORE:4086 /OPT:REF /DEBUG /MACHINE:I386 Kernel32.lib MSVCRTD.lib vcruntimed.lib ucrtd.lib Gdi32.lib User32.lib Winmm.lib Advapi32.lib /lldmap /EXPORT:InitializeDriver=_ModuleEntryPoint + CLANGPE:*_*_IA32_CC_FLAGS == -m32 -g -fshort-wchar -fno-strict-aliasing -Wall -c -include AutoGen.h -D _CRT_SECURE_NO_WARNINGS -Wnonportable-include-path -D UNICODE -D _CRT_SECURE_NO_DEPRECATE From 033e066ef69de3f8c2b874730236fe4cd96e6869 Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 21:27:06 +0800 Subject: [PATCH 12/13] OvmfPkg: Enable CLANG9PE tool chain Signed-off-by: Liming Gao --- OvmfPkg/OvmfPkgIa32.dsc | 6 ++++-- OvmfPkg/OvmfPkgIa32.fdf | 2 +- OvmfPkg/OvmfPkgIa32X64.dsc | 4 +++- OvmfPkg/OvmfPkgIa32X64.fdf | 2 +- OvmfPkg/OvmfPkgX64.dsc | 6 ++++-- OvmfPkg/OvmfPkgX64.fdf | 2 +- OvmfPkg/Sec/SecMain.inf | 3 +++ 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 66e944436a69..7af58f4795c8 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -66,7 +66,7 @@ GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG -!if $(TOOL_CHAIN_TAG) != "XCODE5" +!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANG9PE" GCC:*_*_*_CC_FLAGS = -mno-mmx -mno-sse !endif @@ -80,12 +80,14 @@ [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 XCODE:*_*_*_DLINK_FLAGS = + CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096 # Force PE/COFF sections to be aligned at 4KB boundaries to support page level # protection of DXE_SMM_DRIVER/SMM_CORE modules [BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE] GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 XCODE:*_*_*_DLINK_FLAGS = + CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096 ################################################################################ # @@ -804,7 +806,7 @@ OvmfPkg/Csm/Csm16/Csm16.inf !endif -!if $(TOOL_CHAIN_TAG) != "XCODE5" +!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANG9PE" ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf { gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf index 785affeb90c8..4176e1fe1771 100644 --- a/OvmfPkg/OvmfPkgIa32.fdf +++ b/OvmfPkg/OvmfPkgIa32.fdf @@ -278,7 +278,7 @@ INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResour INF FatPkg/EnhancedFatDxe/Fat.inf INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf -!if $(TOOL_CHAIN_TAG) != "XCODE5" +!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANG9PE" INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf !endif INF ShellPkg/Application/Shell/Shell.inf diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 51c2bfb44f14..012869b66460 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -66,7 +66,7 @@ GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG -!if $(TOOL_CHAIN_TAG) != "XCODE5" +!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANG9PE" GCC:*_*_*_CC_FLAGS = -mno-mmx -mno-sse !endif !ifdef $(SOURCE_DEBUG_ENABLE) @@ -85,12 +85,14 @@ [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 XCODE:*_*_*_DLINK_FLAGS = + CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096 # Force PE/COFF sections to be aligned at 4KB boundaries to support page level # protection of DXE_SMM_DRIVER/SMM_CORE modules [BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE] GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 XCODE:*_*_*_DLINK_FLAGS = + CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096 ################################################################################ # diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf index 74407072563b..28c812388213 100644 --- a/OvmfPkg/OvmfPkgIa32X64.fdf +++ b/OvmfPkg/OvmfPkgIa32X64.fdf @@ -279,7 +279,7 @@ INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResour INF FatPkg/EnhancedFatDxe/Fat.inf INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf -!if $(TOOL_CHAIN_TAG) != "XCODE5" +!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANG9PE" INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf !endif INF ShellPkg/Application/Shell/Shell.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index ba7a75884490..c9d663aa8135 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -66,7 +66,7 @@ GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG INTEL:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG MSFT:RELEASE_*_*_CC_FLAGS = /D MDEPKG_NDEBUG -!if $(TOOL_CHAIN_TAG) != "XCODE5" +!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANG9PE" GCC:*_*_*_CC_FLAGS = -mno-mmx -mno-sse !endif !ifdef $(SOURCE_DEBUG_ENABLE) @@ -85,12 +85,14 @@ [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER] GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 XCODE:*_*_*_DLINK_FLAGS = + CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096 # Force PE/COFF sections to be aligned at 4KB boundaries to support page level # protection of DXE_SMM_DRIVER/SMM_CORE modules [BuildOptions.common.EDKII.DXE_SMM_DRIVER, BuildOptions.common.EDKII.SMM_CORE] GCC:*_*_*_DLINK_FLAGS = -z common-page-size=0x1000 XCODE:*_*_*_DLINK_FLAGS = + CLANGPE: *_*_*_DLINK_FLAGS = /ALIGN:4096 ################################################################################ # @@ -815,7 +817,7 @@ OvmfPkg/Csm/Csm16/Csm16.inf !endif -!if $(TOOL_CHAIN_TAG) != "XCODE5" +!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANG9PE" ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf { gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf index 74407072563b..28c812388213 100644 --- a/OvmfPkg/OvmfPkgX64.fdf +++ b/OvmfPkg/OvmfPkgX64.fdf @@ -279,7 +279,7 @@ INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResour INF FatPkg/EnhancedFatDxe/Fat.inf INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf -!if $(TOOL_CHAIN_TAG) != "XCODE5" +!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(TOOL_CHAIN_TAG) != "CLANG9PE" INF ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf !endif INF ShellPkg/Application/Shell/Shell.inf diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf index 63ba4cb555fb..b6668e3e6b92 100644 --- a/OvmfPkg/Sec/SecMain.inf +++ b/OvmfPkg/Sec/SecMain.inf @@ -69,3 +69,6 @@ [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire + +[BuildOptions] + CLANGPE:*_*_*_CC_FLAGS =-fno-omit-frame-pointer \ No newline at end of file From 2908e5e93fc9533e3f5153578c8f0612c2933d77 Mon Sep 17 00:00:00 2001 From: Liming Gao Date: Thu, 5 Sep 2019 22:29:51 +0800 Subject: [PATCH 13/13] Update Readme.md for new CLANG9PE tool chain Signed-off-by: Liming Gao --- Readme.md | 220 ++++++++++-------------------------------------------- 1 file changed, 39 insertions(+), 181 deletions(-) diff --git a/Readme.md b/Readme.md index 27e4ce07719b..c75b1e4a5695 100644 --- a/Readme.md +++ b/Readme.md @@ -1,181 +1,39 @@ -# EDK II Project - -A modern, feature-rich, cross-platform firmware development environment -for the UEFI and PI specifications from www.uefi.org. - -The majority of the content in the EDK II open source project uses a -[BSD-2-Clause Plus Patent License](License.txt). The EDK II open source project -contains the following components that are covered by additional licenses: -* [BaseTools/Source/C/BrotliCompress](BaseTools/Source/C/BrotliCompress/LICENSE) -* [MdeModulePkg/Library/BrotliCustomDecompressLib](MdeModulePkg/Library/BrotliCustomDecompressLib/LICENSE) -* [BaseTools/Source/C/LzmaCompress](BaseTools/Source/C/LzmaCompress/LZMA-SDK-README.txt) -* [MdeModulePkg/Library/LzmaCustomDecompressLib](MdeModulePkg/Library/LzmaCustomDecompressLib/LZMA-SDK-README.txt) -* [IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/Sdk](IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LZMA-SDK-README.txt) -* [BaseTools/Source/C/VfrCompile/Pccts](BaseTools/Source/C/VfrCompile/Pccts/RIGHTS) -* [MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma](MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/README) -* [OvmfPkg](OvmfPkg/License.txt) -* [CryptoPkg/Library/OpensslLib/openssl](https://github.com/openssl/openssl/blob/50eaac9f3337667259de725451f201e784599687/LICENSE) -* [ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3](https://github.com/ucb-bar/berkeley-softfloat-3/blob/b64af41c3276f97f0e181920400ee056b9c88037/COPYING.txt) - -The EDK II Project is composed of packages. The maintainers for each package -are listed in [Maintainers.txt](Maintainers.txt). - -# Resources -* [TianoCore](http://www.tianocore.org) -* [EDK II](https://github.com/tianocore/tianocore.github.io/wiki/EDK-II) -* [Getting Started with EDK II](https://github.com/tianocore/tianocore.github.io/wiki/Getting-Started-with-EDK-II) -* [Mailing Lists](https://github.com/tianocore/tianocore.github.io/wiki/Mailing-Lists) -* [TianoCore Bugzilla](https://bugzilla.tianocore.org) -* [How To Contribute](https://github.com/tianocore/tianocore.github.io/wiki/How-To-Contribute) -* [Release Planning](https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Planning) - -# Code Contributions -To make a contribution to a TianoCore project, follow these steps. -1. Create a change description in the format specified below to - use in the source control commit log. -2. Your commit message must include your `Signed-off-by` signature -3. Submit your code to the TianoCore project using the process - that the project documents on its web page. If the process is - not documented, then submit the code on development email list - for the project. -4. It is preferred that contributions are submitted using the same - copyright license as the base project. When that is not possible, - then contributions using the following licenses can be accepted: - * BSD (2-clause): http://opensource.org/licenses/BSD-2-Clause - * BSD (3-clause): http://opensource.org/licenses/BSD-3-Clause - * MIT: http://opensource.org/licenses/MIT - * Python-2.0: http://opensource.org/licenses/Python-2.0 - * Zlib: http://opensource.org/licenses/Zlib - - For documentation: - * FreeBSD Documentation License - https://www.freebsd.org/copyright/freebsd-doc-license.html - - Contributions of code put into the public domain can also be - accepted. - - Contributions using other licenses might be accepted, but further - review will be required. - -# Developer Certificate of Origin - -Your change description should use the standard format for a -commit message, and must include your `Signed-off-by` signature. - -In order to keep track of who did what, all patches contributed must -include a statement that to the best of the contributor's knowledge -they have the right to contribute it under the specified license. - -The test for this is as specified in the [Developer's Certificate of -Origin (DCO) 1.1](https://developercertificate.org/). The contributor -certifies compliance by adding a line saying - - Signed-off-by: Developer Name - -where `Developer Name` is the contributor's real name, and the email -address is one the developer is reachable through at the time of -contributing. - -``` -Developer's Certificate of Origin 1.1 - -By making a contribution to this project, I certify that: - -(a) The contribution was created in whole or in part by me and I - have the right to submit it under the open source license - indicated in the file; or - -(b) The contribution is based upon previous work that, to the best - of my knowledge, is covered under an appropriate open source - license and I have the right under that license to submit that - work with modifications, whether created in whole or in part - by me, under the same open source license (unless I am - permitted to submit under a different license), as indicated - in the file; or - -(c) The contribution was provided directly to me by some other - person who certified (a), (b) or (c) and I have not modified - it. - -(d) I understand and agree that this project and the contribution - are public and that a record of the contribution (including all - personal information I submit with it, including my sign-off) is - maintained indefinitely and may be redistributed consistent with - this project or the open source license(s) involved. -``` - -# Sample Change Description / Commit Message - -``` -From: Contributor Name -Subject: [Repository/Branch PATCH] Pkg-Module: Brief-single-line-summary - -Full-commit-message - -Signed-off-by: Contributor Name -``` - -## Notes for sample patch email - -* The first line of commit message is taken from the email's subject - line following `[Repository/Branch PATCH]`. The remaining portion of the - commit message is the email's content. -* `git format-patch` is one way to create this format - -## Definitions for sample patch email - -* `Repository` is the identifier of the repository the patch applies. - This identifier should only be provided for repositories other than - `edk2`. For example `edk2-BuildSpecification` or `staging`. -* `Branch` is the identifier of the branch the patch applies. This - identifier should only be provided for branches other than `edk2/master`. - For example `edk2/UDK2015`, `edk2-BuildSpecification/release/1.27`, or - `staging/edk2-test`. -* `Module` is a short identifier for the affected code or documentation. For - example `MdePkg`, `MdeModulePkg/UsbBusDxe`, `Introduction`, or - `EDK II INF File Format`. -* `Brief-single-line-summary` is a short summary of the change. -* The entire first line should be less than ~70 characters. -* `Full-commit-message` a verbose multiple line comment describing - the change. Each line should be less than ~70 characters. -* `Signed-off-by` is the contributor's signature identifying them - by their real/legal name and their email address. - -# Submodules - -Submodule in EDK II is allowed but submodule chain should be avoided -as possible as we can. Currently EDK II contains two submodules - -- CryptoPkg/Library/OpensslLib/openssl -- ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3 - -The latter one is actually required by previous one. It's inevitable -in openssl-1.1.1 (since stable201905) for floating point parameter -conversion, but should be dropped once there's no such need in future -release of openssl. - -To get a full, buildable EDK II repository, use following steps of git -command - -``` -$ git clone https://github.com/tianocore/edk2.git -$ cd edk2 -$ git submodule update --init -$ cd .. -``` - -If there's update for submodules, use following git commands to get the -latest submodules code. - -``` -$ cd edk2 -$ git pull -$ git submodule update -``` - -Note: When cloning submodule repos, '--recursive' option is not -recommended. EDK II itself will not use any code/feature from -submodules in above submodules. So using '--recursive' adds a -dependency on being able to reach servers we do not actually want -any code from, as well as needlessly downloading code we will not -use. +## New CLANG9PE tool chain + +CLANG9PE tool chain is added to directly generate PE/COFF image (EFI image). +This tool chain uses LLVM Clang compiler and lld linker, generates PE/COFF +image and PDB compatible debug symbol format. Now, it supports IA32/X64 Archs. +It must use LLVM 9 or above release. LLVM 9 will be released soon. +Now, LLVM 9.0.0-rc3 is ready on https://prereleases.llvm.org/9.0.0/#rc3. + +CLANG9PE is the cross OS tool chain. It can work on Windows/Linux/Mac. +For the same source code, with the same version LLVM tool chain, +CLANG9PE can generate the same binary image. So, the developer can +choose the different development environment and work on the same +code base. + +LLVM tool chain provides the compiler and linker. To build EDK2 project, +some other tools are still required. On Windows OS, nmake and Visual Studio +are required to trig Makefile and compile BaseTools C tools. +On Linux/Mac, binutils and gcc are required to be installed for make and +compile BaseTools C tools. Because VS or GCC are mainly used to compile +BaseTools and provide nmake/make tool, they can keep on the stable version +without update. + +To build source code, CLANG9PE tool chain (-t CLANG9PE) can be specified +on Windows OS, set CLANG_HOST_BIN=n, set CLANG9PE_BIN=LLVM installed directory +CLANG_HOST_BIN is used CLANG_HOST_PREFIX. Prefix n is for nmake. +For example: +* set CLANG_HOST_BIN=n +* set CLANG9PE_BIN=C:\Program Files\LLVM\bin\ +* set IASL_PREFIX=C:\Asl\ + +On Linux/Mac, export CLANG9PE_BIN=LLVM installed directory, CLANG_HOST_BIN is +not required, because there is no prefix for make. +For example: +* export CLANG9PE_BIN=/home/clang9/bin/ + +Now, CLANG9PE tool chain has been verified in Edk2 packages and Ovmf/Emulator +with LLVM 9.0.0-rc3 on Windows and Linux OS. +OVMF IA32/X64/IA32X64 all boots to Shell on Windows and Linux OS. +Emulator can boot to Shell on Windows only with CLANG9PE.