Date   

Re: [PATCH 1/2] EmbeddedPkg: make PrePiMemoryAllocationLib a SEC type library

Laszlo Ersek
 

On 08/03/16 10:21, Ard Biesheuvel wrote:
This library is only used by the various PrePi implementations, all of
which are of type SEC.
You can actually enforce that client module type restriction, by setting

LIBRARY_CLASS = MemoryAllocationLib|SEC

Can you try that, in addition to the MODULE_TYPE change?

Just an idea, of course.

Thanks,
Laszlo

So make this library SEC as well. This may affect
the build options used by the platform.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
index 21f6eb1e14bc..ea3d0f5da9c2 100644
--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
@@ -15,7 +15,7 @@ [Defines]
INF_VERSION = 0x00010005
BASE_NAME = PrePiMemoryAllocationLib
FILE_GUID = 4f14c900-51a9-11e0-afbf-0002a5d5c51b
- MODULE_TYPE = PEIM
+ MODULE_TYPE = SEC
VERSION_STRING = 1.0
LIBRARY_CLASS = MemoryAllocationLib


[Patch] BaseTools: Fix the bug when use FILE_GUID override the module in DSC

Yonghong Zhu <yonghong.zhu@...>
 

In last commit 2502b73, it doesn't cover the case that in the DSC file
use FILE_GUID to override the module.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
BaseTools/Source/Python/AutoGen/AutoGen.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 9c548be..0484a5d 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -328,32 +328,41 @@ class WorkspaceAutoGen(AutoGen):
for fvname in self.FvTargetList:
if fvname.upper() not in self.FdfProfile.FvDict:
EdkLogger.error("build", OPTION_VALUE_INVALID,
"No such an FV in FDF file: %s" % fvname)

+ # In DSC file may use FILE_GUID to override the module, then in the Platform.Modules use FILE_GUIDmodule.inf as key,
+ # but the path (self.MetaFile.Path) is the real path
for key in self.FdfProfile.InfDict:
if key == 'ArchTBD':
Platform_cache = {}
+ MetaFile_cache = {}
for Arch in self.ArchList:
Platform_cache[Arch] = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]
+ MetaFile_cache[Arch] = []
+ for Pkey in Platform_cache[Arch].Modules.keys():
+ MetaFile_cache[Arch].append(Platform_cache[Arch].Modules[Pkey].MetaFile)
for Inf in self.FdfProfile.InfDict[key]:
ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch)
for Arch in self.ArchList:
- if ModuleFile in Platform_cache[Arch].Modules:
+ if ModuleFile in MetaFile_cache[Arch]:
break
else:
ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, Toolchain]
if not ModuleData.IsBinaryModule:
EdkLogger.error('build', PARSER_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % ModuleFile)

else:
for Arch in self.ArchList:
if Arch == key:
Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]
+ MetaFileList = []
+ for Pkey in Platform.Modules.keys():
+ MetaFileList.append(Platform.Modules[Pkey].MetaFile)
for Inf in self.FdfProfile.InfDict[key]:
ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch)
- if ModuleFile in Platform.Modules:
+ if ModuleFile in MetaFileList:
continue
ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, Toolchain]
if not ModuleData.IsBinaryModule:
EdkLogger.error('build', PARSER_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % ModuleFile)

--
2.6.1.windows.1


[PATCH v5 4/4] ShellPkg-UefiShellCommandLib: Add EFIAPI in VA_List library function

Shi, Steven <steven.shi@...>
 

Add EFIAPI in CatPrint library function. Every function which uses
variable list need explicit use EFIAPI to force use MS ABI. This change
is needed to pass CLANG38 build.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Steven Shi <steven.shi@intel.com>
---
ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c | 1 +
1 file changed, 1 insertion(+)
mode change 100644 => 100755 ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c

diff --git a/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c b/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
old mode 100644
new mode 100755
index d157ebb..979693a
--- a/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
+++ b/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
@@ -85,6 +85,7 @@ typedef struct {

**/
EFI_STATUS
+EFIAPI
CatPrint (
IN OUT POOL_PRINT *Str,
IN CHAR16 *Fmt,
--
2.7.4


[PATCH v5 3/4] ShellPkg-UefiShellTftpCommandLib: Replace compiler builtin

Shi, Steven <steven.shi@...>
 

Use explicit CopyMem to replace compiler builtin to do the structure
values assignment. This change is needed to pass CLANG38 build.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Steven Shi <steven.shi@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
---
ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
mode change 100644 => 100755 ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c

diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
old mode 100644
new mode 100755
index 666ee9d..5c50797
--- a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
+++ b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
@@ -342,7 +342,7 @@ ShellCommandRunTftp (
goto Error;
}

- Mtftp4ConfigData = DefaultMtftp4ConfigData;
+ CopyMem (&Mtftp4ConfigData, &DefaultMtftp4ConfigData, sizeof (EFI_MTFTP4_CONFIG_DATA));

//
// Check the host IPv4 address
--
2.7.4


[PATCH v5 2/4] BaseTools-Conf:Introduce CLANG38 new toolchain for x86

Shi, Steven <steven.shi@...>
 

This adds support for LLVM 3.8.x in LTO mode for IA32 and X64.
CLANG38 enable LLVM Link Time Optimization (LTO) and code size
optimization flag (-Oz) by default for aggressive code size
improvement. CLANG38 X64 code is small code model + PIE.

CLANG LTO needs PIE in link flags to generate PIE code correctly,
otherwise the PIE is not really enabled. (e.g. OvmfPkgX64 will
hang in 64bits SEC at high address because of small model code
displacement overflow).

Test pass platforms: OVMF (OvmfPkgIa32.dsc, OvmfPkgX64.dsc and
OvmfPkgIa32X64.dsc).
Test compiler and linker version: LLVM 3.8, GNU ld 2.26.

Example steps to use the CLANG38 tool chain to build OVMF platform:
1. Download and extract the llvm 3.8.0 Pre-Built Binaries from
http://www.llvm.org/releases/ (e.g. http://www.llvm.org/releases/
3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz and
extract it as ~/clang38).
2. Copy LLVMgold.so from https://github.com/shijunjing/edk2/blob/
llvm/BaseTools/Bin/LLVMgold.so to above clang lib folder (e.g.
~/clang38/lib/LLVMgold.so)
3. Install new version linker with plugin support (e.g. ld 2.26 in
GNU Binutils 2.26 or Ubuntu16.04)
$ cd edk2
$ git checkout llvm
$ export CLANG38_BIN=path/to/your/clang38/
(e.g. export CLANG38_BIN=~/clang38/bin/)
$ source edksetup.sh
$ make -C BaseTools/Source/C
$ build -t CLANG38 -a X64 -p OvmfPkg/OvmfPkgX64.dsc -n 5 -b DEBUG
-DDEBUG_ON_SERIAL_PORT
$ cd edk2/Build/OvmfX64/DEBUG_CLANG38/FV
$ qemu-system-x86_64.exe -bios OVMF.fd -serial file:serial.log -m 4096
-hda fat:.

If you want, you can build and install GNU Binutils 2.26 as below steps
in Ubuntu:
Download binutils-2.26 source code from http://ftp.gnu.org/gnu/binutils/
and extract it to ~/binutils-2.26
$sudo apt-get install bison
$sudo apt-get install flex
Install other necessary binutils build tools if missing
$ mkdir build
$ cd build
$ ../binutils-2.26/configure --enable-gold --enable-plugins
--disable-werror --prefix=/usr
$ make -j 5
$ sudo make install

If you want, you can build LLVMgold.so as below steps
Download llvm-3.8.0 source code from http://www.llvm.org/releases/
3.8.0/llvm-3.8.0.src.tar.xz and extract it to ~/llvm-3.8.0.src
Download clang3.8.0 source code from http://www.llvm.org/releases/
3.8.0/cfe-3.8.0.src.tar.xz and extract it to ~/llvm-3.8.0.src/tools/clang
Refer http://clang.llvm.org/get_started.html to Install other necessary
clang build tools if missing
$ mkdir llvm38build
$ cd llvm38build
If your GNU Binutils 2.26 is in /home/jshi19/binutils-2.26,
$ cmake ../llvm-3.8.0.src -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release"
-DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_VERBOSE_MAKEFILE=ON
-DCMAKE_CXX_COMPILER="/usr/bin/g++" -DCMAKE_C_COMPILER="/usr/bin/gcc"
-DLLVM_BINUTILS_INCDIR=/home/jshi19/binutils-2.26/include
$ make -j 5 LLVMgold The LLVMgold.so is in ~/llvm38build/lib/LLVMgold.so

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Steven Shi <steven.shi@intel.com>
---
BaseTools/Conf/tools_def.template | 87 +++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
mode change 100644 => 100755 BaseTools/Conf/tools_def.template

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
old mode 100644
new mode 100755
index fd9eccb..6489039
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -381,6 +381,12 @@ DEFINE SOURCERY_CYGWIN_TOOLS = /cygdrive/c/Program Files/CodeSourcery/Sourcery G
# Required to build platforms or ACPI tables:
# Intel(r) ACPI Compiler from
# https://acpica.org/downloads
+# CLANG38 -Linux- Requires:
+# Clang v3.8 or later, LLVMgold plugin and GNU binutils 2.26 targeting x86_64-linux-gnu
+# Optional:
+# Required to build platforms or ACPI tables:
+# Intel(r) ACPI Compiler from
+# https://acpica.org/downloads
# ELFGCC -Linux- Requires:
# GCC(this tool chain uses whatever version of gcc and binutils that is installed in /usr/bin)
# Optional:
@@ -5428,6 +5434,87 @@ RELEASE_CLANG35_AARCH64_CC_FLAGS = DEF(CLANG35_AARCH64_CC_FLAGS) $(ARCHCC_FLAGS)

####################################################################################
#
+# Clang 3.8 - This configuration is used to compile under Linux to produce
+# PE/COFF binaries using LLVM/Clang 3.8 with Link Time Optimization enabled
+#
+####################################################################################
+*_CLANG38_*_*_FAMILY = GCC
+*_CLANG38_*_MAKE_PATH = make
+*_CLANG38_*_*_DLL = ENV(CLANG38_DLL)
+*_CLANG38_*_ASL_PATH = DEF(UNIX_IASL_BIN)
+
+*_CLANG38_*_APP_FLAGS =
+*_CLANG38_*_ASL_FLAGS = DEF(IASL_FLAGS)
+*_CLANG38_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
+
+DEFINE CLANG38_IA32_PREFIX = ENV(CLANG38_BIN)
+DEFINE CLANG38_X64_PREFIX = ENV(CLANG38_BIN)
+
+DEFINE CLANG38_IA32_TARGET = -target i686-pc-linux-gnu
+DEFINE CLANG38_X64_TARGET = -target x86_64-pc-linux-gnu
+
+DEFINE CLANG38_ALL_CC_FLAGS = DEF(GCC44_ALL_CC_FLAGS) -Wno-empty-body -fno-stack-protector -fno-builtin -mms-bitfields -Wno-address -Wno-shift-negative-value -Wno-parentheses-equality -Wno-unknown-pragmas -Wno-tautological-constant-out-of-range-compare -Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -msoft-float -mno-implicit-float -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference -Wno-tautological-compare
+
+###########################
+# CLANG38 IA32 definitions
+###########################
+*_CLANG38_IA32_OBJCOPY_PATH = objcopy
+*_CLANG38_IA32_CC_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_SLINK_PATH = DEF(CLANG38_IA32_PREFIX)llvm-ar
+*_CLANG38_IA32_DLINK_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_ASLDLINK_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_ASM_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_PP_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_VFRPP_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_ASLCC_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_ASLPP_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_RC_PATH = objcopy
+
+*_CLANG38_IA32_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m32 -fno-lto DEF(CLANG38_IA32_TARGET)
+*_CLANG38_IA32_ASLDLINK_FLAGS = DEF(GCC5_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_i386
+*_CLANG38_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386 DEF(CLANG38_IA32_TARGET)
+DEBUG_CLANG38_IA32_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANG38_IA32_TARGET) -g
+RELEASE_CLANG38_IA32_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANG38_IA32_TARGET)
+*_CLANG38_IA32_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-Oz -Wl,-melf_i386 -Wl,--oformat=elf32-i386
+*_CLANG38_IA32_DLINK2_FLAGS = DEF(GCC5_IA32_DLINK2_FLAGS)
+*_CLANG38_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
+*_CLANG38_IA32_OBJCOPY_FLAGS =
+*_CLANG38_IA32_NASM_FLAGS = -f elf32
+*_CLANG38_IA32_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG38_IA32_TARGET)
+*_CLANG38_IA32_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_IA32_TARGET)
+*_CLANG38_IA32_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_IA32_TARGET)
+
+##########################
+# CLANG38 X64 definitions
+##########################
+*_CLANG38_X64_OBJCOPY_PATH = objcopy
+*_CLANG38_X64_CC_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_SLINK_PATH = DEF(CLANG38_X64_PREFIX)llvm-ar
+*_CLANG38_X64_DLINK_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_ASLDLINK_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_ASM_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_PP_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_VFRPP_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_ASLCC_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_ASLPP_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_RC_PATH = objcopy
+
+*_CLANG38_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64 -fno-lto DEF(CLANG38_X64_TARGET)
+*_CLANG38_X64_ASLDLINK_FLAGS = DEF(GCC5_IA32_X64_ASLDLINK_FLAGS) -Wl,-m,elf_x86_64
+*_CLANG38_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64 DEF(CLANG38_X64_TARGET)
+DEBUG_CLANG38_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
+RELEASE_CLANG38_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)
+*_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small
+*_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS)
+*_CLANG38_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
+*_CLANG38_X64_OBJCOPY_FLAGS =
+*_CLANG38_X64_NASM_FLAGS = -f elf64
+*_CLANG38_X64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG38_X64_TARGET)
+*_CLANG38_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_X64_TARGET)
+*_CLANG38_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_X64_TARGET)
+
+####################################################################################
+#
# Cygwin GCC And Intel ACPI Compiler
#
####################################################################################
--
2.7.4


[PATCH v5 1/4] BaseTools-Conf:Remove short dash in ar flag for LLVM

Shi, Steven <steven.shi@...>
 

Both binutils ar and LLVM ar support "cr", but LLVM ar doens't
support add "-" in the flags, and llvm-ar cannot accept "-cr".
So remove the short dash "-" to make llvm archives work.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Steven Shi <steven.shi@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
BaseTools/Conf/build_rule.template | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
mode change 100644 => 100755 BaseTools/Conf/build_rule.template

diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule.template
old mode 100644
new mode 100755
index 9adf391..6e7b7d4
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -266,7 +266,7 @@
"$(SLINK)" $(SLINK_FLAGS) /OUT:${dst} @$(OBJECT_FILES_LIST)

<Command.GCC, Command.GCCLD>
- "$(SLINK)" -cr ${dst} $(SLINK_FLAGS) @$(OBJECT_FILES_LIST)
+ "$(SLINK)" cr ${dst} $(SLINK_FLAGS) @$(OBJECT_FILES_LIST)

<Command.RVCT>
"$(SLINK)" $(SLINK_FLAGS) ${dst} --via $(OBJECT_FILES_LIST)
--
2.7.4


[PATCH v5 0/4] Introduce CLANG38 toolchain in edk2

Shi, Steven <steven.shi@...>
 

Please review my new commits in public branch:
https://github.com/shijunjing/edk2/commits/llvm_v5

The difference from V4(https://github.com/shijunjing/edk2/commits/llvm_v4):
1. Remove the GCC5 path prefix for binutils objcopy, because a clang user may not set GCC5_BIN.
2. Follow GCC5 to disable the LTO for ASLCC flags.
3. Add CLANG38 in the "Supported Tool Chains" part.

The difference from V2(https://github.com/shijunjing/edk2/commits/llvm_v2):
1. Seperate the CLANG38 from the other two toolchains (GCC5, CLANGSCAN38), and only focus on CLANG38 in this serial.
2. Base on current GCC5 in edk2 to enhance the CLANG38.
3. Seperate the GenFW new relocation types support patch from this serial, and I will send it later in new serial.
4. Add EFIAPI for UefiShellCommandLib function.

Test pass platforms: OVMF (OvmfPkgIa32.dsc, OvmfPkgX64.dsc and
OvmfPkgIa32X64.dsc).
Test compiler and linker version: LLVM 3.8, GNU ld 2.26.

Example steps to use the CLANG38 tool chain to build OVMF platform:
1. Download and extract the llvm 3.8.0 Pre-Built Binaries from http://www.llvm.org/releases/ (e.g. http://www.llvm.org/releases/3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz and extract it as ~/clang38).
2. Copy LLVMgold.so from https://github.com/shijunjing/edk2/blob/llvm/BaseTools/Bin/LLVMgold.so to above clang lib folder (e.g.~/clang38/lib/LLVMgold.so)
3. Install new version linker with plugin support (e.g. ld 2.26 in GNU Binutils 2.26 or Ubuntu16.04)
$ cd edk2
$ export CLANG38_BIN=path/to/your/clang38/ (e.g. export CLANG38_BIN=~/clang38/bin/)
$ source edksetup.sh
$ make -C BaseTools/Source/C
$ build -t CLANG38 -a X64 -p OvmfPkg/OvmfPkgX64.dsc -n 5 -b DEBUG -DDEBUG_ON_SERIAL_PORT
$ cd edk2/Build/OvmfX64/DEBUG_CLANG38/FV
$ qemu-system-x86_64.exe -bios OVMF.fd -serial file:serial.log -m 4096 -hda fat:.


Shi, Steven (4):
BaseTools-Conf:Remove short dash in ar flag for LLVM
BaseTools-Conf:Introduce CLANG38 new toolchain for x86
ShellPkg-UefiShellTftpCommandLib: Replace compiler builtin
ShellPkg-UefiShellCommandLib: Add EFIAPI in VA_List library function

BaseTools/Conf/build_rule.template | 2 +-
BaseTools/Conf/tools_def.template | 87 ++++++++++++++++++++++
.../Library/UefiShellCommandLib/ConsistMapping.c | 1 +
ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c | 2 +-
4 files changed, 90 insertions(+), 2 deletions(-)
mode change 100644 => 100755 BaseTools/Conf/build_rule.template
mode change 100644 => 100755 BaseTools/Conf/tools_def.template
mode change 100644 => 100755 ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
mode change 100644 => 100755 ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c

--
2.7.4


Re: [PATCH 0/3] BaseTools GCC: pass CC flags to linker

Ard Biesheuvel
 

On 3 August 2016 at 10:58, Gao, Liming <liming.gao@intel.com> wrote:
Ard:
I see Steven says it doesn't work, yet. So, I am curious what real issue is resolved by this patch?
For example, when building ArmVirtQemu for ARM, you may get warnings
(or errors when -Werror is enabled) like

lto1: warning: switch -mcpu=cortex-a15 conflicts with -march=armv7-a switch

where cortex-a15 is the target set by the platform .DSC, and armv7-a
is the default target of the compiler.
In this particular example, that does not cause any issues, since
cortex-a15 is compatible with armv7-a. However, if you are building
for ARM11, the code generation performed by the linker will generate
incompatible code unless we pass it the -mcpu=arm11 option as well.

The same applies to things like -mstrict-alignment and -mcmodel=xxx. I
suppose the same issue exists for IA32, where the -march/-mcpu options
in the platform may deviate from the compiler's default.

--
Ard.


Re: [PATCH 0/3] BaseTools GCC: pass CC flags to linker

Liming Gao
 

Ard:
I see Steven says it doesn't work, yet. So, I am curious what real issue is resolved by this patch?

Thanks
Liming

-----Original Message-----
From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
Sent: Wednesday, August 03, 2016 4:23 PM
To: Gao, Liming <liming.gao@intel.com>
Cc: Zhu, Yonghong <yonghong.zhu@intel.com>; Justen, Jordan L
<jordan.l.justen@intel.com>; edk2-devel@lists.01.org;
leif.lindholm@linaro.org; sigmaepsilon92@gmail.com
Subject: Re: [PATCH 0/3] BaseTools GCC: pass CC flags to linker

On 2 August 2016 at 16:51, Ard Biesheuvel <ard.biesheuvel@linaro.org>
wrote:
On 2 August 2016 at 16:50, Gao, Liming <liming.gao@intel.com> wrote:
Ard:
Without this change, GCC5 LTO can pass build. With it, what difference
will be in the generated image? Original way may generate the wrong image,
or new way will generate the smaller image?
This is not about code size but about correctness. Compiler switches
for code model or alignment etc may affect the way code is generated
at link time by the LTO routines.
Note that Steven mentions a similar problem in his CLANG38 series: he
needs to pass -pie to the linker (or -fpie would be sufficient, I
suspect) to prevent the linker from using the wrong code model when
generating code from the LTO bytecode.

Thanks,
Ard.


Re: [PATCH 2/4] BaseTools-Conf:Introduce CLANG38 new toolchain for x86

Shi, Steven <steven.shi@...>
 

Hello Ard,


Hello Steven,

On 3 August 2016 at 08:48, Shi, Steven <steven.shi@intel.com> wrote:
This adds support for LLVM 3.8.x in LTO mode for IA32 and X64.
CLANG38 enable LLVM Link Time Optimization (LTO) and code size
optimization flag (-Oz) by default for aggressive code size
improvement. CLANG38 X64 code is small code model + PIE.

CLANG LTO needs PIE in link flags to generate PIE code correctly,
otherwise the PIE is not really enabled. (e.g. OvmfPkgX64 will
hang in 64bits SEC at high address because of small model code
displacement overflow).
This is probably caused by the same issue I am addressing with the
series I sent out yesterday, to pass the CC flags to the DLINK
command.

The reason is that code is generated by the link pass, so it needs to
see the same -fpie -mcmodel=small options that we passed to the
compiler as wel.

Could you check whether replacing '-Wl,-pie' with -fpie does the trick
as well? As I mentioned before, creating a PIE executable at link time
is not the same as generatic position independent code at compile time
(whether it is via $(CC) or via $(DLINK)). The PIE executable will
contain a .rela section that partially overlaps with other absolute
relocations, so it is best to avoid it.
[Steven]: I just tried it. No, replacing '-Wl,-pie' with -fpie cannot works for clang38. With -fpie in link flags, the OvmfPkgX64 still hang in 64bits SEC at high address.



Some more comments below

+*_CLANG38_IA32_OBJCOPY_PATH = DEF(GCC5_IA32_PREFIX)objcopy
Why are you using the GCC5 prefix here? A clang user may not set GCC5_BIN
[Steven]: OK, I will remove the GCC5 prefix.


+*_CLANG38_IA32_ASLCC_FLAGS = -x c -Os -m32
DEF(CLANG38_IA32_TARGET) -flto

Does LTO make any sense for ACPI tables?
[Steven]: OK, I will follow GCC5 to disable the LTO for ASLCC flags.


Thanks
Steven


Re: [PATCH 0/3] BaseTools GCC: pass CC flags to linker

Ard Biesheuvel
 

On 2 August 2016 at 16:51, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
On 2 August 2016 at 16:50, Gao, Liming <liming.gao@intel.com> wrote:
Ard:
Without this change, GCC5 LTO can pass build. With it, what difference will be in the generated image? Original way may generate the wrong image, or new way will generate the smaller image?
This is not about code size but about correctness. Compiler switches
for code model or alignment etc may affect the way code is generated
at link time by the LTO routines.
Note that Steven mentions a similar problem in his CLANG38 series: he
needs to pass -pie to the linker (or -fpie would be sufficient, I
suspect) to prevent the linker from using the wrong code model when
generating code from the LTO bytecode.

Thanks,
Ard.


[PATCH 2/2] ArmVirtPkg ARM: make relocatable PrePi users build with CLANG35

Ard Biesheuvel
 

The clang developers have made a backward incompatible change to the
command line arguments, and have replaced '-mllvm -arm-use-movt=0'
with '-mno-movt'. This does not matter for most ARM platforms, and
therefore it has been removed from the default CLANG35/ARM CC flags
in patch 1c63516075b3 ("BaseTools CLANG35: drop problematic use-movt
and save-temps options"), but as it turns out, the relocatable PrePi
implementation used by ArmVirtQemuKernel and ArmVirtXen will fail to
build if it contains MOVT/MOVW pairs, due to the fact that these are
not runtime relocatable under ELF.

Since they are runtime relocatable under PE/COFF, and GenFw does the
right thing when encountering them, selectively controlling their
use is more appropriate than disabling them altogether. Therefore,
this patch adds the -mno-movt argument only for the platforms that
use the relocatable PrePi, and only for the module types that may
be pulled into its build.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/ArmVirtQemuKernel.dsc | 8 ++++++++
ArmVirtPkg/ArmVirtXen.dsc | 9 +++++++++
2 files changed, 17 insertions(+)

diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index 01a1d9b4613b..6c536d9bbd2d 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -45,6 +45,9 @@ [LibraryClasses.ARM]
ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf
ArmCpuLib|ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.inf

+[LibraryClasses.ARM.SEC]
+ ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7LibSec.inf
+
[LibraryClasses.common]
ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf

@@ -77,6 +80,11 @@ [BuildOptions]
GCC:*_*_ARM_PLATFORM_FLAGS == -mcpu=cortex-a15 -I$(WORKSPACE)/ArmVirtPkg/Include
*_*_AARCH64_PLATFORM_FLAGS == -I$(WORKSPACE)/ArmVirtPkg/Include

+[BuildOptions.ARM.EDKII.SEC, BuildOptions.ARM.EDKII.BASE]
+ # Avoid MOVT/MOVW instruction pairs in code that may end up in the PIE
+ # executable we build for the relocatable PrePi. They are not runtime
+ # relocatable in ELF.
+ *_CLANG35_*_CC_FLAGS = -mno-movt

################################################################################
#
diff --git a/ArmVirtPkg/ArmVirtXen.dsc b/ArmVirtPkg/ArmVirtXen.dsc
index 5ad1bf630bda..4ebead5ba6e6 100644
--- a/ArmVirtPkg/ArmVirtXen.dsc
+++ b/ArmVirtPkg/ArmVirtXen.dsc
@@ -44,6 +44,9 @@ [LibraryClasses.ARM]
ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf
ArmCpuLib|ArmPkg/Drivers/ArmCpuLib/ArmCortexA15Lib/ArmCortexA15Lib.inf

+[LibraryClasses.ARM.SEC]
+ ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7LibSec.inf
+
[LibraryClasses.common]
ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf

@@ -77,6 +80,12 @@ [BuildOptions]
GCC:*_*_ARM_PLATFORM_FLAGS == -mcpu=cortex-a15 -I$(WORKSPACE)/ArmVirtPkg/Include
GCC:*_*_AARCH64_PLATFORM_FLAGS == -I$(WORKSPACE)/ArmVirtPkg/Include

+[BuildOptions.ARM.EDKII.SEC, BuildOptions.ARM.EDKII.BASE]
+ # Avoid MOVT/MOVW instruction pairs in code that may end up in the PIE
+ # executable we build for the relocatable PrePi. They are not runtime
+ # relocatable in ELF.
+ *_CLANG35_*_CC_FLAGS = -mno-movt
+
################################################################################
#
# Pcd Section - list of all EDK II PCD Entries defined by this Platform
--
2.7.4


[PATCH 1/2] EmbeddedPkg: make PrePiMemoryAllocationLib a SEC type library

Ard Biesheuvel
 

This library is only used by the various PrePi implementations, all of
which are of type SEC. So make this library SEC as well. This may affect
the build options used by the platform.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
index 21f6eb1e14bc..ea3d0f5da9c2 100644
--- a/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
+++ b/EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
@@ -15,7 +15,7 @@ [Defines]
INF_VERSION = 0x00010005
BASE_NAME = PrePiMemoryAllocationLib
FILE_GUID = 4f14c900-51a9-11e0-afbf-0002a5d5c51b
- MODULE_TYPE = PEIM
+ MODULE_TYPE = SEC
VERSION_STRING = 1.0
LIBRARY_CLASS = MemoryAllocationLib

--
2.7.4


[PATCH 0/2] ArmVirtPkg EmbeddedPkg: fix build for CLANG35/ARM

Ard Biesheuvel
 

Currently, the ArmVirtQemuKernel and ArmVirtXen platforms will not build
for ARM when using CLANG35, due to the fact that the compiler emits
MOVT/MOVW pairs into objects that are used by the relocatable PrePi, and
such instruction pairs are not runtime relocatable in ELF (i.e., there are
no dynamic relocation types to describe them)

So fix this by selectively inhibiting the use of these pairs when building
these platforms for ARM using CLANG35

Ard Biesheuvel (2):
EmbeddedPkg: make PrePiMemoryAllocationLib a SEC type library
ArmVirtPkg ARM: make relocatable PrePi users build with CLANG35

ArmVirtPkg/ArmVirtQemuKernel.dsc | 8 ++++++++
ArmVirtPkg/ArmVirtXen.dsc | 9 +++++++++
EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf | 2 +-
3 files changed, 18 insertions(+), 1 deletion(-)

--
2.7.4


[edk2-platforms/branch]: pentium-celeron-n-udk2015

Guo, Mang <mang.guo@...>
 

Restructured BraswellPlatformPkg on pentium-celeron-n-udk2015 branch of edk2-platforms to follow Cover Creek requirement.



URL fork of edk2-platforms with the restructured code for review:
https://github.com/mangguo321/edk2-platforms/tree/Braswell


[Patch][Vlv2TbltDevicePkg] Enable Spread Spectrum of on-chip devices

Wei, David <david.wei@...>
 

From bf33c2b16e718f9b241889d2f3e863719731f340 Mon Sep 17 00:00:00 2001
From: david wei <david.wei@intel.com>
Date: Wed, 3 Aug 2016 16:02:34 +0800
Subject: [PATCH] Enable Spread Spectrum of on-chip devices.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Wei <david.wei@intel.com>
---
Vlv2TbltDevicePkg/Stitch/IFWIHeader/IFWI_HEADER.bin | Bin 4096 -> 4096 bytes
.../Stitch/IFWIHeader/IFWI_HEADER_SPILOCK.bin | Bin 4096 -> 4096 bytes
2 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/Vlv2TbltDevicePkg/Stitch/IFWIHeader/IFWI_HEADER.bin b/Vlv2TbltDevicePkg/Stitch/IFWIHeader/IFWI_HEADER.bin
index ca10f7af61b91e1daf79e374c6c837ee06e6ea4c..aa551cbc189290a6e1cc29a75ccd3b058e326e45 100644
GIT binary patch
delta 15
WcmZorXi(U|!^o7tyqS;j6CVH}&IBa@

delta 15
WcmZorXi(U|!^p(Iu$hnX6CVH{90S4t

diff --git a/Vlv2TbltDevicePkg/Stitch/IFWIHeader/IFWI_HEADER_SPILOCK.bin b/Vlv2TbltDevicePkg/Stitch/IFWIHeader/IFWI_HEADER_SPILOCK.bin
index f2dcb0067d1a48f08b4c4048362443b5c7095aa9..defc55461161943c6a62dda3f9c4315e30f05d61 100644
GIT binary patch
delta 15
WcmZorXi(U|!^o7tyqS;j6CVH}&IBa@

delta 15
WcmZorXi(U|!^p(Iu$hnX6CVH{90S4t

--
2.7.1.windows.2


Re: [PATCH 2/4] BaseTools-Conf:Introduce CLANG38 new toolchain for x86

Ard Biesheuvel
 

Hello Steven,

On 3 August 2016 at 08:48, Shi, Steven <steven.shi@intel.com> wrote:
This adds support for LLVM 3.8.x in LTO mode for IA32 and X64.
CLANG38 enable LLVM Link Time Optimization (LTO) and code size
optimization flag (-Oz) by default for aggressive code size
improvement. CLANG38 X64 code is small code model + PIE.

CLANG LTO needs PIE in link flags to generate PIE code correctly,
otherwise the PIE is not really enabled. (e.g. OvmfPkgX64 will
hang in 64bits SEC at high address because of small model code
displacement overflow).
This is probably caused by the same issue I am addressing with the
series I sent out yesterday, to pass the CC flags to the DLINK
command.

The reason is that code is generated by the link pass, so it needs to
see the same -fpie -mcmodel=small options that we passed to the
compiler as wel.

Could you check whether replacing '-Wl,-pie' with -fpie does the trick
as well? As I mentioned before, creating a PIE executable at link time
is not the same as generatic position independent code at compile time
(whether it is via $(CC) or via $(DLINK)). The PIE executable will
contain a .rela section that partially overlaps with other absolute
relocations, so it is best to avoid it.

Some more comments below

Test pass platforms: OVMF (OvmfPkgIa32.dsc, OvmfPkgX64.dsc and
OvmfPkgIa32X64.dsc).
Test compiler and linker version: LLVM 3.8, GNU ld 2.26.

Example steps to use the CLANG38 tool chain to build OVMF platform:
1. Download and extract the llvm 3.8.0 Pre-Built Binaries from
http://www.llvm.org/releases/ (e.g. http://www.llvm.org/releases/
3.8.0/clang+llvm-3.8.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz and
extract it as ~/clang38).
2. Copy LLVMgold.so from https://github.com/shijunjing/edk2/blob/
llvm/BaseTools/Bin/LLVMgold.so to above clang lib folder (e.g.
~/clang38/lib/LLVMgold.so)
3. Install new version linker with plugin support (e.g. ld 2.26 in
GNU Binutils 2.26 or Ubuntu16.04)
$ cd edk2
$ git checkout llvm
$ export CLANG38_BIN=path/to/your/clang38/
(e.g. export CLANG38_BIN=~/clang38/bin/)
$ source edksetup.sh
$ make -C BaseTools/Source/C
$ build -t CLANG38 -a X64 -p OvmfPkg/OvmfPkgX64.dsc -n 5 -b DEBUG
-DDEBUG_ON_SERIAL_PORT
$ cd edk2/Build/OvmfX64/DEBUG_CLANG38/FV
$ qemu-system-x86_64.exe -bios OVMF.fd -serial file:serial.log -m 4096
-hda fat:.

If you want, you can build and install GNU Binutils 2.26 as below steps
in Ubuntu:
Download binutils-2.26 source code from http://ftp.gnu.org/gnu/binutils/
and extract it to ~/binutils-2.26
$sudo apt-get install bison
$sudo apt-get install flex
Install other necessary binutils build tools if missing
$ mkdir build
$ cd build
$ ../binutils-2.26/configure --enable-gold --enable-plugins
--disable-werror --prefix=/usr
$ make -j 5
$ sudo make install

If you want, you can build LLVMgold.so as below steps
Download llvm-3.8.0 source code from http://www.llvm.org/releases/
3.8.0/llvm-3.8.0.src.tar.xz and extract it to ~/llvm-3.8.0.src
Download clang3.8.0 source code from http://www.llvm.org/releases/
3.8.0/cfe-3.8.0.src.tar.xz and extract it to ~/llvm-3.8.0.src/tools/clang
Refer http://clang.llvm.org/get_started.html to Install other necessary
clang build tools if missing
$ mkdir llvm38build
$ cd llvm38build
If your GNU Binutils 2.26 is in /home/jshi19/binutils-2.26,
$ cmake ../llvm-3.8.0.src -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release"
-DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_VERBOSE_MAKEFILE=ON
-DCMAKE_CXX_COMPILER="/usr/bin/g++" -DCMAKE_C_COMPILER="/usr/bin/gcc"
-DLLVM_BINUTILS_INCDIR=/home/jshi19/binutils-2.26/include
$ make -j 5 LLVMgold The LLVMgold.so is in ~/llvm38build/lib/LLVMgold.so

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Steven Shi <steven.shi@intel.com>
---
BaseTools/Conf/tools_def.template | 81 +++++++++++++++++++++++++++++++++++++++
1 file changed, 81 insertions(+)
mode change 100644 => 100755 BaseTools/Conf/tools_def.template

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
old mode 100644
new mode 100755
index fd9eccb..6d964f1
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -5428,6 +5428,87 @@ RELEASE_CLANG35_AARCH64_CC_FLAGS = DEF(CLANG35_AARCH64_CC_FLAGS) $(ARCHCC_FLAGS)

####################################################################################
#
+# Clang 3.8 - This configuration is used to compile under Linux to produce
+# PE/COFF binaries using LLVM/Clang 3.8 with Link Time Optimization enabled
+#
+####################################################################################
+*_CLANG38_*_*_FAMILY = GCC
+*_CLANG38_*_MAKE_PATH = DEF(GCC5_IA32_PREFIX)make
+*_CLANG38_*_*_DLL = ENV(CLANG38_DLL)
+*_CLANG38_*_ASL_PATH = DEF(UNIX_IASL_BIN)
+
+*_CLANG38_*_APP_FLAGS =
+*_CLANG38_*_ASL_FLAGS = DEF(IASL_FLAGS)
+*_CLANG38_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
+
+DEFINE CLANG38_IA32_PREFIX = ENV(CLANG38_BIN)
+DEFINE CLANG38_X64_PREFIX = ENV(CLANG38_BIN)
+
+DEFINE CLANG38_IA32_TARGET = -target i686-pc-linux-gnu
+DEFINE CLANG38_X64_TARGET = -target x86_64-pc-linux-gnu
+
+DEFINE CLANG38_ALL_CC_FLAGS = DEF(GCC44_ALL_CC_FLAGS) -Wno-empty-body -fno-stack-protector -fno-builtin -mms-bitfields -Wno-address -Wno-shift-negative-value -Wno-parentheses-equality -Wno-unknown-pragmas -Wno-tautological-constant-out-of-range-compare -Wno-incompatible-library-redeclaration -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -msoft-float -mno-implicit-float -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang -funsigned-char -fno-ms-extensions -Wno-null-dereference -Wno-tautological-compare
+
+###########################
+# CLANG38 IA32 definitions
+###########################
+*_CLANG38_IA32_OBJCOPY_PATH = DEF(GCC5_IA32_PREFIX)objcopy
Why are you using the GCC5 prefix here? A clang user may not set GCC5_BIN

+*_CLANG38_IA32_CC_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_SLINK_PATH = DEF(CLANG38_IA32_PREFIX)llvm-ar
+*_CLANG38_IA32_DLINK_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_ASLDLINK_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_ASM_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_PP_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_VFRPP_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_ASLCC_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_ASLPP_PATH = DEF(CLANG38_IA32_PREFIX)clang
+*_CLANG38_IA32_RC_PATH = DEF(GCC5_IA32_PREFIX)objcopy
+
+*_CLANG38_IA32_ASLCC_FLAGS = -x c -Os -m32 DEF(CLANG38_IA32_TARGET) -flto
Does LTO make any sense for ACPI tables?

+*_CLANG38_IA32_ASLDLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-Oz -Wl,-melf_i386 -Wl,--entry,ReferenceAcpiTable -Wl,-u,ReferenceAcpiTable
+*_CLANG38_IA32_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m32 -march=i386 DEF(CLANG38_IA32_TARGET)
+DEBUG_CLANG38_IA32_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANG38_IA32_TARGET) -g
+RELEASE_CLANG38_IA32_CC_FLAGS = DEF(CLANG38_ALL_CC_FLAGS) -m32 -Oz -flto -march=i586 DEF(CLANG38_IA32_TARGET)
+*_CLANG38_IA32_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-Oz -Wl,-melf_i386 -Wl,--oformat=elf32-i386
+*_CLANG38_IA32_DLINK2_FLAGS = DEF(GCC5_IA32_DLINK2_FLAGS)
+*_CLANG38_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
+*_CLANG38_IA32_OBJCOPY_FLAGS =
+*_CLANG38_IA32_NASM_FLAGS = -f elf32
+*_CLANG38_IA32_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG38_IA32_TARGET)
+*_CLANG38_IA32_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_IA32_TARGET)
+*_CLANG38_IA32_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_IA32_TARGET)
+
+##########################
+# CLANG38 X64 definitions
+##########################
+*_CLANG38_X64_OBJCOPY_PATH = DEF(GCC5_X64_PREFIX)objcopy
+*_CLANG38_X64_CC_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_SLINK_PATH = DEF(CLANG38_X64_PREFIX)llvm-ar
+*_CLANG38_X64_DLINK_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_ASLDLINK_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_ASM_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_PP_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_VFRPP_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_ASLCC_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_ASLPP_PATH = DEF(CLANG38_X64_PREFIX)clang
+*_CLANG38_X64_RC_PATH = DEF(GCC5_X64_PREFIX)objcopy
+
+*_CLANG38_X64_ASLCC_FLAGS = -x c -Os -m64 -flto DEF(CLANG38_X64_TARGET)
+*_CLANG38_X64_ASLDLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-Oz -Wl,-melf_x86_64 -Wl,--entry,ReferenceAcpiTable -Wl,-u,ReferenceAcpiTable -Wl,-pie -mcmodel=small
+*_CLANG38_X64_ASM_FLAGS = DEF(GCC5_ASM_FLAGS) -m64 DEF(CLANG38_X64_TARGET)
+DEBUG_CLANG38_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
+RELEASE_CLANG38_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)
+*_CLANG38_X64_DLINK_FLAGS = DEF(GCC5_IA32_X64_DLINK_FLAGS) -Wl,-Oz -Wl,-melf_x86_64 -Wl,--oformat=elf64-x86-64 -Wl,-pie -mcmodel=small
+*_CLANG38_X64_DLINK2_FLAGS = DEF(GCC5_X64_DLINK2_FLAGS)
+*_CLANG38_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
+*_CLANG38_X64_OBJCOPY_FLAGS =
+*_CLANG38_X64_NASM_FLAGS = -f elf64
+*_CLANG38_X64_PP_FLAGS = DEF(GCC_PP_FLAGS) DEF(CLANG38_X64_TARGET)
+*_CLANG38_X64_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS) DEF(CLANG38_X64_TARGET)
+*_CLANG38_X64_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS) DEF(CLANG38_X64_TARGET)
+
+####################################################################################
+#
# Cygwin GCC And Intel ACPI Compiler
#
####################################################################################
--
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


Re: [PATCH 1/4] BaseTools-Conf:Remove short dash in ar flag for LLVM

Ard Biesheuvel
 

On 3 August 2016 at 08:48, Shi, Steven <steven.shi@intel.com> wrote:
Both binutils ar and LLVM ar support "cr", but LLVM ar doens't
support add "-" in the flags, and llvm-ar cannot accept "-cr".
So remove the short dash "-" to make llvm archives work.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Steven Shi <steven.shi@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
BaseTools/Conf/build_rule.template | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
mode change 100644 => 100755 BaseTools/Conf/build_rule.template

diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule.template
old mode 100644
new mode 100755
index 9adf391..6e7b7d4
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -266,7 +266,7 @@
"$(SLINK)" $(SLINK_FLAGS) /OUT:${dst} @$(OBJECT_FILES_LIST)

<Command.GCC, Command.GCCLD>
- "$(SLINK)" -cr ${dst} $(SLINK_FLAGS) @$(OBJECT_FILES_LIST)
+ "$(SLINK)" cr ${dst} $(SLINK_FLAGS) @$(OBJECT_FILES_LIST)

<Command.RVCT>
"$(SLINK)" $(SLINK_FLAGS) ${dst} --via $(OBJECT_FILES_LIST)
--
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[PATCH 4/4] ShellPkg-UefiShellCommandLib: Add EFIAPI in VA_List library function

Shi, Steven <steven.shi@...>
 

Add EFIAPI in CatPrint library function. Every function which uses
variable list need explicit use EFIAPI to force use MS ABI. This change
is needed to pass CLANG38 build.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Steven Shi <steven.shi@intel.com>
---
ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c | 1 +
1 file changed, 1 insertion(+)
mode change 100644 => 100755 ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c

diff --git a/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c b/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
old mode 100644
new mode 100755
index d157ebb..979693a
--- a/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
+++ b/ShellPkg/Library/UefiShellCommandLib/ConsistMapping.c
@@ -85,6 +85,7 @@ typedef struct {

**/
EFI_STATUS
+EFIAPI
CatPrint (
IN OUT POOL_PRINT *Str,
IN CHAR16 *Fmt,
--
2.7.4


[PATCH 3/4] ShellPkg-UefiShellTftpCommandLib: Replace compiler builtin

Shi, Steven <steven.shi@...>
 

Use explicit CopyMem to replace compiler builtin to do the structure
values assignment. This change is needed to pass CLANG38 build.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Steven Shi <steven.shi@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
---
ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
mode change 100644 => 100755 ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c

diff --git a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
old mode 100644
new mode 100755
index 666ee9d..5c50797
--- a/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
+++ b/ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
@@ -342,7 +342,7 @@ ShellCommandRunTftp (
goto Error;
}

- Mtftp4ConfigData = DefaultMtftp4ConfigData;
+ CopyMem (&Mtftp4ConfigData, &DefaultMtftp4ConfigData, sizeof (EFI_MTFTP4_CONFIG_DATA));

//
// Check the host IPv4 address
--
2.7.4