Subject: libtool 2.4.6: incorrect linking with tcc under GNU/Linux

From: Vincent Lefevre <[email-masked]>
Date: Thu, 21 May 2015 18:41:07 +0200

I've installed libtool 2.4.6 on my Debian unstable machine in some
non-system directory. When I build GNU MPFR with CC=tcc LD=tcc, I
get things like:

  libtool: link: tcc -O2 -o tzeta_ui tzeta_ui.o  -L../src/.libs ./.libs/libfrtests.a -lm ../src/.libs/libmpfr.so -lgmp

The problem is that the MPFR library used at run time is not
../src/.libs/libmpfr.so but the one installed on the system.

When I use libtool 2.4.2 with the following patch:

--- a/libltdl/m4/libtool.m4
+++ b/libltdl/m4/libtool.m4
@@ -4375,6 +4375,14 @@
        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
        _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
        ;;
+      tcc*)
+       # Fabrice Bellard et al's Tiny C Compiler
+       # When it learns to make shared objects, it will
+       # presumably use -fPIC.
+       _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+       _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+       ;;
       pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
         # Portland Group compilers (*not* the Pentium gcc compiler,
        # which looks to be a dead project)

I get:

  libtool: link: tcc -O2 -o tzeta_ui tzeta_ui.o  -L../src/.libs ./.libs/libfrtests.a -lm ../src/.libs/libmpfr.a -lgmp

(libmpfr.a instead of libmpfr.so) and the problem doesn't occur.

So, either libtool should select libmpfr.a as before or it should
make sure that the correct full path to libmpfr.so be used (something
like run path setting?).

-- 
Vincent Lefèvre <[email-masked]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)