Hi Scott,

What is the purpose of GCCLINK_PREFIX?  Why can't the Wl flag just be included 
in tools_def.txt as required?

Thanks,

Mike

-----Original Message-----
From: Scott Duplichan [mailto:sc...@notabs.org] 
Sent: Tuesday, July 14, 2015 9:44 AM
To: edk2-devel@lists.sourceforge.net
Cc: Mcdaniel, Daryl
Subject: [edk2] [PATCH] BaseTools: Add GCC49LTO tool chain: GCC49 with link 
time optimization

BaseTools: Add GCC49LTO tool chain: GCC49 with link time optimization

New tool chain GCC49LTO uses gcc -flto (link time optimization) for
DEBUG and RELEASE builds of IA32, X64, and AARCH64. 

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Scott Duplichan <sc...@notabs.org>
---

This patch enables gcc link time optimization by adding a stand-alone
GCC49LTO tool chain. The existing GCC49 and other GCC tool chains remain
unmodified. Link time optimization is added for IA32, X64 and AARCH64.
ARM is omitted for the time being because I am unable to build some of
the ARM projects. Link time optimization is added for RELEASE and DEBUG
builds. It is not enabled for NOOPT builds because the gcc documentation
states "Link-time optimization does not work well with generation of
debugging information. Combining ‘-flto’ with ‘-g’ is currently
experimental and expected to produce unexpected results."

Builds that complete error free with GCC49 also complete with GCC49LTO.
However, use of -flto allows gcc to see and warn about an AutoGen.h/
AutoGen.c declaration difference for PCD array data. Other warnings
are exposed when ASSERT code is expanded and optimized. A separate
patch that allows overriding the warning as error option lets the
builds complete so that -flto can be tested before the autogen and
other warning issues are resolved.

The only successful boot test so far is Duet. The patches from
last year are still needed. I may rebsubmit these patches. GCC
builds using the latest CorebootPayloadPkg code are not working
on my board, so this needs to be debugged before it can be used
as a gcc -flto test case.

While this patch mainly targets BaseTools, some non-BaseTools files
are changed: ArmVirt.dsc.inc and ArmVExpress.dsc.inc are modified
to add GCC LTO compatibility to their overrides of DLINK_FLAGS.
StdLib.inc is modified to disable link time optimization for its
build. This is because gcc code generation for StdLib contains calls
to compiler helper functions. While this can work with link time 
optimization, it requires linker option -plugin-opt=-pass-through=.
Right now we have no easy way to generate the library path needed
by -plugin-opt=-pass-through=.

Laszlo suggested adding link time optimization support for GCC48
since it ships with RHEL-7.1. I will do that in a day or two. I
want to submit this patch now because I have done a lot of build
testing with it.


 ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc |   2 +-
 ArmVirtPkg/ArmVirt.dsc.inc                        |   2 +-
 BaseTools/Conf/build_rule.template                |   2 +-
 BaseTools/Conf/tools_def.template                 | 178 ++++++++++++++++++++++
 StdLib/StdLib.inc                                 |   6 +
 5 files changed, 187 insertions(+), 3 deletions(-)

diff --git a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc 
b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
index 37a1ef7..1736104 100644
--- a/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
+++ b/ArmPlatformPkg/ArmVExpressPkg/ArmVExpress.dsc.inc
@@ -13,7 +13,7 @@
 #
 
 [BuildOptions.AARCH64.EDKII.DXE_RUNTIME_DRIVER]
-  GCC:*_*_AARCH64_DLINK_FLAGS = 
--script=$(EDK_TOOLS_PATH)/Scripts/gcc-aarch64-64K-align-ld-script
+  GCC:*_*_AARCH64_DLINK_FLAGS = 
$(GCCLINK_PREFIX)--script=$(EDK_TOOLS_PATH)/Scripts/gcc-aarch64-64K-align-ld-script
 
 [LibraryClasses.common]
 !if $(TARGET) == RELEASE
diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index d3f401b..4e2b237 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -18,7 +18,7 @@
   DEFINE TTY_TERMINAL            = FALSE
 
 [BuildOptions.AARCH64.EDKII.DXE_RUNTIME_DRIVER]
-  GCC:*_*_AARCH64_DLINK_FLAGS = 
--script=$(EDK_TOOLS_PATH)/Scripts/gcc-aarch64-64K-align-ld-script
+  GCC:*_*_AARCH64_DLINK_FLAGS = 
$(GCCLINK_PREFIX)--script=$(EDK_TOOLS_PATH)/Scripts/gcc-aarch64-64K-align-ld-script
 
 [LibraryClasses.common]
 !if $(TARGET) == RELEASE
diff --git a/BaseTools/Conf/build_rule.template 
b/BaseTools/Conf/build_rule.template
index 596d41d..86ea464 100644
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -279,7 +279,7 @@
         "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) 
@$(STATIC_LIBRARY_FILES_LIST)
 
     <Command.GCC>
-        "$(DLINK)" -o ${dst} $(DLINK_FLAGS) --start-group $(DLINK_SPATH) 
@$(STATIC_LIBRARY_FILES_LIST) --end-group $(DLINK2_FLAGS)
+        "$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(GCCLINK_PREFIX)--start-group 
$(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) $(GCCLINK_PREFIX)--end-group 
$(DLINK2_FLAGS)
         "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
 
     <Command.ARMGCC, Command.ARMLINUXGCC>
diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 8e5750e..8d1b319 100644
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -344,6 +344,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
+#   GCC49LTO    -Linux,Windows-  Requires:
+#                             LTO capable GCC 4.9 targeting x86_64-linux-gnu, 
aarch64-linux-gnu, or arm-linux-gnueabi
+#                        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:
@@ -3920,6 +3926,39 @@ DEFINE GCC49_AARCH64_DLINK_FLAGS     = 
DEF(GCC48_AARCH64_DLINK_FLAGS)
 DEFINE GCC49_ARM_ASLDLINK_FLAGS      = DEF(GCC48_ARM_ASLDLINK_FLAGS)
 DEFINE GCC49_AARCH64_ASLDLINK_FLAGS  = DEF(GCC48_AARCH64_ASLDLINK_FLAGS)
 
+DEFINE GCC49LTO_IA32_BASE_CC_FLAGS       = -g -fshort-wchar 
-fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections 
-fdata-sections -include AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings -m32 
-malign-double -fno-stack-protector -D EFI32 -fno-builtin
+DEFINE GCC49LTO_IA32_X64_DLINK_COMMON    = -nostdlib 
-Wl,-n,-q,--gc-sections,--script=$(EDK_TOOLS_PATH)/Scripts/gcc4.9-ld-script
+DEFINE GCC49LTO_IA32_X64_ASLDLINK_FLAGS  = 
DEF(GCC49LTO_IA32_X64_DLINK_COMMON),--entry,ReferenceAcpiTable,-u,ReferenceAcpiTable
+DEFINE GCC49LTO_IA32_X64_DLINK_FLAGS     = 
DEF(GCC49LTO_IA32_X64_DLINK_COMMON),--entry,$(IMAGE_ENTRY_POINT),-u,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
+DEFINE GCC49LTO_IA32_DLINK_FLAGS         = 
DEF(GCC49LTO_IA32_X64_DLINK_FLAGS),-melf_i386,--oformat=elf32-i386
+DEFINE GCC49LTO_X64_BASE_CC_FLAGS        = -g -fshort-wchar 
-fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections 
-fdata-sections -include AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings -m64 
-fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" -DNO_BUILTIN_VA_FUNCS 
-mno-red-zone -Wno-address -mcmodel=large -fno-builtin
+DEFINE GCC49LTO_X64_DLINK_FLAGS          = 
DEF(GCC49LTO_IA32_X64_DLINK_FLAGS),-melf_x86_64,--oformat=elf64-x86-64
+DEFINE GCC49LTO_ASM_FLAGS                = DEF(GCC48_ASM_FLAGS)
+DEFINE GCC49LTO_ARM_AARCH64_DLINK_COMMON = -nostdlib 
-Wl,--emit-relocs,--gc-sections,-u,$(IMAGE_ENTRY_POINT),-e,$(IMAGE_ENTRY_POINT),-Map,$(DEST_DIR_DEBUG)/$(BASE_NAME).map
+
+DEFINE GCC49LTO_ARM_ASM_FLAGS            = DEF(GCC48_ARM_ASM_FLAGS)
+DEFINE GCC49LTO_ARM_BASE_CC_FLAGS        = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) 
-DSTRING_ARRAY_NAME=$(BASE_NAME)Strings -g -fshort-wchar -fno-strict-aliasing 
-Wall -Werror -Wno-array-bounds -include AutoGen.h -mword-relocations 
-mlittle-endian -mabi=aapcs -mapcs -fno-short-enums -fsigned-char 
-ffunction-sections -fdata-sections -fomit-frame-pointer -fno-builtin 
-Wno-address -mthumb -mfloat-abi=soft -fstack-protector -mno-unaligned-access
+DEFINE GCC49LTO_ARM_DLINK_FLAGS          = 
DEF(GCC49LTO_ARM_AARCH64_DLINK_COMMON),-Ttext=0x0
+DEFINE GCC49LTO_ARM_ASLDLINK_FLAGS       = 
DEF(GCC49LTO_ARM_DLINK_FLAGS),--entry,ReferenceAcpiTable,-u,ReferenceAcpiTable
+
+DEFINE GCC49LTO_AARCH64_ASM_FLAGS        = DEF(GCC48_AARCH64_ASM_FLAGS)
+DEFINE GCC49LTO_AARCH64_BASE_CC_FLAGS    = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) 
-DSTRING_ARRAY_NAME=$(BASE_NAME)Strings -g -fshort-wchar -fno-strict-aliasing 
-Wall -Werror -Wno-array-bounds -include AutoGen.h -mcmodel=large 
-mlittle-endian -fno-short-enums -fverbose-asm -fsigned-char 
-ffunction-sections -fdata-sections -fomit-frame-pointer -fno-builtin 
-Wno-address
+DEFINE GCC49LTO_AARCH64_DLINK_FLAGS      = 
DEF(GCC49LTO_ARM_AARCH64_DLINK_COMMON),--script=$(EDK_TOOLS_PATH)/Scripts/gcc-aarch64-ld-script
+DEFINE GCC49LTO_AARCH64_ASLDLINK_FLAGS   = 
DEF(GCC49LTO_AARCH64_DLINK_FLAGS),--entry,ReferenceAcpiTable,-u,ReferenceAcpiTable
+
+DEFINE GCC49LTO_IA32_DEBUG_FLAGS         = -Os -flto
+DEFINE GCC49LTO_IA32_RELEASE_FLAGS       = -Os -flto 
-Wno-unused-but-set-variable
+DEFINE GCC49LTO_IA32_NOOPT_FLAGS         = -Og
+DEFINE GCC49LTO_X64_DEBUG_FLAGS          = -Os -flto
+DEFINE GCC49LTO_X64_RELEASE_FLAGS        = -Os -flto 
-Wno-unused-but-set-variable
+DEFINE GCC49LTO_X64_NOOPT_FLAGS          = -Og
+DEFINE GCC49LTO_ARM_DEBUG_FLAGS          = -Og
+DEFINE GCC49LTO_ARM_RELEASE_FLAGS        = -Wno-unused-but-set-variable
+DEFINE GCC49LTO_ARM_NOOPT_FLAGS          = -Og
+DEFINE GCC49LTO_AARCH64_DEBUG_FLAGS      = -Og -flto
+DEFINE GCC49LTO_AARCH64_RELEASE_FLAGS    = -flto -Wno-unused-but-set-variable
+DEFINE GCC49LTO_AARCH64_NOOPT_FLAGS      = -Og
+
 
####################################################################################
 #
 # Unix GCC And Intel Linux ACPI Compiler
@@ -4613,6 +4652,145 @@ RELEASE_GCC49_AARCH64_CC_FLAGS   = 
DEF(GCC49_AARCH64_CC_FLAGS) -Wno-unused-but-s
 
 
####################################################################################
 #
+# GCC 4.9 LTO - This configuration is used to compile under Linux to produce
+#               PE/COFF binaries using GCC 4.9 with Link Time Optimization 
enabled.
+#
+####################################################################################
+*_GCC49LTO_*_*_FAMILY                = GCC
+
+*_GCC49LTO_*_MAKE_PATH               = DEF(GCC49_IA32_PREFIX)make
+*_GCC49LTO_*_*_DLL                   = ENV(GCC49_DLL)
+*_GCC49LTO_*_ASL_PATH                = DEF(UNIX_IASL_BIN)
+*_GCC49LTO_*_GCCLINK_PREFIX          = -Wl,
+
+*_GCC49LTO_*_PP_FLAGS                = DEF(GCC_PP_FLAGS)
+*_GCC49LTO_*_ASLPP_FLAGS             = DEF(GCC_ASLPP_FLAGS)
+*_GCC49LTO_*_ASLCC_FLAGS             = DEF(GCC_ASLCC_FLAGS)
+*_GCC49LTO_*_VFRPP_FLAGS             = DEF(GCC_VFRPP_FLAGS)
+*_GCC49LTO_*_APP_FLAGS               =
+*_GCC49LTO_*_ASL_FLAGS               = DEF(IASL_FLAGS)
+*_GCC49LTO_*_ASL_OUTFLAGS            = DEF(IASL_OUTFLAGS)
+
+##################
+# GCC49LTO IA32 definitions
+##################
+*_GCC49LTO_IA32_OBJCOPY_PATH         = DEF(GCC49_IA32_PREFIX)objcopy
+*_GCC49LTO_IA32_CC_PATH              = DEF(GCC49_IA32_PREFIX)gcc
+*_GCC49LTO_IA32_SLINK_PATH           = DEF(GCC49_IA32_PREFIX)gcc-ar
+*_GCC49LTO_IA32_DLINK_PATH           = DEF(GCC49_IA32_PREFIX)gcc
+*_GCC49LTO_IA32_ASLDLINK_PATH        = DEF(GCC49_IA32_PREFIX)gcc
+*_GCC49LTO_IA32_ASM_PATH             = DEF(GCC49_IA32_PREFIX)gcc
+*_GCC49LTO_IA32_PP_PATH              = DEF(GCC49_IA32_PREFIX)gcc
+*_GCC49LTO_IA32_VFRPP_PATH           = DEF(GCC49_IA32_PREFIX)gcc
+*_GCC49LTO_IA32_ASLCC_PATH           = DEF(GCC49_IA32_PREFIX)gcc
+*_GCC49LTO_IA32_ASLPP_PATH           = DEF(GCC49_IA32_PREFIX)gcc
+*_GCC49LTO_IA32_RC_PATH              = DEF(GCC49_IA32_PREFIX)objcopy
+
+      *_GCC49LTO_IA32_ASLCC_FLAGS    = DEF(GCC_ASLCC_FLAGS) -m32
+      *_GCC49LTO_IA32_ASLDLINK_FLAGS = 
DEF(GCC49LTO_IA32_X64_ASLDLINK_FLAGS),-melf_i386
+      *_GCC49LTO_IA32_ASM_FLAGS      = DEF(GCC49LTO_ASM_FLAGS) -m32 -march=i386
+  DEBUG_GCC49LTO_IA32_CC_FLAGS       = DEF(GCC49LTO_IA32_BASE_CC_FLAGS) 
DEF(GCC49LTO_IA32_DEBUG_FLAGS) -c
+RELEASE_GCC49LTO_IA32_CC_FLAGS       = DEF(GCC49LTO_IA32_BASE_CC_FLAGS) 
DEF(GCC49LTO_IA32_RELEASE_FLAGS) -c
+  NOOPT_GCC49LTO_IA32_CC_FLAGS       = DEF(GCC49LTO_IA32_BASE_CC_FLAGS) 
DEF(GCC49LTO_IA32_NOOPT_FLAGS) -c
+  DEBUG_GCC49LTO_IA32_DLINK_FLAGS    = DEF(GCC49LTO_IA32_DLINK_FLAGS) 
DEF(GCC49LTO_IA32_BASE_CC_FLAGS) DEF(GCC49LTO_IA32_DEBUG_FLAGS)
+RELEASE_GCC49LTO_IA32_DLINK_FLAGS    = DEF(GCC49LTO_IA32_DLINK_FLAGS) 
DEF(GCC49LTO_IA32_BASE_CC_FLAGS) DEF(GCC49LTO_IA32_RELEASE_FLAGS)
+  NOOPT_GCC49LTO_IA32_DLINK_FLAGS    = DEF(GCC49LTO_IA32_DLINK_FLAGS) 
DEF(GCC49LTO_IA32_BASE_CC_FLAGS) DEF(GCC49LTO_IA32_NOOPT_FLAGS)
+      *_GCC49LTO_IA32_RC_FLAGS       = DEF(GCC_IA32_RC_FLAGS)
+      *_GCC49LTO_IA32_OBJCOPY_FLAGS  =
+      *_GCC49LTO_IA32_NASM_FLAGS     = -f elf32
+
+##################
+# GCC49LTO X64 definitions
+##################
+*_GCC49LTO_X64_OBJCOPY_PATH          = DEF(GCC49_X64_PREFIX)objcopy
+*_GCC49LTO_X64_CC_PATH               = DEF(GCC49_X64_PREFIX)gcc
+*_GCC49LTO_X64_SLINK_PATH            = DEF(GCC49_X64_PREFIX)gcc-ar
+*_GCC49LTO_X64_DLINK_PATH            = DEF(GCC49_X64_PREFIX)gcc
+*_GCC49LTO_X64_ASLDLINK_PATH         = DEF(GCC49_X64_PREFIX)gcc
+*_GCC49LTO_X64_ASM_PATH              = DEF(GCC49_X64_PREFIX)gcc
+*_GCC49LTO_X64_PP_PATH               = DEF(GCC49_X64_PREFIX)gcc
+*_GCC49LTO_X64_VFRPP_PATH            = DEF(GCC49_X64_PREFIX)gcc
+*_GCC49LTO_X64_ASLCC_PATH            = DEF(GCC49_X64_PREFIX)gcc
+*_GCC49LTO_X64_ASLPP_PATH            = DEF(GCC49_X64_PREFIX)gcc
+*_GCC49LTO_X64_RC_PATH               = DEF(GCC49_X64_PREFIX)objcopy
+
+*_GCC49LTO_X64_ASLCC_FLAGS           = DEF(GCC_ASLCC_FLAGS) -m64
+*_GCC49LTO_X64_ASLDLINK_FLAGS        = 
DEF(GCC49LTO_IA32_X64_ASLDLINK_FLAGS),-melf_x86_64
+*_GCC49LTO_X64_ASM_FLAGS             = DEF(GCC49LTO_ASM_FLAGS) -m64
+  DEBUG_GCC49LTO_X64_CC_FLAGS        = DEF(GCC49LTO_X64_BASE_CC_FLAGS) 
DEF(GCC49LTO_X64_DEBUG_FLAGS) -c
+RELEASE_GCC49LTO_X64_CC_FLAGS        = DEF(GCC49LTO_X64_BASE_CC_FLAGS) 
DEF(GCC49LTO_X64_RELEASE_FLAGS) -c
+  NOOPT_GCC49LTO_X64_CC_FLAGS        = DEF(GCC49LTO_X64_BASE_CC_FLAGS) 
DEF(GCC49LTO_X64_NOOPT_FLAGS) -c
+  DEBUG_GCC49LTO_X64_DLINK_FLAGS     = DEF(GCC49LTO_X64_DLINK_FLAGS) 
DEF(GCC49LTO_X64_BASE_CC_FLAGS) DEF(GCC49LTO_X64_DEBUG_FLAGS)
+RELEASE_GCC49LTO_X64_DLINK_FLAGS     = DEF(GCC49LTO_X64_DLINK_FLAGS) 
DEF(GCC49LTO_X64_BASE_CC_FLAGS) DEF(GCC49LTO_X64_RELEASE_FLAGS)
+  NOOPT_GCC49LTO_X64_DLINK_FLAGS     = DEF(GCC49LTO_X64_DLINK_FLAGS) 
DEF(GCC49LTO_X64_BASE_CC_FLAGS) DEF(GCC49LTO_X64_NOOPT_FLAGS)
+      *_GCC49LTO_X64_RC_FLAGS        = DEF(GCC_X64_RC_FLAGS)
+      *_GCC49LTO_X64_OBJCOPY_FLAGS   =
+      *_GCC49LTO_X64_NASM_FLAGS      = -f elf64
+
+##################
+# GCC49LTO ARM definitions
+##################
+*_GCC49LTO_ARM_CC_PATH               = ENV(GCC49_ARM_PREFIX)gcc
+*_GCC49LTO_ARM_SLINK_PATH            = ENV(GCC49_ARM_PREFIX)gcc-ar
+*_GCC49LTO_ARM_DLINK_PATH            = ENV(GCC49_ARM_PREFIX)gcc
+*_GCC49LTO_ARM_ASLDLINK_PATH         = ENV(GCC49_ARM_PREFIX)gcc
+*_GCC49LTO_ARM_ASM_PATH              = ENV(GCC49_ARM_PREFIX)gcc
+*_GCC49LTO_ARM_PP_PATH               = ENV(GCC49_ARM_PREFIX)gcc
+*_GCC49LTO_ARM_VFRPP_PATH            = ENV(GCC49_ARM_PREFIX)gcc
+*_GCC49LTO_ARM_ASLCC_PATH            = ENV(GCC49_ARM_PREFIX)gcc
+*_GCC49LTO_ARM_ASLPP_PATH            = ENV(GCC49_ARM_PREFIX)gcc
+*_GCC49LTO_ARM_RC_PATH               = ENV(GCC49_ARM_PREFIX)objcopy
+
+*_GCC49LTO_ARM_ARCHCC_FLAGS          = -mthumb
+*_GCC49LTO_ARM_PLATFORM_FLAGS        = -march=armv7-a
+
+*_GCC49LTO_ARM_ASLCC_FLAGS           = DEF(GCC_ASLCC_FLAGS)
+*_GCC49LTO_ARM_ASLDLINK_FLAGS        = DEF(GCC49LTO_ARM_ASLDLINK_FLAGS)
+*_GCC49LTO_ARM_ASM_FLAGS             = DEF(GCC49LTO_ARM_ASM_FLAGS)
+*_GCC49LTO_ARM_DLINK_FLAGS           = DEF(GCC49LTO_ARM_DLINK_FLAGS)
+*_GCC49LTO_ARM_PLATFORM_FLAGS        = -march=armv7-a
+*_GCC49LTO_ARM_PP_FLAGS              = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) 
DEF(GCC_PP_FLAGS)
+*_GCC49LTO_ARM_RC_FLAGS              = DEF(GCC_ARM_RC_FLAGS)
+*_GCC49LTO_ARM_VFRPP_FLAGS           = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) 
DEF(GCC_VFRPP_FLAGS)
+
+  DEBUG_GCC49LTO_ARM_CC_FLAGS        = DEF(GCC49LTO_ARM_BASE_CC_FLAGS) 
DEF(GCC49LTO_ARM_DEBUG_FLAGS) -c
+RELEASE_GCC49LTO_ARM_CC_FLAGS        = DEF(GCC49LTO_ARM_BASE_CC_FLAGS) 
DEF(GCC49LTO_ARM_RELEASE_FLAGS) -c
+  NOOPT_GCC49LTO_ARM_CC_FLAGS        = DEF(GCC49LTO_ARM_BASE_CC_FLAGS) 
DEF(GCC49LTO_ARM_NOOPT_FLAGS) -c
+  DEBUG_GCC49LTO_ARM_DLINK_FLAGS     = DEF(GCC49LTO_ARM_DLINK_FLAGS) 
DEF(GCC49LTO_ARM_BASE_CC_FLAGS) DEF(GCC49LTO_ARM_DEBUG_FLAGS)
+RELEASE_GCC49LTO_ARM_DLINK_FLAGS     = DEF(GCC49LTO_ARM_DLINK_FLAGS) 
DEF(GCC49LTO_ARM_BASE_CC_FLAGS) DEF(GCC49LTO_ARM_RELEASE_FLAGS)
+  NOOPT_GCC49LTO_ARM_DLINK_FLAGS     = DEF(GCC49LTO_ARM_DLINK_FLAGS) 
DEF(GCC49LTO_ARM_BASE_CC_FLAGS) DEF(GCC49LTO_ARM_NOOPT_FLAGS)
+
+##################
+# GCC49LTO AARCH64 definitions
+##################
+*_GCC49LTO_AARCH64_CC_PATH           = ENV(GCC49_AARCH64_PREFIX)gcc
+*_GCC49LTO_AARCH64_SLINK_PATH        = ENV(GCC49_AARCH64_PREFIX)gcc-ar
+*_GCC49LTO_AARCH64_DLINK_PATH        = ENV(GCC49_AARCH64_PREFIX)gcc
+*_GCC49LTO_AARCH64_ASLDLINK_PATH     = ENV(GCC49_AARCH64_PREFIX)gcc
+*_GCC49LTO_AARCH64_ASM_PATH          = ENV(GCC49_AARCH64_PREFIX)gcc
+*_GCC49LTO_AARCH64_PP_PATH           = ENV(GCC49_AARCH64_PREFIX)gcc
+*_GCC49LTO_AARCH64_VFRPP_PATH        = ENV(GCC49_AARCH64_PREFIX)gcc
+*_GCC49LTO_AARCH64_ASLCC_PATH        = ENV(GCC49_AARCH64_PREFIX)gcc
+*_GCC49LTO_AARCH64_ASLPP_PATH        = ENV(GCC49_AARCH64_PREFIX)gcc
+*_GCC49LTO_AARCH64_RC_PATH           = ENV(GCC49_AARCH64_PREFIX)objcopy
+
+*_GCC49LTO_AARCH64_ASLCC_FLAGS       = DEF(GCC_ASLCC_FLAGS)
+*_GCC49LTO_AARCH64_ASLDLINK_FLAGS    = DEF(GCC49LTO_AARCH64_ASLDLINK_FLAGS)
+*_GCC49LTO_AARCH64_ASM_FLAGS         = DEF(GCC49LTO_AARCH64_ASM_FLAGS)
+*_GCC49LTO_AARCH64_PLATFORM_FLAGS=
+*_GCC49LTO_AARCH64_PP_FLAGS          = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) 
DEF(GCC_PP_FLAGS)
+*_GCC49LTO_AARCH64_RC_FLAGS          = DEF(GCC_AARCH64_RC_FLAGS)
+*_GCC49LTO_AARCH64_VFRPP_FLAGS       = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) 
DEF(GCC_VFRPP_FLAGS)
+
+  DEBUG_GCC49LTO_AARCH64_CC_FLAGS    = DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) 
DEF(GCC49LTO_AARCH64_DEBUG_FLAGS) -c
+RELEASE_GCC49LTO_AARCH64_CC_FLAGS    = DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) 
DEF(GCC49LTO_AARCH64_RELEASE_FLAGS) -c
+  NOOPT_GCC49LTO_AARCH64_CC_FLAGS    = DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) 
DEF(GCC49LTO_AARCH64_NOOPT_FLAGS) -c
+  DEBUG_GCC49LTO_AARCH64_DLINK_FLAGS = DEF(GCC49LTO_AARCH64_DLINK_FLAGS) 
DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) DEF(GCC49LTO_AARCH64_DEBUG_FLAGS)
+RELEASE_GCC49LTO_AARCH64_DLINK_FLAGS = DEF(GCC49LTO_AARCH64_DLINK_FLAGS) 
DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) DEF(GCC49LTO_AARCH64_RELEASE_FLAGS)
+  NOOPT_GCC49LTO_AARCH64_DLINK_FLAGS = DEF(GCC49LTO_AARCH64_DLINK_FLAGS) 
DEF(GCC49LTO_AARCH64_BASE_CC_FLAGS) DEF(GCC49LTO_AARCH64_NOOPT_FLAGS)
+
+####################################################################################
+#
 # Cygwin GCC And Intel ACPI Compiler
 #
 
####################################################################################
diff --git a/StdLib/StdLib.inc b/StdLib/StdLib.inc
index 1b7fcf0..1821a46 100644
--- a/StdLib/StdLib.inc
+++ b/StdLib/StdLib.inc
@@ -125,3 +125,9 @@
   ARMGCC:*_*_*_CC_FLAGS     = -nostdinc -nostdlib -DUEFI_C_SOURCE 
-Wno-unknown-pragmas -Wno-unused -Wno-format-zero-length
    XCODE:*_*_*_CC_FLAGS     = -nostdinc -nostdlib -DUEFI_C_SOURCE 
-Wno-unused-const-variable -Wno-string-compare -Wno-sometimes-uninitialized
 !endif
+
+  # For gcc link time optimization (-flto) use, library functions that resolve
+  # compiler generated calls must be compiled without -flto.
+  # Wildcard can't be used for gcc version because GCC44 predates 
-flto/-fno-lto
+  GCC:*_GCC49LTO_IA32_CC_FLAGS   = -fno-lto
+  GCC:*_GCC51LTO_IA32_CC_FLAGS   = -fno-lto

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to