[oi-dev] Strange libgmp effect

Alexander Pyhalov alp at rsu.ru
Tue Jun 18 20:45:17 UTC 2013


Hello.
While testing 3801 bug fix I observed one interestin unrelated GCC 
effect.
We have two gmp libraries:
one from library/gmp

$ ls -l /usr/lib/libgmp.so*
lrwxrwxrwx 1 root root     15 Jun 13 23:28 /usr/lib/libgmp.so -> 
libgmp.so.3.5.0
lrwxrwxrwx 1 root root     15 Jun 13 23:28 /usr/lib/libgmp.so.3 -> 
libgmp.so.3.5.0
-rwxr-xr-x 1 root bin  294528 Jun 13 23:28 /usr/lib/libgmp.so.3.5.0

and another coming with gcc
$ ls -l  /usr/gcc/4.7/lib/libgmp.so*
lrwxrwxrwx 1 root root     16 Jun 13 23:39 /usr/gcc/4.7/lib/libgmp.so -> 
libgmp.so.10.0.5
lrwxrwxrwx 1 root root     16 Jun 13 23:39 /usr/gcc/4.7/lib/libgmp.so.10 
-> libgmp.so.10.0.5
-r-xr-xr-x 1 root bin  577620 Jun 13 23:39 
/usr/gcc/4.7/lib/libgmp.so.10.0.5

Now, when autoconf tries to find libgmp it tries to compile the next 
program:
/* confdefs.h */
#define PACKAGE_NAME "FULL-PACKAGE-NAME"
#define PACKAGE_TARNAME "full-package-name"
#define PACKAGE_VERSION "VERSION"
#define PACKAGE_STRING "FULL-PACKAGE-NAME VERSION"
#define PACKAGE_BUGREPORT "BUG-REPORT-ADDRESS"
#define PACKAGE_URL ""
#define HAVE_LIBGMP 1
#define HAVE_DECL_MPZ_POWM 1
#define HAVE_DECL_MPZ_POWM_SEC 1
/* end confdefs.h.  */
#include <ctype.h>
#include <stdlib.h>
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c)              (('a' <= (c) && (c) <= 'i')             
|| ('j' <= (c) && (c) <= 'r')                   || ('s' <= (c) && (c) <= 
'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif

#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i))
return 2;
return 0;
}

with: gcc -o gmp gmp.c -O2 -lgmp
The command finishes succesfully but links gmp to libgmp.so.10:
$ ldd gmp
libgmp.so.10 =>  (file not found)
libc.so.1 =>     /lib/libc.so.1
libm.so.2 =>     /lib/libm.so.2
So, the resulting binary cannot be run.

So, I have an ethernal question: who is guilty and what to do?

-- 
System Administrator of Southern Federal University Computer Center





More information about the oi-dev mailing list