File gcc-5.x-support.diff of Package OVMF

From 6f72a9f8caa287ea0a0d62a05bd3ca260c5c0c1a Mon Sep 17 00:00:00 2001
From: James Bottomley <James.Bottomley@HansenPartnership.com>
Date: Wed, 2 Mar 2016 15:02:09 -0800
Subject: [PATCH 1/3] gcc-5 .x support

Add support for gcc-5.x compiler (complete clone of gcc-49)

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
 BaseTools/Conf/tools_def.template | 164 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 161 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index 2065fa3..beaa8ff 100644
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -197,6 +197,9 @@ DEFINE GCC48_X64_PREFIX        = ENV(GCC48_BIN)
 DEFINE GCC49_IA32_PREFIX       = ENV(GCC49_BIN)
 DEFINE GCC49_X64_PREFIX        = ENV(GCC49_BIN)
 
+DEFINE GCC50_IA32_PREFIX       = ENV(GCC50_BIN)
+DEFINE GCC50_X64_PREFIX        = ENV(GCC50_BIN)
+
 DEFINE UNIX_IASL_BIN           = ENV(IASL_PREFIX)iasl
 DEFINE WIN_ASL_BIN_DIR         = C:\ASL
 DEFINE WIN_IASL_BIN            = DEF(WIN_ASL_BIN_DIR)\iasl.exe
@@ -366,6 +369,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
+#   GCC50       -Linux,Windows-  Requires:
+#                             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
 #   CLANG35     -Linux,Windows-  Requires:
 #                             Clang v3.5 or later, and GNU binutils targeting aarch64-linux-gnu or arm-linux-gnueabi
 #                        Optional:
@@ -4319,7 +4328,7 @@ NOOPT_DDK3790xASL_IPF_DLINK_FLAGS    = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF
 DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG     = --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
 RELEASE_*_*_OBJCOPY_ADDDEBUGFLAG   =
 
-DEFINE GCC_ALL_CC_FLAGS            = -g -Os -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -c -include AutoGen.h -fno-common
+DEFINE GCC_ALL_CC_FLAGS            = -g -Os -fshort-wchar -fno-strict-aliasing -Wall -Wno-array-bounds -c -include AutoGen.h -fno-common
 DEFINE GCC_IA32_CC_FLAGS           = DEF(GCC_ALL_CC_FLAGS) -m32 -malign-double -freorder-blocks -freorder-blocks-and-partition -O2 -mno-stack-arg-probe
 DEFINE GCC_X64_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-address -mno-stack-arg-probe
 DEFINE GCC_IPF_CC_FLAGS            = DEF(GCC_ALL_CC_FLAGS) -minline-int-divide-min-latency
@@ -4351,8 +4360,8 @@ DEFINE GCC_IPF_RC_FLAGS            = -I binary -O elf64-ia64-little   -B ia64
 DEFINE GCC_ARM_RC_FLAGS            = -I binary -O elf32-littlearm     -B arm     --rename-section .data=.hii
 DEFINE GCC_AARCH64_RC_FLAGS        = -I binary -O elf64-littleaarch64 -B aarch64 --rename-section .data=.hii
 
-DEFINE GCC44_ALL_CC_FLAGS            = -g -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-array-bounds -ffunction-sections -fdata-sections -c -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
-DEFINE GCC44_IA32_CC_FLAGS           = DEF(GCC44_ALL_CC_FLAGS) -m32 -march=i586 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-unwind-tables
+DEFINE GCC44_ALL_CC_FLAGS            = -g -fshort-wchar -fno-strict-aliasing -Wall -Wno-array-bounds -ffunction-sections -fdata-sections -c -include AutoGen.h -fno-common -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
+DEFINE GCC44_IA32_CC_FLAGS           = DEF(GCC44_ALL_CC_FLAGS) -m32 -malign-double -fno-stack-protector -D EFI32 -fno-asynchronous-unwind-tables
 DEFINE GCC44_X64_CC_FLAGS            = DEF(GCC44_ALL_CC_FLAGS) -m64 -fno-stack-protector "-DEFIAPI=__attribute__((ms_abi))" -DNO_BUILTIN_VA_FUNCS -mno-red-zone -Wno-address -mcmodel=large -fno-asynchronous-unwind-tables
 DEFINE GCC44_IA32_X64_DLINK_COMMON   = -nostdlib -n -q --gc-sections -z common-page-size=0x20
 DEFINE GCC44_IA32_X64_ASLDLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_COMMON) --entry ReferenceAcpiTable -u ReferenceAcpiTable
@@ -4450,6 +4459,27 @@ DEFINE GCC49_AARCH64_DLINK2_FLAGS    = DEF(GCC48_AARCH64_DLINK2_FLAGS)
 DEFINE GCC49_ARM_ASLDLINK_FLAGS      = DEF(GCC48_ARM_ASLDLINK_FLAGS)
 DEFINE GCC49_AARCH64_ASLDLINK_FLAGS  = DEF(GCC48_AARCH64_ASLDLINK_FLAGS)
 
+DEFINE GCC50_IA32_CC_FLAGS           = DEF(GCC48_IA32_CC_FLAGS)
+DEFINE GCC50_X64_CC_FLAGS            = DEF(GCC48_X64_CC_FLAGS)
+DEFINE GCC50_IA32_X64_DLINK_COMMON   = -nostdlib -n -q --gc-sections -z common-page-size=0x40
+DEFINE GCC50_IA32_X64_ASLDLINK_FLAGS = DEF(GCC50_IA32_X64_DLINK_COMMON) --entry ReferenceAcpiTable -u ReferenceAcpiTable
+DEFINE GCC50_IA32_X64_DLINK_FLAGS    = DEF(GCC50_IA32_X64_DLINK_COMMON) --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+DEFINE GCC50_IA32_DLINK2_FLAGS       = DEF(GCC48_IA32_DLINK2_FLAGS)
+DEFINE GCC50_X64_DLINK_FLAGS         = DEF(GCC50_IA32_X64_DLINK_FLAGS)  -melf_x86_64 --oformat=elf64-x86-64
+DEFINE GCC50_X64_DLINK2_FLAGS        = DEF(GCC48_X64_DLINK2_FLAGS)
+DEFINE GCC50_ASM_FLAGS               = DEF(GCC48_ASM_FLAGS)
+DEFINE GCC50_ARM_ASM_FLAGS           = DEF(GCC48_ARM_ASM_FLAGS)
+DEFINE GCC50_AARCH64_ASM_FLAGS       = DEF(GCC48_AARCH64_ASM_FLAGS)
+DEFINE GCC50_ARM_CC_FLAGS            = DEF(GCC48_ARM_CC_FLAGS)
+DEFINE GCC50_AARCH64_CC_FLAGS        = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC44_ALL_CC_FLAGS) -mcmodel=tiny DEF(GCC_AARCH64_CC_FLAGS)
+DEFINE GCC50_AARCH64_CC_XIPFLAGS     = -mstrict-align
+DEFINE GCC50_ARM_DLINK_FLAGS         = DEF(GCC48_ARM_DLINK_FLAGS)
+DEFINE GCC50_ARM_DLINK2_FLAGS        = DEF(GCC48_ARM_DLINK2_FLAGS)
+DEFINE GCC50_AARCH64_DLINK_FLAGS     = DEF(GCC48_AARCH64_DLINK_FLAGS)
+DEFINE GCC50_AARCH64_DLINK2_FLAGS    = DEF(GCC48_AARCH64_DLINK2_FLAGS)
+DEFINE GCC50_ARM_ASLDLINK_FLAGS      = DEF(GCC48_ARM_ASLDLINK_FLAGS)
+DEFINE GCC50_AARCH64_ASLDLINK_FLAGS  = DEF(GCC48_AARCH64_ASLDLINK_FLAGS)
+
 ####################################################################################
 #
 # Unix GCC And Intel Linux ACPI Compiler
@@ -5183,6 +5213,134 @@ RELEASE_GCC49_AARCH64_DLINK_FLAGS  = DEF(GCC49_AARCH64_DLINK_FLAGS)
 
 ####################################################################################
 #
+# GCC 5.x - This configuration is used to compile under Linux to produce
+#           PE/COFF binaries using GCC 4.9.
+#
+####################################################################################
+*_GCC50_*_*_FAMILY               = GCC
+
+*_GCC50_*_MAKE_PATH                    = DEF(GCC50_IA32_PREFIX)make
+*_GCC50_*_*_DLL                        = ENV(GCC50_DLL)
+*_GCC50_*_ASL_PATH                     = DEF(UNIX_IASL_BIN)
+
+*_GCC50_*_PP_FLAGS                     = DEF(GCC_PP_FLAGS)
+*_GCC50_*_ASLPP_FLAGS                  = DEF(GCC_ASLPP_FLAGS)
+*_GCC50_*_ASLCC_FLAGS                  = DEF(GCC_ASLCC_FLAGS)
+*_GCC50_*_VFRPP_FLAGS                  = DEF(GCC_VFRPP_FLAGS)
+*_GCC50_*_APP_FLAGS                    =
+*_GCC50_*_ASL_FLAGS                    = DEF(IASL_FLAGS)
+*_GCC50_*_ASL_OUTFLAGS                 = DEF(IASL_OUTFLAGS)
+
+##################
+# GCC50 IA32 definitions
+##################
+*_GCC50_IA32_OBJCOPY_PATH         = DEF(GCC50_IA32_PREFIX)objcopy
+*_GCC50_IA32_CC_PATH              = DEF(GCC50_IA32_PREFIX)gcc
+*_GCC50_IA32_SLINK_PATH           = DEF(GCC50_IA32_PREFIX)ar
+*_GCC50_IA32_DLINK_PATH           = DEF(GCC50_IA32_PREFIX)ld
+*_GCC50_IA32_ASLDLINK_PATH        = DEF(GCC50_IA32_PREFIX)ld
+*_GCC50_IA32_ASM_PATH             = DEF(GCC50_IA32_PREFIX)gcc
+*_GCC50_IA32_PP_PATH              = DEF(GCC50_IA32_PREFIX)gcc
+*_GCC50_IA32_VFRPP_PATH           = DEF(GCC50_IA32_PREFIX)gcc
+*_GCC50_IA32_ASLCC_PATH           = DEF(GCC50_IA32_PREFIX)gcc
+*_GCC50_IA32_ASLPP_PATH           = DEF(GCC50_IA32_PREFIX)gcc
+*_GCC50_IA32_RC_PATH              = DEF(GCC50_IA32_PREFIX)objcopy
+
+*_GCC50_IA32_ASLCC_FLAGS          = DEF(GCC_ASLCC_FLAGS) -m32
+*_GCC50_IA32_ASLDLINK_FLAGS       = DEF(GCC50_IA32_X64_ASLDLINK_FLAGS) -m elf_i386
+*_GCC50_IA32_ASM_FLAGS            = DEF(GCC50_ASM_FLAGS) -m32 -march=i386
+*_GCC50_IA32_CC_FLAGS             = DEF(GCC50_IA32_CC_FLAGS) -Os
+*_GCC50_IA32_DLINK_FLAGS          = DEF(GCC50_IA32_X64_DLINK_FLAGS) -m elf_i386 --oformat=elf32-i386
+*_GCC50_IA32_DLINK2_FLAGS         = DEF(GCC50_IA32_DLINK2_FLAGS)
+*_GCC50_IA32_RC_FLAGS             = DEF(GCC_IA32_RC_FLAGS)
+*_GCC50_IA32_OBJCOPY_FLAGS        = 
+*_GCC50_IA32_NASM_FLAGS           = -f elf32
+
+##################
+# GCC50 X64 definitions
+##################
+*_GCC50_X64_OBJCOPY_PATH         = DEF(GCC50_X64_PREFIX)objcopy
+*_GCC50_X64_CC_PATH              = DEF(GCC50_X64_PREFIX)gcc
+*_GCC50_X64_SLINK_PATH           = DEF(GCC50_X64_PREFIX)ar
+*_GCC50_X64_DLINK_PATH           = DEF(GCC50_X64_PREFIX)ld
+*_GCC50_X64_ASLDLINK_PATH        = DEF(GCC50_X64_PREFIX)ld
+*_GCC50_X64_ASM_PATH             = DEF(GCC50_X64_PREFIX)gcc
+*_GCC50_X64_PP_PATH              = DEF(GCC50_X64_PREFIX)gcc
+*_GCC50_X64_VFRPP_PATH           = DEF(GCC50_X64_PREFIX)gcc
+*_GCC50_X64_ASLCC_PATH           = DEF(GCC50_X64_PREFIX)gcc
+*_GCC50_X64_ASLPP_PATH           = DEF(GCC50_X64_PREFIX)gcc
+*_GCC50_X64_RC_PATH              = DEF(GCC50_X64_PREFIX)objcopy
+
+*_GCC50_X64_ASLCC_FLAGS          = DEF(GCC_ASLCC_FLAGS) -m64
+*_GCC50_X64_ASLDLINK_FLAGS       = DEF(GCC50_IA32_X64_ASLDLINK_FLAGS) -m elf_x86_64
+*_GCC50_X64_ASM_FLAGS            = DEF(GCC50_ASM_FLAGS) -m64
+*_GCC50_X64_CC_FLAGS             = DEF(GCC50_X64_CC_FLAGS)
+*_GCC50_X64_DLINK_FLAGS          = DEF(GCC50_X64_DLINK_FLAGS)
+*_GCC50_X64_DLINK2_FLAGS         = DEF(GCC50_X64_DLINK2_FLAGS)
+*_GCC50_X64_RC_FLAGS             = DEF(GCC_X64_RC_FLAGS)
+*_GCC50_X64_OBJCOPY_FLAGS        = 
+*_GCC50_X64_NASM_FLAGS           = -f elf64
+
+##################
+# GCC50 ARM definitions
+##################
+*_GCC50_ARM_CC_PATH              = ENV(GCC50_ARM_PREFIX)gcc
+*_GCC50_ARM_SLINK_PATH           = ENV(GCC50_ARM_PREFIX)ar
+*_GCC50_ARM_DLINK_PATH           = ENV(GCC50_ARM_PREFIX)ld
+*_GCC50_ARM_ASLDLINK_PATH        = ENV(GCC50_ARM_PREFIX)ld
+*_GCC50_ARM_ASM_PATH             = ENV(GCC50_ARM_PREFIX)gcc
+*_GCC50_ARM_PP_PATH              = ENV(GCC50_ARM_PREFIX)gcc
+*_GCC50_ARM_VFRPP_PATH           = ENV(GCC50_ARM_PREFIX)gcc
+*_GCC50_ARM_ASLCC_PATH           = ENV(GCC50_ARM_PREFIX)gcc
+*_GCC50_ARM_ASLPP_PATH           = ENV(GCC50_ARM_PREFIX)gcc
+*_GCC50_ARM_RC_PATH              = ENV(GCC50_ARM_PREFIX)objcopy
+
+*_GCC50_ARM_ARCHCC_FLAGS         = -mthumb
+*_GCC50_ARM_PLATFORM_FLAGS       = -march=armv7-a
+
+*_GCC50_ARM_ASLCC_FLAGS          = DEF(GCC_ASLCC_FLAGS)
+*_GCC50_ARM_ASLDLINK_FLAGS       = DEF(GCC50_ARM_ASLDLINK_FLAGS)
+*_GCC50_ARM_ASM_FLAGS            = DEF(GCC50_ARM_ASM_FLAGS)
+*_GCC50_ARM_DLINK_FLAGS          = DEF(GCC50_ARM_DLINK_FLAGS)
+*_GCC50_ARM_DLINK2_FLAGS         = DEF(GCC50_ARM_DLINK2_FLAGS)
+*_GCC50_ARM_PLATFORM_FLAGS       = -march=armv7-a
+*_GCC50_ARM_PP_FLAGS             = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
+*_GCC50_ARM_RC_FLAGS             = DEF(GCC_ARM_RC_FLAGS)
+*_GCC50_ARM_VFRPP_FLAGS          = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
+
+  DEBUG_GCC50_ARM_CC_FLAGS       = DEF(GCC50_ARM_CC_FLAGS) -O0
+RELEASE_GCC50_ARM_CC_FLAGS       = DEF(GCC50_ARM_CC_FLAGS) -Wno-unused-but-set-variable
+
+##################
+# GCC50 AARCH64 definitions
+##################
+*_GCC50_AARCH64_CC_PATH          = ENV(GCC50_AARCH64_PREFIX)gcc
+*_GCC50_AARCH64_SLINK_PATH       = ENV(GCC50_AARCH64_PREFIX)ar
+*_GCC50_AARCH64_DLINK_PATH       = ENV(GCC50_AARCH64_PREFIX)ld
+*_GCC50_AARCH64_ASLDLINK_PATH    = ENV(GCC50_AARCH64_PREFIX)ld
+*_GCC50_AARCH64_ASM_PATH         = ENV(GCC50_AARCH64_PREFIX)gcc
+*_GCC50_AARCH64_PP_PATH          = ENV(GCC50_AARCH64_PREFIX)gcc
+*_GCC50_AARCH64_VFRPP_PATH       = ENV(GCC50_AARCH64_PREFIX)gcc
+*_GCC50_AARCH64_ASLCC_PATH       = ENV(GCC50_AARCH64_PREFIX)gcc
+*_GCC50_AARCH64_ASLPP_PATH       = ENV(GCC50_AARCH64_PREFIX)gcc
+*_GCC50_AARCH64_RC_PATH          = ENV(GCC50_AARCH64_PREFIX)objcopy
+
+*_GCC50_AARCH64_ASLCC_FLAGS      = DEF(GCC_ASLCC_FLAGS)
+*_GCC50_AARCH64_ASLDLINK_FLAGS   = DEF(GCC50_AARCH64_ASLDLINK_FLAGS)
+*_GCC50_AARCH64_ASM_FLAGS        = DEF(GCC50_AARCH64_ASM_FLAGS)
+*_GCC50_AARCH64_DLINK_FLAGS      = DEF(GCC50_AARCH64_DLINK_FLAGS)
+*_GCC50_AARCH64_DLINK2_FLAGS     = DEF(GCC50_AARCH64_DLINK2_FLAGS)
+*_GCC50_AARCH64_PLATFORM_FLAGS   =
+*_GCC50_AARCH64_PP_FLAGS         = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_PP_FLAGS)
+*_GCC50_AARCH64_RC_FLAGS         = DEF(GCC_AARCH64_RC_FLAGS)
+*_GCC50_AARCH64_VFRPP_FLAGS      = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) DEF(GCC_VFRPP_FLAGS)
+*_GCC50_AARCH64_CC_XIPFLAGS      = DEF(GCC50_AARCH64_CC_XIPFLAGS)
+
+  DEBUG_GCC50_AARCH64_CC_FLAGS   = DEF(GCC50_AARCH64_CC_FLAGS) -O0
+RELEASE_GCC50_AARCH64_CC_FLAGS   = DEF(GCC50_AARCH64_CC_FLAGS) -Wno-unused-but-set-variable
+
+####################################################################################
+#
 # CLANG35   - This configuration is used to compile under Linux to produce
 #             PE/COFF binaries using the clang compiler and assembler (v3.5 and up)
 #             and GNU linker
-- 
2.6.6