summaryrefslogtreecommitdiff
path: root/patches/gcc/3.3
diff options
context:
space:
mode:
Diffstat (limited to 'patches/gcc/3.3')
-rw-r--r--patches/gcc/3.3/compat.exp.patch37
-rw-r--r--patches/gcc/3.3/config.sub.patch72
-rw-r--r--patches/gcc/3.3/gcc-3.2.3-g++.exp.patch98
-rw-r--r--patches/gcc/3.3/gcc-3.3-libstdc++-v3-dg.exp.patch54
-rw-r--r--patches/gcc/3.3/sh-pic-set_fpscr.patch60
-rw-r--r--patches/gcc/3.3/sh-predef-gnu_source.patch15
-rw-r--r--patches/gcc/3.3/sh-spec.patch45
-rw-r--r--patches/gcc/3.3/sh4-kaz-workaround.patch145
-rw-r--r--patches/gcc/3.3/sh4-no-fix-protos.patch12
-rw-r--r--patches/gcc/3.3/sh4-pthread.patch42
10 files changed, 580 insertions, 0 deletions
diff --git a/patches/gcc/3.3/compat.exp.patch b/patches/gcc/3.3/compat.exp.patch
new file mode 100644
index 0000000..763b8a1
--- /dev/null
+++ b/patches/gcc/3.3/compat.exp.patch
@@ -0,0 +1,37 @@
+Fixes the following problem when testing a cross-compiler:
+
+============================================
+Testing g++.dg/compat/abi/bitfield1,
+...
+Invoking the compiler as /crosstool-0.12/build/powerpc-750-linux-gnu/gcc-3.3-glibc-2.2.5/build-gcc/gcc/testsuite/../g++ ...
+/crosstool-0.12/build/powerpc-750-linux-gnu/gcc-3.3-glibc-2.2.5/gcc-3.3/gcc/testsuite/g++.dg/compat/abi/bitfield1_main.C
+pid is 16028 -16028
+compiler exited with status 1
+output is:
+sh: error while loading shared libraries: /opt/cegl-2.0/powerpc-750-linux-gnu/gcc-3.3-glibc-2.2.5/powerpc-750-linux-gnu/./lib/libdl.so.2: ELF file data encoding not little-endian
+/crosstool-0.12/build/powerpc-750-linux-gnu/gcc-3.3-glibc-2.2.5/build-gcc/gcc/testsuite/../g++: error while loading shared libraries: /opt/cegl-2.0/powerpc-750-linux-gnu/gcc-3.3-glibc-2.2.5/powerpc-750-linux-gnu/./lib/libc.so.6: ELF file data encoding not little-endian
+
+FAIL: g++.dg/compat/abi/bitfield1 main_tst.o compile
+============================================
+
+--- gcc-3.3/gcc/testsuite/g++.dg/compat/compat.exp.old Thu Oct 17 17:22:57 2002
++++ gcc-3.3/gcc/testsuite/g++.dg/compat/compat.exp Mon Jul 14 10:59:19 2003
+@@ -42,11 +42,13 @@
+ proc compat-fix-library-path { } {
+ global ld_library_path
+
+- # See comments in lib/g++.exp for why this is needed.
+- setenv LD_LIBRARY_PATH $ld_library_path
+- setenv SHLIB_PATH $ld_library_path
+- setenv LD_LIBRARYN32_PATH $ld_library_path
+- setenv LD_LIBRARY64_PATH $ld_library_path
++ if {![is_remote target]} {
++ # See comments in lib/g++.exp for why this is needed.
++ setenv LD_LIBRARY_PATH $ld_library_path
++ setenv SHLIB_PATH $ld_library_path
++ setenv LD_LIBRARYN32_PATH $ld_library_path
++ setenv LD_LIBRARY64_PATH $ld_library_path
++ }
+ }
+
+ #
diff --git a/patches/gcc/3.3/config.sub.patch b/patches/gcc/3.3/config.sub.patch
new file mode 100644
index 0000000..928f911
--- /dev/null
+++ b/patches/gcc/3.3/config.sub.patch
@@ -0,0 +1,72 @@
+When configuring a s390->s390 or cris->cris crosscompiler
+(ok, I haven't hit this yet, but one of these days I'll get me an account
+on an s390, and then I'll need this patch :-), you'll get the
+following error:
+
++ /build/s390-unknown-linux-gnu/gcc-3.3-glibc-2.3.2/gcc-3.3/configure
+--target=s390-unknown-linux-gnu --host=s390-host_unknown-linux-gnu
+--prefix=/result/s390-unknown-linux-gnu/gcc-3.3-glibc-2.3.2
+--enable-languages=c
+--with-local-prefix=/result/s390-unknown-linux-gnu/gcc-3.3-glibc-2.3.2/s390-
+unknown-linux-gnu --enable-threads=no --without-headers --with-newlib
+--disable-shared
+...
+*** --with-headers is only supported when cross compiling
+
+This error pops up only when you're using Daniel Jacobowitz's technique
+of slightly changing the target and host tuples to make them different
+enough to force gcc's build system to not try to pull in system libraries
+or headers. This technique is needed e.g. to build an x86 -> x86
+cross-compiler.
+(The LFS developers ran into the same bug that prompted me to use
+this technique; they point people who run into it to
+http://linuxfromscratch.org/~greg/pure_lfs.txt, which is a different
+way of avoiding this problem. I think the tuple tweak is the way to go, though.)
+
+config-patches@gnu.org rejected this patch, on the grounds that there
+is only one vendor of each of those two architectures, so the
+canonicalization is by definition correct. When I pointed out the
+difficulty this causes for people building s390 -> s390 or
+cris -> cris compilers that are incompatible with the system
+libraries and thus must be built like cross-compilers, he grumped and said
+"autoconf should let you specify a cross-compiler in some other way than
+comparing tuple strings".
+
+
+
+--- gcc-3.3/config.sub.old Sun Jun 8 20:38:47 2003
++++ gcc-3.3/config.sub Sun Jun 8 20:40:34 2003
+@@ -433,9 +433,12 @@
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+- cris | cris-* | etrax*)
++ cris | etrax*)
+ basic_machine=cris-axis
+ ;;
++ cris-*)
++ basic_machine=cris-`echo $basic_machine | sed 's/^[^-]*-//'`
++ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+@@ -820,11 +823,17 @@
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+- s390 | s390-*)
++ s390)
+ basic_machine=s390-ibm
+ ;;
+- s390x | s390x-*)
++ s390-*)
++ basic_machine=s390-`echo $basic_machine | sed 's/^[^-]*-//'`
++ ;;
++ s390x)
+ basic_machine=s390x-ibm
++ ;;
++ s390x-*)
++ basic_machine=s390x-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
diff --git a/patches/gcc/3.3/gcc-3.2.3-g++.exp.patch b/patches/gcc/3.3/gcc-3.2.3-g++.exp.patch
new file mode 100644
index 0000000..0de46fc
--- /dev/null
+++ b/patches/gcc/3.3/gcc-3.2.3-g++.exp.patch
@@ -0,0 +1,98 @@
+g++ testsuite fixes for cross-compilers, Dan Kegel, Ixia Communications, 12 July 2003
+
+The first hunk fixes the error
+
+/testsuite_flags: /testsuite_flags: No such file or directory
+ while executing
+"exec sh ${odir_v3}/testsuite_flags --build-includes"
+ (procedure "g++_include_flags" line 21)
+ invoked from within
+"g++_include_flags [get_multilibs] "
+ (procedure "g++_init" line 63)
+ invoked from within
+"${tool}_init $test_file_name"
+ (procedure "runtest" line 19)
+ invoked from within
+"runtest $test_name"
+ ("foreach" body line 42)
+ invoked from within
+...
+make[1]: [check-g++] Error 1 (ignored)
+
+The fix isn't especially pretty, but it worked for me, and can't hurt the
+more common native compiler case. Maybe someone who knows the code better
+can come up with a better fix.
+
+The second hunk fixes the error
+
+sh: error while loading shared libraries: /opt/cegl-2.0/powerpc-405-linux-gnu/gcc-3.2.3-glibc-2.2.5/powerpc-405-linux-gnu/./lib/libdl.so.2: ELF file data encoding not little-endian
+
+when trying to compile g++ testcases (!); setting up
+the shared library environment when running crosstests of g++
+should either be done by a special board file, or by
+setting up a remote chroot environment (see http://kegel.com/crosstool),
+not by blithely setting LD_LIBRARY_PATH on the local system.
+
+--- gcc-3.2.3/gcc/testsuite/lib/g++.exp.old Fri Jul 11 15:42:47 2003
++++ gcc-3.2.3/gcc/testsuite/lib/g++.exp Sat Jul 12 12:57:07 2003
+@@ -72,6 +72,8 @@
+ #
+ proc g++_include_flags { paths } {
+ global srcdir
++ global objdir
++ global target_triplet
+ global HAVE_LIBSTDCXX_V3
+ global TESTING_IN_BUILD_TREE
+
+@@ -90,6 +92,20 @@
+
+ if { ${HAVE_LIBSTDCXX_V3} } {
+ set odir_v3 [lookfor_file ${gccpath} libstdc++-v3]
++ if { $odir_v3 == "" } {
++ verbose "g++_include_flags: couldn't find libstdc++-v3 on first try, now looking in build directory $objdir"
++ # first assume no multilibs
++ set odir_v3 [lookfor_file ${objdir} "$target_triplet/libstdc++-v3"]
++ }
++ if { $odir_v3 == "" } {
++ verbose "g++_include_flags: couldn't find libstdc++-v3 on second try, trying multilib"
++ # assume multilib only one level deep
++ set multisub [file tail $gccpath]
++ set odir_v3 [lookfor_file ${objdir} "$target_triplet/$multisub/libstdc++-v3"]
++ }
++ if { $odir_v3 == "" } {
++ error "Can't find libstdc++-v3"
++ }
+ append flags [exec sh ${odir_v3}/testsuite_flags --build-includes]
+ } else {
+ set odir_v2 [lookfor_file ${gccpath} libstdc++]
+@@ -192,16 +192,20 @@
+ }
+ }
+
+- # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
+- # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
+- # (for the 64-bit ABI). The right way to do this would be to modify
+- # unix.exp -- but that's not an option since it's part of DejaGNU
+- # proper, so we do it here. We really only need to do
+- # this on IRIX, but it shouldn't hurt to do it anywhere else.
+- setenv LD_LIBRARY_PATH $ld_library_path
+- setenv SHLIB_PATH $ld_library_path
+- setenv LD_LIBRARYN32_PATH $ld_library_path
+- setenv LD_LIBRARY64_PATH $ld_library_path
++ if {![is_remote target]} {
++ # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
++ # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
++ # (for the 64-bit ABI). The right way to do this would be to modify
++ # unix.exp -- but that's not an option since it's part of DejaGNU
++ # proper, so we do it here. We really only need to do
++ # this on IRIX, but it shouldn't hurt to do it anywhere else.
++
++ # Doing this causes us to be unable to run cross-compilers.
++ setenv LD_LIBRARY_PATH $ld_library_path
++ setenv SHLIB_PATH $ld_library_path
++ setenv LD_LIBRARYN32_PATH $ld_library_path
++ setenv LD_LIBRARY64_PATH $ld_library_path
++ }
+
+ return "$flags"
+ }
diff --git a/patches/gcc/3.3/gcc-3.3-libstdc++-v3-dg.exp.patch b/patches/gcc/3.3/gcc-3.3-libstdc++-v3-dg.exp.patch
new file mode 100644
index 0000000..aafc130
--- /dev/null
+++ b/patches/gcc/3.3/gcc-3.3-libstdc++-v3-dg.exp.patch
@@ -0,0 +1,54 @@
+Without this patch, the command
+
+RUNTESTFLAGS=--target=powerpc-750-linux-gnu -v -v -v -v make check-target-libstdc++-v3
+
+fails in two ways:
+1. the -L option meant to locate the testsuite directory is incorrect, and
+2. the wrong compiler is invoked, causing all sorts of havoc, not least of which
+is the native compiler is invoked when we really wanted to invoke the cross-compiler
+we just built.
+
+Here's an example log of the problem in action. Every testcase fails, this shows just one:
+-------------
+Invoking the compiler as g++ -ggdb3 -DDEBUG_ASSERT -I/home3/dank/wk/ixos/dap_interim/linux/3rdParty/crosstool/crosstool-0.12/build/powerpc-750-linux-gnu/gcc-3.3-glibc-2.2.5/gcc-3.3/libstdc++-v3/testsuite /home3/dank/wk/ixos/dap_interim/linux/3rdParty/crosstool/crosstool-0.12/build/powerpc-750-linux-gnu/gcc-3.3-glibc-2.2.5/gcc-3.3/libstdc++-v3/testsuite/20_util/binders.cc -g -O2 -DDEBUG_ASSERT -L/testsuite -lv3test -lm -o ./binders.exe
+compiler exited with status 1
+output is:
+/usr/lib/gcc-lib/i386-linux/2.95.4/../../../../include/g++-3/stl_function.h: In method `void binder2nd<mem_fun1_ref_t<void,Elem,int> >::operator ()(const Elem &) const':^M
+/usr/lib/gcc-lib/i386-linux/2.95.4/../../../../include/g++-3/stl_algo.h:83: instantiated from `for_each<Elem *, binder2nd<mem_fun1_ref_t<void,Elem,int> > >(Elem *, Elem *, binder2nd<mem_fun1_ref_t<void,Elem,int> >)'^M
+/home3/dank/wk/ixos/dap_interim/linux/3rdParty/crosstool/crosstool-0.12/build/powerpc-750-linux-gnu/gcc-3.3-glibc-2.2.5/gcc-3.3/libstdc++-v3/testsuite/20_util/binders.cc:43: instantiated from here^M
+/usr/lib/gcc-lib/i386-linux/2.95.4/../../../../include/g++-3/stl_function.h:224: conversion from `const Elem' to `Elem &' discards qualifiers^M
+/usr/lib/gcc-lib/i386-linux/2.95.4/../../../../include/g++-3/stl_function.h:622: in passing argument 1 of `mem_fun1_ref_t<void,Elem,int>::operator ()(Elem &, int) const'^M
+...
+FAIL: 20_util/binders.cc (test for excess errors)
+WARNING: 20_util/binders.cc compilation failed to produce executable
+-------------
+
+And here's the patch. I'm not happy with it, and it probably gets some cases wrong,
+but it seems to work for the common native case and for my cross-compiler case.
+
+--- gcc-3.3/libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp.old Sun Jul 13 10:42:01 2003
++++ gcc-3.3/libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp Sun Jul 13 11:39:54 2003
+@@ -46,8 +46,23 @@
+ global gluefile wrap_flags
+ global ld_library_path
+ global tool_root_dir
++ global target_triplet
+
+ set blddir [lookfor_file [get_multilibs] libstdc++-v3]
++ if { $blddir == "" } {
++ set multilibs [get_multilibs]
++ # FIXME: assume multilib only one level deep
++ set multisub [file tail $multilibs]
++ verbose "libstdc++-v3-init: couldn't find libstdc++-v3 in $multilibs, trying $objdir"
++ set blddir [lookfor_file ${objdir} "$target_triplet/$multisub/libstdc++-v3"]
++ }
++ if { $blddir == "" } {
++ verbose "libstdc++-v3-init: couldn't find libstdc++-v3, trying $objdir without multilibs"
++ set blddir [lookfor_file ${objdir} "$target_triplet/libstdc++-v3"]
++ }
++ if { $blddir == "" } {
++ error "Can't find libstdc++-v3"
++ }
+
+ # By default, we assume we want to run program images.
+ global dg-do-what-default
diff --git a/patches/gcc/3.3/sh-pic-set_fpscr.patch b/patches/gcc/3.3/sh-pic-set_fpscr.patch
new file mode 100644
index 0000000..00cfb4c
--- /dev/null
+++ b/patches/gcc/3.3/sh-pic-set_fpscr.patch
@@ -0,0 +1,60 @@
+Should fix
+make[2]: *** [/gcc-3.3-glibc-2.3.2/build-glibc/elf/check-textrel.out] Error 1
+in glibc's "make tests".
+
+-------------
+
+Message-Id: <200307300255.h6U2tB906928@r-rr.iij4u.or.jp>
+To: dank@kegel.com
+Cc: linux-sh@m17n.org
+Subject: Re: Writing PIC version of __udivsi3_i4? (was: Re: "make tests" fails
+ with "libc.so: text relocations used" in glibc-2.3.2 for sh4)
+In-Reply-To: Your message of "Wed, 30 Jul 2003 11:20:49 +0900"
+ <200307300212.h6U2CH901209@r-rr.iij4u.or.jp>
+References: <200307300212.h6U2CH901209@r-rr.iij4u.or.jp>
+Date: Wed, 30 Jul 2003 12:03:01 +0900
+From: kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+> I'll try to write the PIC version of it,
+
+Dan, does the attached patch work for you?
+
+[dank: original patch deleted; here's same thing rediffed against gcc-3.3 instead of HEAD]
+
+--- gcc-3.3/gcc/config/sh/lib1funcs.asm.old Tue Jul 29 21:37:29 2003
++++ gcc-3.3/gcc/config/sh/lib1funcs.asm Tue Jul 29 21:40:58 2003
+@@ -1792,7 +1792,17 @@
+ .global GLOBAL(set_fpscr)
+ GLOBAL(set_fpscr):
+ lds r4,fpscr
++#ifdef __PIC__
++ mov.l r12,@-r15
++ mova LOCAL(set_fpscr_L0),r0
++ mov.l LOCAL(set_fpscr_L0),r12
++ add r0,r12
++ mov.l LOCAL(set_fpscr_L1),r0
++ mov.l @(r0,r12),r1
++ mov.l @r15+,r12
++#else
+ mov.l LOCAL(set_fpscr_L1),r1
++#endif
+ swap.w r4,r0
+ or #24,r0
+ #ifndef FMOVD_WORKS
+@@ -1820,8 +1830,16 @@
+ mov.l r3,@(4,r1)
+ #endif
+ .align 2
++#ifdef __PIC__
++LOCAL(set_fpscr_L0):
++ .long _GLOBAL_OFFSET_TABLE_
++LOCAL(set_fpscr_L1):
++ .long GLOBAL(fpscr_values@GOT)
++#else
+ LOCAL(set_fpscr_L1):
+ .long GLOBAL(fpscr_values)
++#endif
++
+ #ifdef __ELF__
+ .comm GLOBAL(fpscr_values),8,4
+ #else
diff --git a/patches/gcc/3.3/sh-predef-gnu_source.patch b/patches/gcc/3.3/sh-predef-gnu_source.patch
new file mode 100644
index 0000000..dc94f4c
--- /dev/null
+++ b/patches/gcc/3.3/sh-predef-gnu_source.patch
@@ -0,0 +1,15 @@
+See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11096
+and http://gcc.gnu.org/ml/gcc-patches/2003-06/msg00424.html
+
+--- gcc-3.3/gcc/config/sh/linux.h.old Wed Jun 4 17:37:40 2003
++++ gcc-3.3/gcc/config/sh/linux.h Wed Jun 4 17:38:16 2003
+@@ -53,5 +53,9 @@
+ %{static:-static}"
+
++/* The GNU C++ standard library requires that these macros be defined. */
++#undef CPLUSPLUS_CPP_SPEC
++#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
++
+ #undef LIB_SPEC
+ #define LIB_SPEC \
+ "%{shared: -lc} \
diff --git a/patches/gcc/3.3/sh-spec.patch b/patches/gcc/3.3/sh-spec.patch
new file mode 100644
index 0000000..6266c1f
--- /dev/null
+++ b/patches/gcc/3.3/sh-spec.patch
@@ -0,0 +1,45 @@
+Message-Id: <200308020452.h724q0n01509@r-rr.iij4u.or.jp>
+To: dank@kegel.com
+Cc: kkojima@rr.iij4u.or.jp
+Subject: Re: Writing PIC version of __udivsi3_i4?
+In-Reply-To: Your message of "Fri, 01 Aug 2003 21:15:27 -0700"
+ <3F2B3ADF.6030206@kegel.com>
+References: <3F2B3ADF.6030206@kegel.com>
+Date: Sat, 02 Aug 2003 13:58:05 +0900
+From: kaz Kojima <kkojima@rr.iij4u.or.jp>
+
+Dan Kegel <dank@kegel.com> wrote:
+> It seems it might be from gcc's spec file:
+>
+> *subtarget_link_spec:
+> %{shared:-shared} %{!static: %{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} %{!rpath:-rpath /lib}} %{static:-static}
+>
+> as the only place -rpath showed up was in the output of gcc -v as it
+> was linking libc.so.
+>
+> Well, that's a clue, anyway! Guess I'll dig through the spec files
+> tomorrow to see if I can figure it out some more.
+
+I've grepped gcc/config/*/*.h and found only SH and old libc1 stuffs
+of i386/alpha include %{!rpath:-rpath ... in 3.3 release and the
+current CVS. And my sh-gcc's specs doesn't have this :-(
+It would be the Right Thing to remove this stuff simply. How about
+the gcc patch below?
+
+Regards,
+ kaz
+--
+--- gcc-3.3/gcc/config/sh/linux.h.orig Sat Aug 2 13:20:57 2003
++++ gcc-3.3/gcc/config/sh/linux.h Sat Aug 2 13:22:42 2003
+@@ -48,8 +48,7 @@ do { \
+ "%{shared:-shared} \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+- %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2} \
+- %{!rpath:-rpath /lib}} \
++ %{!dynamic-linker:-dynamic-linker /lib/ld-linux.so.2}} \
+ %{static:-static}"
+
+ /* The GNU C++ standard library requires that these macros be defined. */
+
+
diff --git a/patches/gcc/3.3/sh4-kaz-workaround.patch b/patches/gcc/3.3/sh4-kaz-workaround.patch
new file mode 100644
index 0000000..189b132
--- /dev/null
+++ b/patches/gcc/3.3/sh4-kaz-workaround.patch
@@ -0,0 +1,145 @@
+[lightly edited to fit my patch directory - dank]
+
+From: kaz Kojima <kkojima@rr.iij4u.or.jp>
+Date: Sat, 09 Aug 2003 09:46:21 +0900
+To: dank@kegel.com
+
+Hi Dan,
+
+I've come back from the vacation and looked glibc string test
+failures on sh4. This looks a gcc problem. gcc-3.3/3.4 doesn't
+compile these tests correctly. The attached testcase aborts on
+gcc-3.3/3.4 -O2 but exits normally gcc-3.2 and gcc-3.0.
+The option -O2 is not essential but it makes the testcase small.
+The failed string tests include the same pattern of the code with
+f=random to generate ramdom strings but they get strings with
+embedded NULL characters :-(
+
+...
+I've got a workaround below for this bug, though it might merely
+paper over the real bug. Anyway, I'd like to send a PR for this.
+
+Regards,
+ kaz
+--
+int val = 0xff00;
+
+int f (void) { return val; }
+
+unsigned char a[1];
+
+void
+foo (void)
+{
+ a[0] = f () & 255;
+
+ if (!a[0])
+ a[0] = f () & 255;
+
+ if (!a[0])
+ a[0] = 1 + (f () & 127);
+}
+
+int
+main (int argc, char **argv)
+{
+ foo ();
+ if (!a[0])
+ abort ();
+
+ return 0;
+}
+
+--
+
+diff -u3prN ORIG/gcc/gcc/config/sh/sh.c LOCAL/gcc/gcc/config/sh/sh.c
+--- gcc/gcc/config/sh/sh.c.old Fri Aug 8 18:39:02 2003
++++ gcc/gcc/config/sh/sh.c Fri Aug 8 22:31:02 2003
+@@ -6657,6 +6657,19 @@ arith_reg_dest (op, mode)
+ return arith_reg_operand (op, mode);
+ }
+
++/* Like above, but for SImode compare destinations: forbid paradoxical
++ subregs, because it would get the combiner confused. */
++int
++arith_reg_cmp_dest (op, mode)
++ rtx op;
++ enum machine_mode mode;
++{
++ if (mode == SImode && GET_CODE (op) == SUBREG
++ && GET_MODE_SIZE (GET_MODE (SUBREG_REG (op))) < 4)
++ return 0;
++ return arith_reg_operand (op, mode);
++}
++
+ int
+ int_gpr_dest (op, mode)
+ rtx op;
+diff -u3prN ORIG/gcc/gcc/config/sh/sh.h LOCAL/gcc/gcc/config/sh/sh.h
+--- gcc/gcc/config/sh/sh.h.old Fri Aug 8 18:39:02 2003
++++ gcc/gcc/config/sh/sh.h Fri Aug 8 22:31:02 2003
+@@ -3365,6 +3365,7 @@ extern int rtx_equal_function_value_matt
+ {"and_operand", {SUBREG, REG, CONST_INT}}, \
+ {"any_register_operand", {SUBREG, REG}}, \
+ {"arith_operand", {SUBREG, REG, CONST_INT}}, \
++ {"arith_reg_cmp_dest", {SUBREG, REG}}, \
+ {"arith_reg_dest", {SUBREG, REG}}, \
+ {"arith_reg_operand", {SUBREG, REG}}, \
+ {"arith_reg_or_0_operand", {SUBREG, REG, CONST_INT, CONST_VECTOR}}, \
+
+--- gcc-3.3/gcc/config/sh/sh.md.orig Tue Apr 15 10:06:10 2003
++++ gcc-3.3/gcc/config/sh/sh.md Sat Aug 9 22:31:13 2003
+@@ -616,7 +616,7 @@
+
+ (define_insn ""
+ [(set (reg:SI T_REG)
+- (eq:SI (and:SI (match_operand:SI 0 "arith_reg_operand" "z,r")
++ (eq:SI (and:SI (match_operand:SI 0 "arith_reg_cmp_dest" "z,r")
+ (match_operand:SI 1 "arith_operand" "L,r"))
+ (const_int 0)))]
+ "TARGET_SH1"
+@@ -631,7 +631,7 @@
+
+ (define_insn "cmpeqsi_t"
+ [(set (reg:SI T_REG)
+- (eq:SI (match_operand:SI 0 "arith_reg_operand" "r,z,r")
++ (eq:SI (match_operand:SI 0 "arith_reg_cmp_dest" "r,z,r")
+ (match_operand:SI 1 "arith_operand" "N,rI,r")))]
+ "TARGET_SH1"
+ "@
+@@ -642,7 +642,7 @@
+
+ (define_insn "cmpgtsi_t"
+ [(set (reg:SI T_REG)
+- (gt:SI (match_operand:SI 0 "arith_reg_operand" "r,r")
++ (gt:SI (match_operand:SI 0 "arith_reg_cmp_dest" "r,r")
+ (match_operand:SI 1 "arith_reg_or_0_operand" "r,N")))]
+ "TARGET_SH1"
+ "@
+@@ -652,7 +652,7 @@
+
+ (define_insn "cmpgesi_t"
+ [(set (reg:SI T_REG)
+- (ge:SI (match_operand:SI 0 "arith_reg_operand" "r,r")
++ (ge:SI (match_operand:SI 0 "arith_reg_cmp_dest" "r,r")
+ (match_operand:SI 1 "arith_reg_or_0_operand" "r,N")))]
+ "TARGET_SH1"
+ "@
+@@ -666,7 +666,7 @@
+
+ (define_insn "cmpgeusi_t"
+ [(set (reg:SI T_REG)
+- (geu:SI (match_operand:SI 0 "arith_reg_operand" "r")
++ (geu:SI (match_operand:SI 0 "arith_reg_cmp_dest" "r")
+ (match_operand:SI 1 "arith_reg_operand" "r")))]
+ "TARGET_SH1"
+ "cmp/hs %1,%0"
+@@ -674,7 +674,7 @@
+
+ (define_insn "cmpgtusi_t"
+ [(set (reg:SI T_REG)
+- (gtu:SI (match_operand:SI 0 "arith_reg_operand" "r")
++ (gtu:SI (match_operand:SI 0 "arith_reg_cmp_dest" "r")
+ (match_operand:SI 1 "arith_reg_operand" "r")))]
+ "TARGET_SH1"
+ "cmp/hi %1,%0"
diff --git a/patches/gcc/3.3/sh4-no-fix-protos.patch b/patches/gcc/3.3/sh4-no-fix-protos.patch
new file mode 100644
index 0000000..c3c478f
--- /dev/null
+++ b/patches/gcc/3.3/sh4-no-fix-protos.patch
@@ -0,0 +1,12 @@
+See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10331
+and http://gcc.gnu.org/ml/gcc-patches/2003-06/msg00423.html
+
+--- gcc-3.3/gcc/config/sh/t-linux.old Wed Jun 4 13:01:39 2003
++++ gcc-3.3/gcc/config/sh/t-linux Wed Jun 4 13:02:12 2003
+@@ -1,3 +1,6 @@
++# Don't run fixproto
++STMP_FIXPROTO =
++
+ TARGET_LIBGCC2_CFLAGS = -fpic
+ LIB1ASMFUNCS_CACHE = _ic_invalidate
+
diff --git a/patches/gcc/3.3/sh4-pthread.patch b/patches/gcc/3.3/sh4-pthread.patch
new file mode 100644
index 0000000..a0c9233
--- /dev/null
+++ b/patches/gcc/3.3/sh4-pthread.patch
@@ -0,0 +1,42 @@
+Patch to fix following test case failure:
+
+ === libstdc++-v3 tests ===
+FAIL: thread/pthread1.cc (test for excess errors)
+Excess errors:
+/opt/cegl-2.0/sh4-unknown-linux-gnu/gcc-ss-3_3-20030714-glibc-2.2.5/sh4-unknown-linux-gnu/bin/ld: cannot find -lthread
+collect2: ld returned 1 exit status
+
+Note that *any* program compiled with -pthread fails:
+
+/opt/cegl-2.0/sh4-unknown-linux-gnu/gcc-ss-3_3-20030714-glibc-2.2.5/bin/sh4-unknown-linux-gnu-gcc hello.c -pthread
+/opt/cegl-2.0/sh4-unknown-linux-gnu/gcc-ss-3_3-20030714-glibc-2.2.5/lib/gcc-lib/sh4-unknown-linux-gnu/3.3.1/../../../../sh4-unknown-linux-gnu/bin/ld: cannot find -lthread
+collect2: ld returned 1 exit status
+
+Compiling with -lpthread on the other hand works fine:
+/opt/cegl-2.0/sh4-unknown-linux-gnu/gcc-ss-3_3-20030714-glibc-2.2.5/bin/sh4-unknown-linux-gnu-gcc hello.c -lpthread
+
+So -pthread is broken in some trivial way; it should invoke -lpthread, not -lthread,
+at least when targeting Linux.
+
+http://www.sh-linux.org/rpm-2003/SRPMS/gcc-3.2.3-3.src.rpm contains a jumbo patch,
+gcc-20030210-sh-linux-1.patch, that includes a fix for this. Here's the
+appropriate hunk (brings in a fix for the documented -mieee option).
+No idea if this fix is completely right, but it works for me...
+- dank@kegel.com 20 Jul 2003
+
+Index: linux.h
+===================================================================
+RCS file: /cvsroot/gcc/gcc/gcc/config/sh/linux.h,v
+retrieving revision 1.9.20.1
+diff -u -d -u -r1.9.20.1 linux.h
+--- gcc-ss-3_3-20030714/gcc/config/sh/linux.h.old 6 Jun 2003 02:30:59 -0000 1.9.20.1
++++ gcc-ss-3_3-20030714/gcc/config/sh/linux.h 20 Jul 2003 23:36:50 -0000
+@@ -59,7 +59,7 @@
+ #undef LIB_SPEC
+ #define LIB_SPEC \
+ "%{shared: -lc} \
+- %{!shared: %{pthread:-lthread} \
++ %{!shared: %{mieee:-lieee} %{pthread:-lpthread} \
+ %{profile:-lc_p} %{!profile: -lc}}"
+
+ #undef STARTFILE_SPEC