gcc-4.7: Fix build for armv4/EABI and ppc/Os
authorKhem Raj <raj.khem@gmail.com>
Fri, 17 Aug 2012 05:42:07 +0000 (22:42 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 12 Sep 2012 14:13:38 +0000 (15:13 +0100)
arm patch is a forward port from OE/classic
ppc patch should help in building images with Os

(From OE-Core rev: ac9ebcea4a2b778f6dd103a729831d9a9be281df)

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/gcc/gcc-4.7.inc
meta/recipes-devtools/gcc/gcc-4.7/gcc-armv4-pass-fix-v4bx-to-ld.patch [new file with mode: 0644]
meta/recipes-devtools/gcc/gcc-4.7/ppc_no_crtsavres.patch [new file with mode: 0644]

index 84c230c..ab07862 100644 (file)
@@ -1,6 +1,6 @@
 require gcc-common.inc
 
-PR = "r11"
+PR = "r12"
 
 # Third digit in PV should be incremented after a minor release
 # happens from this branch on gcc e.g. currently its 4.7.1
@@ -75,6 +75,8 @@ SRC_URI = "git://github.com/mirrors/gcc.git;branch=${BRANCH};protocol=git \
           file://fix-g++-sysroot.patch \
           file://disablesdt.patch \
           file://libtool.patch \
+          file://gcc-armv4-pass-fix-v4bx-to-ld.patch \
+          file://ppc_no_crtsavres.patch \
          "
 
 S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/git"
diff --git a/meta/recipes-devtools/gcc/gcc-4.7/gcc-armv4-pass-fix-v4bx-to-ld.patch b/meta/recipes-devtools/gcc/gcc-4.7/gcc-armv4-pass-fix-v4bx-to-ld.patch
new file mode 100644 (file)
index 0000000..7e03a3a
--- /dev/null
@@ -0,0 +1,31 @@
+The LINK_SPEC for linux gets overwritten by linux-eabi.h which
+means the value of TARGET_FIX_V4BX_SPEC gets lost and as a result
+the option is not passed to linker when chosing march=armv4
+This patch redefines this in linux-eabi.h and reinserts it
+for eabi defaulting toolchains.
+
+We might want to send it upstream
+
+Upstream-Status: Pending
+
+-Khem
+Index: gcc-4_7-branch/gcc/config/arm/linux-eabi.h
+===================================================================
+--- gcc-4_7-branch.orig/gcc/config/arm/linux-eabi.h    2012-08-21 22:54:12.448453417 -0700
++++ gcc-4_7-branch/gcc/config/arm/linux-eabi.h 2012-08-21 23:05:18.008478722 -0700
+@@ -78,10 +78,14 @@
+      %{mfloat-abi=soft*:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "} \
+      %{!mfloat-abi=*:" GLIBC_DYNAMIC_LINKER_DEFAULT "}"
++/* For armv4 we pass --fix-v4bx to linker to support EABI */
++#undef TARGET_FIX_V4BX_SPEC
++#define TARGET_FIX_V4BX_SPEC "%{mcpu=arm8|mcpu=arm810|mcpu=strongarm*|march=armv4: --fix-v4bx}"
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC.  We want to
+    use the GNU/Linux version, not the generic BPABI version.  */
+ #undef  LINK_SPEC
+-#define LINK_SPEC BE8_LINK_SPEC                                               \
++#define LINK_SPEC BE8_LINK_SPEC TARGET_FIX_V4BX_SPEC                  \
+   LINUX_OR_ANDROID_LD (LINUX_TARGET_LINK_SPEC,                                \
+                      LINUX_TARGET_LINK_SPEC " " ANDROID_LINK_SPEC)
diff --git a/meta/recipes-devtools/gcc/gcc-4.7/ppc_no_crtsavres.patch b/meta/recipes-devtools/gcc/gcc-4.7/ppc_no_crtsavres.patch
new file mode 100644 (file)
index 0000000..92a5d9e
--- /dev/null
@@ -0,0 +1,72 @@
+Upstream-Status: Backport
+
+Signed-off-by: Khem Raj
+
+Source-url: http://gcc.gnu.org/ml/gcc-patches/2012-05/msg01362.html
+
+Currently, powerpc-linux gcc -Os -mno-multiple uses out-of-linux gpr
+save and restore functions when saving/restoring just one gpr.  That's
+quite silly since the function call requires more instructions and is
+slower than an inline save/restore.  The only case where it might win
+is when no fprs are restored and the restore function can tear down
+the frame and exit (also loading up lr on ppc64).  I guess that's how
+GP_SAVE_INLINE came to be like it is, ie. it's optimised for the
+common case using ldm in the prologue and no fprs.  Still, it isn't
+difficult to choose the best combination in all cases, but it does
+mean different logic is needed for restores.  I could have implemented
+GP_RESTORE_INLINE and FP_RESORE_INLINE macros but it seemed simpler to
+just move everything into the one place the macros are invoked.  AIX
+and Darwin register cutoff doesn't change with this patch.
+
+This patch also enables out-of-line restores in cases that were
+previously disabled due to using inline saves.
+
+Bootstrapped and regression tested powerpc-linux.  OK to apply?
+
+       * aix.h (FP_SAVE_INLINE, GP_SAVE_INLINE): Delete.
+       * darwin.h (FP_SAVE_INLINE, GP_SAVE_INLINE): Delete.
+       * sysv4.h (FP_SAVE_INLINE, GP_SAVE_INLINE, V_SAVE_INLINE): Delete.
+       * config/rs6000/rs6000.c (V_SAVE_INLINE): Delete.
+       (rs6000_savres_strategy): Reimplement GP/FP/V_SAVE_INLINE logic.
+       For ELF targets, use out-of-line restores for -Os and any number
+       of regs if the restore exits, and out-of-line gp save for two or
+       more regs.  Use save_reg_p to test for holes in reg restore set.
+       Replace "#if" with "if".
+
+Index: gcc-4_7-branch/gcc/config/rs6000/aix.h
+===================================================================
+--- gcc-4_7-branch.orig/gcc/config/rs6000/aix.h        2012-09-07 12:35:35.000000000 -0700
++++ gcc-4_7-branch/gcc/config/rs6000/aix.h     2012-09-07 15:27:55.215290315 -0700
+@@ -207,11 +207,6 @@
+   { "link_syscalls",            LINK_SYSCALLS_SPEC },                 \
+   { "link_libg",                LINK_LIBG_SPEC }
+-/* Define cutoff for using external functions to save floating point.  */
+-#define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) == 62 || (FIRST_REG) == 63)
+-/* And similarly for general purpose registers.  */
+-#define GP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) < 32)
+-
+ #define PROFILE_HOOK(LABEL)   output_profile_hook (LABEL)
+ /* No version of AIX fully supports AltiVec or 64-bit instructions in
+Index: gcc-4_7-branch/gcc/config/rs6000/darwin.h
+===================================================================
+--- gcc-4_7-branch.orig/gcc/config/rs6000/darwin.h     2012-09-07 12:35:35.000000000 -0700
++++ gcc-4_7-branch/gcc/config/rs6000/darwin.h  2012-09-07 15:27:55.223290316 -0700
+@@ -173,16 +173,6 @@
+   (RS6000_ALIGN (crtl->outgoing_args_size, 16)                \
+    + (STACK_POINTER_OFFSET))
+-/* Define cutoff for using out-of-line functions to save registers.
+-   Currently on Darwin, we implement FP and GPR out-of-line-saves plus the
+-   special routine for 'save everything'.  */
+-
+-#undef FP_SAVE_INLINE
+-#define FP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) > 60 && (FIRST_REG) < 64)
+-
+-#undef GP_SAVE_INLINE
+-#define GP_SAVE_INLINE(FIRST_REG) ((FIRST_REG) > 29 && (FIRST_REG) < 32)
+-
+ /* Darwin uses a function call if everything needs to be saved/restored.  */
+ #undef WORLD_SAVE_P