patches/glibc/2.7/250-sh-chop-linux-version.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@962
     1
--- glibc-2.7/sysdeps/unix/sysv/linux/dl-osinfo.h.orig	2007-09-15 23:54:08.000000000 +0100
yann@962
     2
+++ glibc-2.7/sysdeps/unix/sysv/linux/dl-osinfo.h	2008-08-20 09:26:26.000000000 +0100
yann@962
     3
@@ -83,6 +83,10 @@
yann@962
     4
   int parts;
yann@962
     5
   char *cp;
yann@962
     6
   struct utsname uts;
yann@962
     7
+  int dotsfound = 0;
yann@962
     8
+  int versionindex = 0;
yann@962
     9
+  char *choppoint;
yann@962
    10
+
yann@962
    11
 
yann@962
    12
   /* Try the uname system call.  */
yann@962
    13
   if (__uname (&uts))
yann@962
    14
@@ -102,8 +106,34 @@
yann@962
    15
   else
yann@962
    16
     buf = uts.release;
yann@962
    17
 
yann@962
    18
+  /* We are only interested in the first three kernel numbers, so */
yann@962
    19
+  /* chop off anything past that: */
yann@962
    20
+
yann@962
    21
+  choppoint = buf;
yann@962
    22
+  while (1)
yann@962
    23
+    {
yann@962
    24
+      versionindex++;
yann@962
    25
+      if (versionindex == 63) break;
yann@962
    26
+      if (*choppoint == '.') dotsfound++;
yann@962
    27
+      choppoint++;
yann@962
    28
+      if (dotsfound == 2)
yann@962
    29
+      {
yann@962
    30
+        if (*choppoint == '0' || *choppoint == '1'
yann@962
    31
+          || *choppoint == '2' || *choppoint == '3'
yann@962
    32
+          || *choppoint == '4' || *choppoint == '5'
yann@962
    33
+          || *choppoint == '6' || *choppoint == '7'
yann@962
    34
+          || *choppoint == '8' || *choppoint == '9')
yann@962
    35
+          continue;
yann@962
    36
+        else
yann@962
    37
+          {
yann@962
    38
+            *choppoint = 0;
yann@962
    39
+            break;
yann@962
    40
+          }
yann@962
    41
+      }
yann@962
    42
+    }
yann@962
    43
+
yann@962
    44
   /* Now convert it into a number.  The string consists of at most
yann@962
    45
-     three parts.  */
yann@962
    46
+     three parts.  Now it does, anyway.  ;-)  */
yann@962
    47
   version = 0;
yann@962
    48
   parts = 0;
yann@962
    49
   cp = buf;