patches/gcc/4.4.4/290-freebsd.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Sep 12 23:38:18 2010 +0200 (2010-09-12)
changeset 2120 48de021b3a9e
child 2148 ada9128c98b8
permissions -rw-r--r--
arch/mips: add experimental mips64 samples

Both toolchains were tested to successfully:
- _build_ busybox, giving respectively an n32 and an n64 binary
although it has not been run-tested.
- build linux-2.6.36-rc3 for Loongson, giving an n64 vmlinux
(which is expected, due to the way the kernel is built),
and the kernel properly boots!

Credits are due to Julien MOUTHINO (julm on freenode#uClibc) for
testing that the kernel boots on his hardware! Cheers! ;-)

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     1 diff -durN gcc-4.4.0.orig/gcc/config/freebsd-spec.h gcc-4.4.0/gcc/config/freebsd-spec.h
     2 
     3 diff -durN gcc-4.4.4.orig/gcc/config/freebsd-spec.h gcc-4.4.4/gcc/config/freebsd-spec.h
     4 --- gcc-4.4.4.orig/gcc/config/freebsd-spec.h	2010-05-16 19:36:15.000000000 +0200
     5 +++ gcc-4.4.4/gcc/config/freebsd-spec.h	2010-05-16 19:36:21.000000000 +0200
     6 @@ -86,9 +86,10 @@
     7  #define FBSD_STARTFILE_SPEC \
     8    "%{!shared: \
     9       %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} \
    10 -		       %{!p:%{profile:gcrt1.o%s} \
    11 -			 %{!profile:crt1.o%s}}}} \
    12 -   crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}"
    13 +	%{!p:%{profile:gcrt1.o%s} \
    14 +	 %{!profile:crt1.o%s}}}} \
    15 +   crti.o%s \
    16 +   %{static:crtbeginT.o%s;shared:crtbeginS.o%s;:crtbegin.o%s}"
    17  
    18  /* Provide a ENDFILE_SPEC appropriate for FreeBSD.  Here we tack on
    19     the magical crtend.o file (see crtstuff.c) which provides part of 
    20 @@ -126,7 +127,8 @@
    21      %{pg:  -lc_p}							\
    22    }"
    23  #else
    24 -#if FBSD_MAJOR < 5
    25 +#include <sys/param.h>
    26 +#if __FreeBSD_version < 500016
    27  #define FBSD_LIB_SPEC "							\
    28    %{!shared:								\
    29      %{!pg:								\
    30 @@ -136,17 +138,34 @@
    31        %{!pthread:-lc_p}							\
    32        %{pthread:-lc_r_p}}						\
    33    }"
    34 -#else
    35 +#elif __FreeBSD_version < 700022
    36  #define FBSD_LIB_SPEC "							\
    37    %{!shared:								\
    38      %{!pg: %{pthread:-lpthread} -lc}					\
    39      %{pg:  %{pthread:-lpthread_p} -lc_p}				\
    40    }"
    41 +#else
    42 +#define FBSD_LIB_SPEC "							\
    43 +  %{!shared:								\
    44 +    %{!pg: %{pthread:-lpthread} -lc}					\
    45 +    %{pg:  %{pthread:-lpthread_p} -lc_p}}				\
    46 +  %{shared:								\
    47 +    %{pthread:-lpthread} -lc}						\
    48 +  "
    49  #endif
    50  #endif
    51  
    52 -#if FBSD_MAJOR < 6
    53 +#if FBSD_MAJOR < 5
    54  #define FBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.1"
    55  #else
    56  #define FBSD_DYNAMIC_LINKER "/libexec/ld-elf.so.1"
    57  #endif
    58 +
    59 +#if defined(HAVE_LD_EH_FRAME_HDR)
    60 +#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
    61 +#endif
    62 +
    63 +/* Use --as-needed -lgcc_s for eh support.  */
    64 +#ifdef HAVE_LD_AS_NEEDED
    65 +#define USE_LD_AS_NEEDED 1
    66 +#endif