patches/glibc/2.6.1/200-alpha-ptr_mangle.patch
author "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
Fri Jan 27 13:31:16 2012 +0100 (2012-01-27)
changeset 2854 a70abdbfa342
permissions -rw-r--r--
complibs/cloog: fix linking with libm

In Ubuntu 11.04 and 11.10, the default options for ld have changed.
--no-copy-dt-needed-entries and --as-needed are now enabled by default, which
causes errors like:

[EXTRA] Checking CLooG/ppl
[DEBUG] ==> Executing: 'make' '-j3' '-s' 'check'
[ALL ] Making check in .
[ALL ] config.status: creating include/cloog/cloog-config.h
[ALL ] config.status: include/cloog/cloog-config.h is unchanged
[ALL ] libtool: link: i686-build_pc-linux-gnu-gcc -Wall -fomit-frame-pointer
-pipe -o cloog cloog.o -L/<snip>/build/static/lib ./.libs/libcloog.a -lm
/<snip>/build/static/lib/libppl_c.a /<snip>/build/static/lib/libpwl.a
/<snip>/build/static/lib/libppl.a /<snip>/build/static/lib/libgmpxx.a
/<snip>/build/static/lib/libgmp.a -lstdc++
[ALL ] /usr/bin/ld: /<snip>/build/static/lib/libppl.a(MIP_Problem.o):
undefined reference to symbol 'sqrt@@GLIBC_2.0'
[ALL ] /usr/bin/ld: note: 'sqrt@@GLIBC_2.0' is defined in DSO
/usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/libm.so so try adding
it to the linker command line
[ALL ] /usr/lib/gcc/i686-linux-gnu/4.6.1/../../../i386-linux-gnu/libm.so:
could not read symbols: Invalid operation
[ALL ] collect2: ld returned 1 exit status
[ERROR] make[2]: *** [cloog] Error 1
[ERROR] make[1]: *** [check-recursive] Error 1

See:
https://wiki.ubuntu.com/NattyNarwhal/ToolchainTransition

This patch fixes these errors by placing '-lm' at the right place on the command
line as libppl requires libm when linking cloog.

Signed-off-by: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
yann@748
     1
--- glibc-2.6.1.orig/sysdeps/unix/alpha/sysdep.h
yann@748
     2
+++ glibc-2.6.1/sysdeps/unix/alpha/sysdep.h
yann@748
     3
@@ -397,42 +397,4 @@
yann@748
     4
 	_sc_ret = _sc_0, _sc_err = _sc_19;			\
yann@748
     5
 }
yann@748
     6
 
yann@748
     7
-/* Pointer mangling support.  Note that tls access is slow enough that
yann@748
     8
-   we don't deoptimize things by placing the pointer check value there.  */
yann@748
     9
-
yann@748
    10
-#include <stdint.h>
yann@748
    11
-
yann@748
    12
-#if defined NOT_IN_libc && defined IS_IN_rtld
yann@748
    13
-# ifdef __ASSEMBLER__
yann@748
    14
-#  define PTR_MANGLE(dst, src, tmp)				\
yann@748
    15
-	ldah	tmp, __pointer_chk_guard_local($29) !gprelhigh;	\
yann@748
    16
-	ldq	tmp, __pointer_chk_guard_local(tmp) !gprellow;	\
yann@748
    17
-	xor	src, tmp, dst
yann@748
    18
-#  define PTR_MANGLE2(dst, src, tmp)				\
yann@748
    19
-	xor	src, tmp, dst
yann@748
    20
-#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
yann@748
    21
-#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
yann@748
    22
-# else
yann@748
    23
-extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
yann@748
    24
-#  define PTR_MANGLE(var)	\
yann@748
    25
-  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
yann@748
    26
-#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
yann@748
    27
-# endif
yann@748
    28
-#elif defined PIC
yann@748
    29
-# ifdef __ASSEMBLER__
yann@748
    30
-#  define PTR_MANGLE(dst, src, tmp)		\
yann@748
    31
-	ldq	tmp, __pointer_chk_guard;	\
yann@748
    32
-	xor	src, tmp, dst
yann@748
    33
-#  define PTR_MANGLE2(dst, src, tmp)		\
yann@748
    34
-	xor	src, tmp, dst
yann@748
    35
-#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
yann@748
    36
-#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
yann@748
    37
-# else
yann@748
    38
-extern uintptr_t __pointer_chk_guard attribute_relro;
yann@748
    39
-#  define PTR_MANGLE(var)	\
yann@748
    40
-	(var) = (void *) ((uintptr_t) (var) ^ __pointer_chk_guard)
yann@748
    41
-#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
yann@748
    42
-# endif
yann@748
    43
-#endif
yann@748
    44
-
yann@748
    45
 #endif /* ASSEMBLER */
yann@748
    46
--- glibc-2.6.1.orig/sysdeps/unix/sysv/linux/alpha/sysdep.h
yann@748
    47
+++ glibc-2.6.1/sysdeps/unix/sysv/linux/alpha/sysdep.h
yann@748
    48
@@ -29,6 +29,8 @@
yann@748
    49
 /* There is some commonality.  */
yann@748
    50
 #include <sysdeps/unix/alpha/sysdep.h>
yann@748
    51
 
yann@748
    52
+#include <tls.h>
yann@748
    53
+
yann@748
    54
 /* For Linux we can use the system call table in the header file
yann@748
    55
 	/usr/include/asm/unistd.h
yann@748
    56
    of the kernel.  But these symbols do not follow the SYS_* syntax
yann@748
    57
@@ -96,4 +96,46 @@
yann@748
    58
 	INTERNAL_SYSCALL1(name, err_out, nr, args);			\
yann@748
    59
 })
yann@748
    60
 
yann@748
    61
+/* Pointer mangling support.  Note that tls access is slow enough that
yann@748
    62
+   we don't deoptimize things by placing the pointer check value there.  */
yann@748
    63
+
yann@748
    64
+#if defined NOT_IN_libc && defined IS_IN_rtld
yann@748
    65
+# ifdef __ASSEMBLER__
yann@748
    66
+#  define PTR_MANGLE(dst, src, tmp)				\
yann@748
    67
+	ldah	tmp, __pointer_chk_guard_local($29) !gprelhigh;	\
yann@748
    68
+	ldq	tmp, __pointer_chk_guard_local(tmp) !gprellow;	\
yann@748
    69
+	xor	src, tmp, dst
yann@748
    70
+#  define PTR_MANGLE2(dst, src, tmp)				\
yann@748
    71
+	xor	src, tmp, dst
yann@748
    72
+#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
yann@748
    73
+#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
yann@748
    74
+# else
yann@748
    75
+extern uintptr_t __pointer_chk_guard_local attribute_relro attribute_hidden;
yann@748
    76
+#  define PTR_MANGLE(var)	\
yann@748
    77
+  (var) = (__typeof (var)) ((uintptr_t) (var) ^ __pointer_chk_guard_local)
yann@748
    78
+#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
yann@748
    79
+# endif
yann@748
    80
+#elif defined PIC
yann@748
    81
+# ifdef __ASSEMBLER__
yann@748
    82
+#  define PTR_MANGLE(dst, src, tmp)		\
yann@748
    83
+	ldq	tmp, __pointer_chk_guard;	\
yann@748
    84
+	xor	src, tmp, dst
yann@748
    85
+#  define PTR_MANGLE2(dst, src, tmp)		\
yann@748
    86
+	xor	src, tmp, dst
yann@748
    87
+#  define PTR_DEMANGLE(dst, tmp)   PTR_MANGLE(dst, dst, tmp)
yann@748
    88
+#  define PTR_DEMANGLE2(dst, tmp)  PTR_MANGLE2(dst, dst, tmp)
yann@748
    89
+# else
yann@748
    90
+extern uintptr_t __pointer_chk_guard attribute_relro;
yann@748
    91
+#  define PTR_MANGLE(var)	\
yann@748
    92
+	(var) = (void *) ((uintptr_t) (var) ^ __pointer_chk_guard)
yann@748
    93
+#  define PTR_DEMANGLE(var)  PTR_MANGLE(var)
yann@748
    94
+# endif
yann@748
    95
+#else
yann@748
    96
+/* Pointer mangling is not yet supported for static libc on alpha.  */
yann@748
    97
+# ifndef __ASSEMBLER__
yann@748
    98
+#  define PTR_MANGLE(var)   (void) (var)
yann@748
    99
+#  define PTR_DEMANGLE(var) (void) (var)
yann@748
   100
+# endif
yann@748
   101
+#endif
yann@748
   102
+
yann@748
   103
 #endif /* _LINUX_ALPHA_SYSDEP_H */