From 42c8dd49ac7a4e533b612e3a90f490f31eeee0fa Mon Sep 17 00:00:00 2001
From: James Buren <ryuo@frugalware.org>
Date: Wed, 6 Mar 2013 13:05:08 -0600
Subject: [PATCH] gcc patch

---
 BaseTools/Conf/tools_def.template | 82 +++++++++++++++++++++++++++++++++++++++
 EmulatorPkg/Unix/Host/Host.inf    |  1 +
 EmulatorPkg/build.sh              |  3 ++
 OvmfPkg/build.sh                  |  3 ++
 4 files changed, 89 insertions(+)

diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
index a82404a..5c6d807 100644
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -147,6 +147,9 @@ DEFINE GCC45_X64_PREFIX        = /usr/bin/
 DEFINE GCC46_IA32_PREFIX       = /usr/bin/
 DEFINE GCC46_X64_PREFIX        = /usr/bin/
 
+DEFINE GCC47_IA32_PREFIX       = /usr/bin/
+DEFINE GCC47_X64_PREFIX        = /usr/bin/
+
 DEFINE UNIX_IASL_BIN           = /usr/bin/iasl
 #DEFINE UNIX_IASL_BIN           = $(HOME)/programs/iasl
 DEFINE WIN_ASL_BIN_DIR         = C:\ASL
@@ -277,6 +280,12 @@ DEFINE CLANG_BIN = /usr/bin/
 #                             Required to build platforms or ACPI tables:
 #                               Intel(r) ACPI Compiler v20101013 from
 #                               http://www.acpica.org/downloads/previous_releases.php
+#   GCC47       -Linux-  Requires:
+#                             GCC 4.7 (Native)
+#                        Optional:
+#                             Required to build platforms or ACPI tables:
+#                               Intel(r) ACPI Compiler v20101013 from
+#                               http://www.acpica.org/downloads/previous_releases.php
 #   ELFGCC      -Linux-  Requires:
 #                             GCC(this tool chain uses whatever version of gcc and binutils that is installed in /usr/bin)
 #                        Optional:
@@ -2584,6 +2593,14 @@ DEFINE GCC46_IA32_X64_DLINK_FLAGS    = DEF(GCC45_IA32_X64_DLINK_FLAGS)
 DEFINE GCC46_X64_DLINK_FLAGS         = DEF(GCC45_X64_DLINK_FLAGS)
 DEFINE GCC46_ASM_FLAGS               = DEF(GCC45_ASM_FLAGS)
 
+DEFINE GCC47_IA32_CC_FLAGS           = DEF(GCC46_IA32_CC_FLAGS) -Wno-address -Wno-unused-but-set-variable
+DEFINE GCC47_X64_CC_FLAGS            = DEF(GCC46_X64_CC_FLAGS) -Wno-address -Wno-unused-but-set-variable
+DEFINE GCC47_IA32_X64_DLINK_COMMON   = DEF(GCC46_IA32_X64_DLINK_COMMON)
+DEFINE GCC47_IA32_X64_ASLDLINK_FLAGS = DEF(GCC46_IA32_X64_ASLDLINK_FLAGS)
+DEFINE GCC47_IA32_X64_DLINK_FLAGS    = DEF(GCC46_IA32_X64_DLINK_FLAGS)
+DEFINE GCC47_X64_DLINK_FLAGS         = DEF(GCC46_X64_DLINK_FLAGS)
+DEFINE GCC47_ASM_FLAGS               = DEF(GCC46_ASM_FLAGS)
+
 ####################################################################################
 #
 # Unix GCC And Intel Linux ACPI Compiler
@@ -2867,6 +2884,71 @@ DEFINE GCC46_ASM_FLAGS               = DEF(GCC45_ASM_FLAGS)
 
 ####################################################################################
 #
+# GCC 4.7 - This configuration is used to compile under Linux to produce
+#           PE/COFF binaries using GCC 4.7.
+#
+####################################################################################
+*_GCC47_*_*_FAMILY               = GCC
+
+*_GCC47_*_MAKE_PATH                    = make
+*_GCC47_*_ASL_PATH                     = DEF(UNIX_IASL_BIN)
+
+*_GCC47_*_PP_FLAGS                     = DEF(GCC_PP_FLAGS)
+*_GCC47_*_ASLPP_FLAGS                  = DEF(GCC_ASLPP_FLAGS)
+*_GCC47_*_ASLCC_FLAGS                  = DEF(GCC_ASLCC_FLAGS)
+*_GCC47_*_VFRPP_FLAGS                  = DEF(GCC_VFRPP_FLAGS)
+*_GCC47_*_APP_FLAGS                    =
+*_GCC47_*_ASL_FLAGS                    = DEF(IASL_FLAGS)
+*_GCC47_*_ASL_OUTFLAGS                 = DEF(IASL_OUTFLAGS)
+
+##################
+# GCC47 IA32 definitions
+##################
+*_GCC47_IA32_OBJCOPY_PATH         = DEF(GCC47_IA32_PREFIX)objcopy
+*_GCC47_IA32_CC_PATH              = DEF(GCC47_IA32_PREFIX)gcc
+*_GCC47_IA32_SLINK_PATH           = DEF(GCC47_IA32_PREFIX)ar
+*_GCC47_IA32_DLINK_PATH           = DEF(GCC47_IA32_PREFIX)ld
+*_GCC47_IA32_ASLDLINK_PATH        = DEF(GCC47_IA32_PREFIX)ld
+*_GCC47_IA32_ASM_PATH             = DEF(GCC47_IA32_PREFIX)gcc
+*_GCC47_IA32_PP_PATH              = DEF(GCC47_IA32_PREFIX)gcc
+*_GCC47_IA32_VFRPP_PATH           = DEF(GCC47_IA32_PREFIX)gcc
+*_GCC47_IA32_ASLCC_PATH           = DEF(GCC47_IA32_PREFIX)gcc
+*_GCC47_IA32_ASLPP_PATH           = DEF(GCC47_IA32_PREFIX)gcc
+*_GCC47_IA32_RC_PATH              = DEF(GCC47_IA32_PREFIX)objcopy
+
+*_GCC47_IA32_ASLCC_FLAGS          = DEF(GCC_ASLCC_FLAGS) -m32
+*_GCC47_IA32_ASLDLINK_FLAGS       = DEF(GCC47_IA32_X64_ASLDLINK_FLAGS) -m elf_i386
+*_GCC47_IA32_ASM_FLAGS            = DEF(GCC47_ASM_FLAGS) -m32 -march=i386
+*_GCC47_IA32_CC_FLAGS             = DEF(GCC47_IA32_CC_FLAGS) -Os
+*_GCC47_IA32_DLINK_FLAGS          = DEF(GCC47_IA32_X64_DLINK_FLAGS) -m elf_i386 --oformat=elf32-i386
+*_GCC47_IA32_RC_FLAGS             = DEF(GCC_IA32_RC_FLAGS)
+*_GCC47_IA32_OBJCOPY_FLAGS        = 
+
+##################
+# GCC47 X64 definitions
+##################
+*_GCC47_X64_OBJCOPY_PATH         = DEF(GCC47_X64_PREFIX)objcopy
+*_GCC47_X64_CC_PATH              = DEF(GCC47_X64_PREFIX)gcc
+*_GCC47_X64_SLINK_PATH           = DEF(GCC47_X64_PREFIX)ar
+*_GCC47_X64_DLINK_PATH           = DEF(GCC47_X64_PREFIX)ld
+*_GCC47_X64_ASLDLINK_PATH        = DEF(GCC47_X64_PREFIX)ld
+*_GCC47_X64_ASM_PATH             = DEF(GCC47_X64_PREFIX)gcc
+*_GCC47_X64_PP_PATH              = DEF(GCC47_X64_PREFIX)gcc
+*_GCC47_X64_VFRPP_PATH           = DEF(GCC47_X64_PREFIX)gcc
+*_GCC47_X64_ASLCC_PATH           = DEF(GCC47_X64_PREFIX)gcc
+*_GCC47_X64_ASLPP_PATH           = DEF(GCC47_X64_PREFIX)gcc
+*_GCC47_X64_RC_PATH              = DEF(GCC47_X64_PREFIX)objcopy
+
+*_GCC47_X64_ASLCC_FLAGS          = DEF(GCC_ASLCC_FLAGS) -m64
+*_GCC47_X64_ASLDLINK_FLAGS       = DEF(GCC47_IA32_X64_ASLDLINK_FLAGS) -m elf_x86_64
+*_GCC47_X64_ASM_FLAGS            = DEF(GCC47_ASM_FLAGS) -m64
+*_GCC47_X64_CC_FLAGS             = DEF(GCC47_X64_CC_FLAGS)
+*_GCC47_X64_DLINK_FLAGS          = DEF(GCC47_X64_DLINK_FLAGS)
+*_GCC47_X64_RC_FLAGS             = DEF(GCC_X64_RC_FLAGS)
+*_GCC47_X64_OBJCOPY_FLAGS        = 
+
+####################################################################################
+#
 # Cygwin GCC And Intel ACPI Compiler
 #
 ####################################################################################
diff --git a/EmulatorPkg/Unix/Host/Host.inf b/EmulatorPkg/Unix/Host/Host.inf
index 496bd77..3d262a7 100644
--- a/EmulatorPkg/Unix/Host/Host.inf
+++ b/EmulatorPkg/Unix/Host/Host.inf
@@ -126,6 +126,7 @@
    GCC:*_GCC44_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))"
    GCC:*_GCC45_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))"
    GCC:*_GCC46_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))"
+   GCC:*_GCC47_X64_CC_FLAGS = "-DEFIAPI=__attribute__((ms_abi))"
    GCC:*_*_X64_PP_FLAGS == -m64 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
    GCC:*_*_X64_ASM_FLAGS == -m64 -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h
 
diff --git a/EmulatorPkg/build.sh b/EmulatorPkg/build.sh
index 111619f..725c97e 100755
--- a/EmulatorPkg/build.sh
+++ b/EmulatorPkg/build.sh
@@ -90,6 +90,9 @@ case `uname` in
       4.6.*)
         TARGET_TOOLS=GCC46
         ;;
+      4.[789].*)
+        TARGET_TOOLS=GCC47
+        ;;
       *)
         TARGET_TOOLS=GCC44
         ;;
diff --git a/OvmfPkg/build.sh b/OvmfPkg/build.sh
index 28c7d38..cb78c30 100755
--- a/OvmfPkg/build.sh
+++ b/OvmfPkg/build.sh
@@ -75,6 +75,9 @@ case `uname` in
       4.6.*)
         TARGET_TOOLS=GCC46
         ;;
+      4.[789].*)
+        TARGET_TOOLS=GCC47
+        ;;
       *)
         TARGET_TOOLS=GCC44
         ;;
-- 
1.8.1.4

