patches/glibc/2.9/490-ptr-mangling.patch
author Anthony Foiani <anthony.foiani@gmail.com>
Thu May 19 23:06:16 2011 +0200 (2011-05-19)
changeset 2461 ec30b191f0e3
parent 1201 c9967a6e3b25
permissions -rw-r--r--
complibs/ppl: build only C and C++ interfaces for PPL

By default, PPL wants to build interfaces for any of a variety of
langauges it finds on the local host (python, java, possibly perl, also
more esoteric languages such as ocaml and prolog).

These extra interfaces can double the compile time for the library. For
single-process builds, I found a savings of more than 40%:

default / j1: 716s total, 143.2s avg, 0.52s stdev
just_c / j1: 406s total, 81.2s avg, 0.33s stdev
just_c_cpp / j1: 413s total, 82.6s avg, 0.22s stdev

And for multi-process builds, it approached 50%:

default / j4: 625s total, 125.0s avg, 0.57s stdev
just_c / j4: 338s total, 67.6s avg, 1.25s stdev
just_c_cpp / j4: 327s total, 65.4s avg, 0.36s stdev

Since the PPL we build within ct-ng is only used by GCC, we only need to
build the C and C++ interfaces.

Signed-Off-By: Anthony Foiani <anthony.foiani@gmail.com>
     1 Original patch from: gentoo/src/patchsets/glibc/2.9/6018_all_glibc-ptr-mangling.patch
     2 
     3 -= BEGIN original header =-
     4 http://bugs.gentoo.org/201910
     5 
     6 For every arch, PTR_MANGLE and PTR_DEMANGLE defines are in
     7 sysdeps/unix/sysv/linux/<arch>/sysdep.h. But for alpha this is not true. The
     8 defines are in sysdeps/unix/alpha/sysdep.h and unix/sysv/linux/alpha/sysdep.h
     9 includes the first.
    10 
    11 This is a patch that fixes the issue and let alpha build, at the expense of
    12 disabling MANGLING in the non PIC case, but googling showed that the issue is
    13 known, and that nobody really cares about it. 
    14 
    15 Info from: http://sourceware.org/bugzilla/show_bug.cgi?id=5216
    16 
    17 -= END original header =-
    18 
    19 diff -durN glibc-2_9.orig/sysdeps/unix/alpha/sysdep.h glibc-2_9/sysdeps/unix/alpha/sysdep.h
    20 --- glibc-2_9.orig/sysdeps/unix/alpha/sysdep.h	2006-03-03 12:21:28.000000000 +0100
    21 +++ glibc-2_9/sysdeps/unix/alpha/sysdep.h	2009-02-02 22:01:39.000000000 +0100
    22 @@ -397,42 +397,4 @@
    23  	_sc_ret = _sc_0, _sc_err = _sc_19;			\
    24  }
    25  
    26 -/* Pointer mangling support.  Note that tls access is slow enough that
    27 -   we don't deoptimize things by placing the pointer check value there.  */
    28 -
    29 -#include <stdint.h>
    30 -
    31 -#if defined NOT_IN_libc && defined IS_IN_rtld
    32 -# ifdef __ASSEMBLER__
    33 -#  define PTR_MANGLE(dst, src, tmp)				\
    34 -	ldah	tmp, __pointer_chk_guard_local($29) !gprelhigh;	\
    35 -	ldq	tmp, __pointer_chk_guard_local(tmp) !gprellow;	\
    36 -	xor	src, tmp, dst
    37 -#  define PTR_MANGLE2(dst, src, tmp)				\
    38 -	xor	src, tmp, dst
    39 -#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
    40 -#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
    41 -# else
    42 -extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
    43 -#  define PTR_MANGLE(var)	\
    44 -  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
    45 -#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
    46 -# endif
    47 -#elif defined PIC
    48 -# ifdef __ASSEMBLER__
    49 -#  define PTR_MANGLE(dst, src, tmp)		\
    50 -	ldq	tmp, __pointer_chk_guard;	\
    51 -	xor	src, tmp, dst
    52 -#  define PTR_MANGLE2(dst, src, tmp)		\
    53 -	xor	src, tmp, dst
    54 -#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
    55 -#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
    56 -# else
    57 -extern uintptr_t __pointer_chk_guard attribute_relro;
    58 -#  define PTR_MANGLE(var)	\
    59 -	(var) = (void *) ((uintptr_t) (var) ^ __pointer_chk_guard)
    60 -#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
    61 -# endif
    62 -#endif
    63 -
    64  #endif /* ASSEMBLER */
    65 diff -durN glibc-2_9.orig/sysdeps/unix/sysv/linux/alpha/sysdep.h glibc-2_9/sysdeps/unix/sysv/linux/alpha/sysdep.h
    66 --- glibc-2_9.orig/sysdeps/unix/sysv/linux/alpha/sysdep.h	2007-08-21 10:07:28.000000000 +0200
    67 +++ glibc-2_9/sysdeps/unix/sysv/linux/alpha/sysdep.h	2009-02-02 22:01:39.000000000 +0100
    68 @@ -98,4 +98,46 @@
    69  	INTERNAL_SYSCALL1(name, err_out, nr, args);			\
    70  })
    71  
    72 +/* Pointer mangling support.  Note that tls access is slow enough that
    73 +   we don't deoptimize things by placing the pointer check value there.  */
    74 +
    75 +#if defined NOT_IN_libc && defined IS_IN_rtld
    76 +# ifdef __ASSEMBLER__
    77 +#  define PTR_MANGLE(dst, src, tmp)                            \
    78 +       ldah    tmp, __pointer_chk_guard_local($29) !gprelhigh; \
    79 +       ldq     tmp, __pointer_chk_guard_local(tmp) !gprellow;  \
    80 +       xor     src, tmp, dst
    81 +#  define PTR_MANGLE2(dst, src, tmp)                           \
    82 +       xor     src, tmp, dst
    83 +#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
    84 +#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
    85 +# else
    86 +extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
    87 +#  define PTR_MANGLE(var)      \
    88 +  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
    89 +#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
    90 +# endif
    91 +#elif defined PIC
    92 +# ifdef __ASSEMBLER__
    93 +#  define PTR_MANGLE(dst, src, tmp)            \
    94 +       ldq     tmp, __pointer_chk_guard;       \
    95 +       xor     src, tmp, dst
    96 +#  define PTR_MANGLE2(dst, src, tmp)           \
    97 +       xor     src, tmp, dst
    98 +#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
    99 +#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
   100 +# else
   101 +extern uintptr_t __pointer_chk_guard attribute_relro;
   102 +#  define PTR_MANGLE(var)      \
   103 +       (var) = (void *) ((uintptr_t) (var) ^ __pointer_chk_guard)
   104 +#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
   105 +# endif
   106 +#else
   107 +/* Pointer mangling is not yet supported for static libc on alpha.  */
   108 +# ifndef __ASSEMBLER__
   109 +#  define PTR_MANGLE(var)   (void) (var)
   110 +#  define PTR_DEMANGLE(var) (void) (var)
   111 +# endif
   112 +#endif
   113 +
   114  #endif /* _LINUX_ALPHA_SYSDEP_H */