patches/gcc/3.3/sh4-pthread.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun May 20 13:48:26 2007 +0000 (2007-05-20)
changeset 112 ea15433daba0
permissions -rw-r--r--
Ah! I finally have a progress bar that doesn't stall the build!
- pipe size in Linux is only 8*512=4096 bytes
- pipe size is not setable
- when the feeding process spits out data faster than the eating
process can read it, then the feeding process stalls after 4KiB
of data sent to the pipe
- for us, the progress bar would spawn a sub-shell every line,
and the sub-shell would in turn spawn a 'date' command.
Which was sloooww as hell, and would cause some kind of a
starvation: the pipe was full most of the time, and the
feeding process was stalled all this time.

Now, we use internal variables and a little hack based onan offset
to determine the elapsed time. Much faster this way, but still
CPU-intensive.
     1 Patch to fix following test case failure:
     2 
     3 		=== libstdc++-v3 tests ===
     4 FAIL: thread/pthread1.cc (test for excess errors)
     5 Excess errors:
     6 /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
     7 collect2: ld returned 1 exit status
     8 
     9 Note that *any* program compiled with -pthread fails:
    10 
    11 /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
    12 /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
    13 collect2: ld returned 1 exit status
    14 
    15 Compiling with -lpthread on the other hand works fine:
    16 /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
    17 
    18 So -pthread is broken in some trivial way; it should invoke -lpthread, not -lthread,
    19 at least when targeting Linux. 
    20 
    21 http://www.sh-linux.org/rpm-2003/SRPMS/gcc-3.2.3-3.src.rpm contains a jumbo patch,
    22 gcc-20030210-sh-linux-1.patch, that includes a fix for this.  Here's the
    23 appropriate hunk (brings in a fix for the documented -mieee option).
    24 No idea if this fix is completely right, but it works for me...
    25 - dank@kegel.com  20 Jul 2003
    26 
    27 Index: linux.h
    28 ===================================================================
    29 RCS file: /cvsroot/gcc/gcc/gcc/config/sh/linux.h,v
    30 retrieving revision 1.9.20.1
    31 diff -u -d -u -r1.9.20.1 linux.h
    32 --- gcc-ss-3_3-20030714/gcc/config/sh/linux.h.old	6 Jun 2003 02:30:59 -0000	1.9.20.1
    33 +++ gcc-ss-3_3-20030714/gcc/config/sh/linux.h	20 Jul 2003 23:36:50 -0000
    34 @@ -59,7 +59,7 @@
    35  #undef LIB_SPEC
    36  #define LIB_SPEC \
    37    "%{shared: -lc} \
    38 -   %{!shared: %{pthread:-lthread} \
    39 +   %{!shared: %{mieee:-lieee} %{pthread:-lpthread} \
    40       %{profile:-lc_p} %{!profile: -lc}}"
    41  
    42  #undef STARTFILE_SPEC