[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#600835: gcc-4.4: please add preliminary m68k patches



Source: gcc-4.4
Version: 4.4.5-3
Severity: wishlist
Tags: patch

Please apply the patch from the attached debdiff. It allowed me to
compile gcc-4.4 entirely (no -B) on an m68k system with an experi-
mental (non-packaged) TLS capable eglibc installed, which in turn
I will now be using to build the packaged eglibc.

The two pr*.diff fix ICEs and wrong-code generation and are required.
The multiarch.h patch adds names for the multilib/arch targets stock
gcc wants to build for m68k. I have disabled that in rules2 though,
until we get past the TLS transition. Then, we can discuss among the
m68k porters which multilib targets to build at all, but please keep
it like this for a while, to ease the transition.

This has not been run through the testsuite yet, because I want to
get eglibc built first, which is a showstopper for much more. How-
ever, bootstrapping, stage comparision, and whatever works. Building
gcc alone on an emulated (= rather fast) m68k takes about three days,
so please bear with me on that.
diff -u gcc-4.4-4.4.5/debian/rules.patch gcc-4.4-4.4.5/debian/rules.patch
--- gcc-4.4-4.4.5/debian/rules.patch
+++ gcc-4.4-4.4.5/debian/rules.patch
@@ -238,7 +238,8 @@
 #endif
 
 ifeq ($(DEB_TARGET_ARCH),m68k)
-  debian_patches +=
+  debian_patches += pr41302
+  debian_patches += pr43804
 endif
 
 ifeq ($(DEB_TARGET_ARCH_OS),kfreebsd)
diff -u gcc-4.4-4.4.5/debian/changelog gcc-4.4-4.4.5/debian/changelog
--- gcc-4.4-4.4.5/debian/changelog
+++ gcc-4.4-4.4.5/debian/changelog
@@ -1,3 +1,13 @@
+gcc-4.4 (4.4.5-3+m68k.1) unreleased; urgency=low
+
+  * debian/patches/gcc-multiarch.diff: Add m68k support.
+  * debian/rules2: Disable multi{arch,lib} on m68k for now.
+  * debian/patches/pr41302.diff: new, backported from trunk.
+  * debian/patches/pr43804.diff: new, taken from GCC BZ.
+  * debian/rules.patch: Add pr41302, pr43804 on m68k.
+
+ -- Thorsten Glaser <tg@mirbsd.de>  Mon, 18 Oct 2010 16:08:12 +0000
+
 gcc-4.4 (4.4.5-3) unstable; urgency=medium
 
   * Update to SVN 20101011 from the gcc-4_4-branch (r164607, 4.4.5 release
diff -u gcc-4.4-4.4.5/debian/rules2 gcc-4.4-4.4.5/debian/rules2
--- gcc-4.4-4.4.5/debian/rules2
+++ gcc-4.4-4.4.5/debian/rules2
@@ -343,6 +343,14 @@
   CONFARGS += --with-multilib-list=m4,m4-nofpu --with-cpu=sh4
 endif
 
+ifneq (,$(findstring m68k-linux,$(DEB_TARGET_GNU_TYPE)))
+# Works in theory, but libfortran/mfidoa cannot be built because
+# the system headers contain incompatible inline assembly code -
+# at least for the pre-TLS libc; we'll need to recheck once past
+# newer eglibc's usable, and decide which to build anyway.
+  CONFARGS += --disable-multiarch --disable-multilib
+endif
+
 ifeq ($(DEB_TARGET_ARCH_OS),linux)
   ifneq (,$(findstring $(DEB_TARGET_ARCH), alpha powerpc ppc64 s390 s390x sparc sparc64))
     ifeq ($(DEB_TARGET_ARCH),alpha)
diff -u gcc-4.4-4.4.5/debian/patches/gcc-multiarch.diff gcc-4.4-4.4.5/debian/patches/gcc-multiarch.diff
--- gcc-4.4-4.4.5/debian/patches/gcc-multiarch.diff
+++ gcc-4.4-4.4.5/debian/patches/gcc-multiarch.diff
@@ -6,6 +6,8 @@
 # DP:	/usr/include/<arch>-linux-gnu
 # DP:	/usr/lib/<arch>-linux-gnu
 # DP: to the system paths.
+# DP:
+# DP: Add __m68k_linux_gnu__ //mirabilos
 
 2009-03-24  Arthur Loiret  <aloiret@debian.org>
 
@@ -258,7 +260,7 @@
  	}
 --- /dev/null
 +++ b/src/gcc/multiarch.h
-@@ -0,0 +1,95 @@
+@@ -0,0 +1,101 @@
 +/* Header for multiarch handling (include directories, libraries path).
 +   Copyright (C) 2009 Free Software Foundation, Inc.
 +   Contributed by Arthur Loiret <aloiret@debian.org>
@@ -332,6 +334,12 @@
 +  { "m4",  "sh4-linux-gnu" },
 +  { "m4-nofpu",  "sh4_nofpu-linux-gnu" },
 +# endif
++# if defined(__m68k_linux_gnu__)
++  { "m68040", "m68040-linux-gnu" },
++  { "m68060", "m68060-linux-gnu" },
++  { "mcpu32", "m68360-linux-gnu" },
++  { "mfidoa", "fido-linux-gnu" },
++# endif
 +#endif /* ENABLE_MULTIARCH */
 +  { 0, 0 }
 +};
only in patch2:
unchanged:
--- gcc-4.4-4.4.5.orig/debian/patches/pr41302.diff
+++ gcc-4.4-4.4.5/debian/patches/pr41302.diff
@@ -0,0 +1,139 @@
+From: mkuvyrkov <mkuvyrkov@138bc75d-0d04-0410-961f-82ee72b054a4>
+Date: Wed, 4 Nov 2009 09:57:55 +0000 (+0000)
+Subject: 2009-11-04  Maxim Kuvyrkov  <maxim@codesourcery.com>
+X-Git-Url: http://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;a=commitdiff_plain;h=d09fd72c630c4886367f1977cdb366aa82950e32
+
+2009-11-04  Maxim Kuvyrkov  <maxim@codesourcery.com>
+
+	PR target/41302
+	* config/m68k/m68k.c (m68k_reg_present_p): New static function.
+	(m68k_ok_for_sibcall_p): Handle different result return locations.
+
+2009-11-04  Carlos O'Donell  <carlos@codesourcery.com>
+
+	PR target/41302
+	* gcc.target/m68k/pr41302.c: New test.
+
+
+git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153890 138bc75d-0d04-0410-961f-82ee72b054a4
+---
+
+--- a/src/gcc/ChangeLog	2010-10-14 15:23:18.000000000 +0000
++++ b/src/gcc/ChangeLog	2010-10-14 16:42:48.000000000 +0000
+@@ -1,3 +1,12 @@
++2010-10-14  Thorsten Glaser  <tg@debian.org>
++
++	Backport from mainline
++	2009-11-04  Maxim Kuvyrkov  <maxim@codesourcery.com>
++
++	PR target/41302
++	* config/m68k/m68k.c (m68k_reg_present_p): New static function.
++	(m68k_ok_for_sibcall_p): Handle different result return locations.
++
+ 2010-10-07  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
+ 
+ 	PR target/45820
+--- a/src/gcc/config/m68k/m68k.c	2010-10-14 15:23:42.000000000 +0000
++++ b/src/gcc/config/m68k/m68k.c	2010-10-14 16:43:31.000000000 +0000
+@@ -1383,6 +1383,30 @@ flags_in_68881 (void)
+   return cc_status.flags & CC_IN_68881;
+ }
+ 
++/* Return true if PARALLEL contains register REGNO.  */
++static bool
++m68k_reg_present_p (const_rtx parallel, unsigned int regno)
++{
++  int i;
++
++  if (REG_P (parallel) && REGNO (parallel) == regno)
++    return true;
++
++  if (GET_CODE (parallel) != PARALLEL)
++    return false;
++
++  for (i = 0; i < XVECLEN (parallel, 0); ++i)
++    {
++      const_rtx x;
++
++      x = XEXP (XVECEXP (parallel, 0, i), 0);
++      if (REG_P (x) && REGNO (x) == regno)
++	return true;
++    }
++
++  return false;
++}
++
+ /* Implement TARGET_FUNCTION_OK_FOR_SIBCALL_P.  */
+ 
+ static bool
+@@ -1395,6 +1419,26 @@ m68k_ok_for_sibcall_p (tree decl, tree e
+   if (CALL_EXPR_STATIC_CHAIN (exp))
+     return false;
+ 
++  if (!VOID_TYPE_P (TREE_TYPE (DECL_RESULT (cfun->decl))))
++    {
++      /* Check that the return value locations are the same.  For
++	 example that we aren't returning a value from the sibling in
++	 a D0 register but then need to transfer it to a A0 register.  */
++      rtx cfun_value;
++      rtx call_value;
++
++      cfun_value = FUNCTION_VALUE (TREE_TYPE (DECL_RESULT (cfun->decl)),
++				   cfun->decl);
++      call_value = FUNCTION_VALUE (TREE_TYPE (exp), decl);
++
++      /* Check that the values are equal or that the result the callee
++	 function returns is superset of what the current function returns.  */
++      if (!(rtx_equal_p (cfun_value, call_value)
++	    || (REG_P (cfun_value)
++		&& m68k_reg_present_p (call_value, REGNO (cfun_value)))))
++	return false;
++    }
++
+   kind = m68k_get_function_kind (current_function_decl);
+   if (kind == m68k_fk_normal_function)
+     /* We can always sibcall from a normal function, because it's
+@@ -5091,6 +5135,9 @@ m68k_libcall_value (enum machine_mode mo
+   return gen_rtx_REG (mode, m68k_libcall_value_in_a0_p ? A0_REG : D0_REG);
+ }
+ 
++/* Location in which function value is returned.
++   NOTE: Due to differences in ABIs, don't call this function directly,
++   use FUNCTION_VALUE instead.  */
+ rtx
+ m68k_function_value (const_tree valtype, const_tree func ATTRIBUTE_UNUSED)
+ {
+--- a/src/gcc/testsuite/ChangeLog	2010-10-14 15:23:19.000000000 +0000
++++ b/src/gcc/testsuite/ChangeLog	2010-10-14 16:44:21.000000000 +0000
+@@ -1,3 +1,11 @@
++2010-10-14  Thorsten Glaser  <tg@debian.org>
++
++	Backport from mainline
++	2009-11-04  Carlos O'Donell  <carlos@codesourcery.com>
++
++	PR target/41302
++	* gcc.target/m68k/pr41302.c: New test.
++
+ 2010-10-10  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
+ 
+ 	Backport from mainline
+diff --git a/gcc/testsuite/gcc.target/m68k/pr41302.c b/gcc/testsuite/gcc.target/m68k/pr41302.c
+new file mode 100644
+index 0000000..8e1c310
+--- /dev/null
++++ b/src/gcc/testsuite/gcc.target/m68k/pr41302.c
+@@ -0,0 +1,14 @@
++/* { dg-do compile } */
++/* { dg-options "-O2" } */
++/* { dg-final { scan-assembler "move.l \%d0,\%a0" { target *linux* } } } */
++
++struct pts {
++  int c;
++};
++
++unsigned int bar (struct pts *a, int b);
++
++struct pts * foo (struct pts *a, int b)
++{
++  return (struct pts *) bar (a, b);
++}
only in patch2:
unchanged:
--- gcc-4.4-4.4.5.orig/debian/patches/pr43804.diff
+++ gcc-4.4-4.4.5/debian/patches/pr43804.diff
@@ -0,0 +1,14 @@
+# DP: Fix PR target/43804 with Attachment #20541 from Richard Sandiford
+
+--- a/src/gcc/config/m68k/constraints.md	2010-10-18 16:03:54.000000000 +0000
++++ b/src/gcc/config/m68k/constraints.md	2010-10-18 16:04:34.000000000 +0000
+@@ -89,7 +89,8 @@
+ (define_constraint "T"
+   "Used for operands that satisfy 's' when -mpcrel is not in effect."
+   (and (match_code "symbol_ref,label_ref,const")
+-       (match_test "!flag_pic")))
++       (match_test "!TARGET_PCREL")
++       (match_test "!flag_pic || LEGITIMATE_PIC_OPERAND_P (op)")))
+ 
+ (define_memory_constraint "Q"
+   "Means address register indirect addressing mode."

Reply to: