patches/glibc/2.2.5/glibc-2.2.5-allow-gcc-3.4-weakextern.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Tue May 08 17:48:32 2007 +0000 (2007-05-08)
changeset 78 c3868084d81a
permissions -rw-r--r--
Huge fixes to glibc build, so that we can build at least (and at last):
- use ports addon even when installing headers,
- use optimisation (-O) when installing headers, to avoid unnecessary warnings (thanks Robert P. J. DAY for pointing this out!),
- lowest kernel version to use is only X.Y.Z, not X.Y.Z.T,
- a bit of preparations for NPTL (RSN I hope),
- fix fixing the linker scripts (changing the backup file is kind of useless and stupid);

Shut uClibc finish step: there really is nothing to do;

Add a patch for glibc-2.3.6 weak aliases handling on some archs (ARM and ALPHA at least);

Did not catch the make errors: fixed the pattern matching in scripts/functions;

Introduce a new log level, ALL:
- send components' build messages there,
- DEBUG log level is destined only for crosstool-NG debug messages,
- migrate sub-actions to use appropriate log levels;

Update the armeb-unknown-linux-gnu sample:
- it builds!
- uses gcc-4.0.4 and glibc-2.3.6,
- updated to latest config options set.
     1 Suggested by Jake Page <jake at cs dot stanford dot edu>
     2 in http://sources.redhat.com/ml/crossgcc/2004-07/msg00169.html
     3 but the libc-symbols.h fragment has been reworked to fix typos
     4 and to still work on gcc-2.95.3, which lacks _Pragma.
     5 
     6 His comment was:
     7  Fixes gcc-3.4 optimizing out comparisons to weak external symbols in code
     8  like:
     9   if (__pthread_mutex_init != NULL)
    10     __pthread_mutex_init(...);
    11  that causes segfaults during libc init when not linked to libpthread
    12 
    13 diff -uNr glibc-2.2.5-orig/resolv/res_libc.c glibc-2.2.5/resolv/res_libc.c
    14 --- glibc-2.2.5-orig/resolv/res_libc.c	2001-02-12 12:23:34.000000000 -0800
    15 +++ glibc-2.2.5/resolv/res_libc.c	2004-07-27 22:56:32.000000000 -0700
    16 @@ -84,7 +84,8 @@
    17  
    18  #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_2)
    19  # undef res_init
    20 -strong_alias (__res_init, __res_init_weak);
    21 +extern int __res_init_weak (void);
    22  weak_extern (__res_init_weak);
    23 +strong_alias (__res_init, __res_init_weak);
    24  compat_symbol (libc, __res_init_weak, res_init, GLIBC_2_0);
    25  #endif
    26 --- glibc-2.2.5/include/libc-symbols.h.old	Fri Aug 13 04:20:55 2004
    27 +++ glibc-2.2.5/include/libc-symbols.h	Fri Aug 13 04:37:06 2004
    28 @@ -108,10 +108,16 @@
    29  
    30  /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
    31  #  define weak_extern(symbol) _weak_extern (symbol)
    32 -#  ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
    33 -#   define _weak_extern(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
    34 -#  else
    35 -#   define _weak_extern(symbol)    asm (".weak " __SYMBOL_PREFIX #symbol);
    36 +#  if __GNUC__ >= 3
    37 +    /* see http://sources.redhat.com/ml/libc-alpha/2003-01/msg00043.html */
    38 +#   define __weak_extern_1(expr) _Pragma(#expr)
    39 +#   define _weak_extern(symbol) __weak_extern_1(weak symbol)
    40 +#  else /* __GNUC__ == 2 */
    41 +#   ifdef HAVE_ASM_WEAKEXT_DIRECTIVE
    42 +#    define _weak_extern(symbol) asm (".weakext " __SYMBOL_PREFIX #symbol);
    43 +#   else
    44 +#    define _weak_extern(symbol)    asm (".weak " __SYMBOL_PREFIX #symbol);
    45 +#   endif
    46  #  endif
    47  
    48  # else