autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

autoconf 2.50: Libdnet may be linked in unnecessarily with libX11


From: Maciej W. Rozycki
Subject: autoconf 2.50: Libdnet may be linked in unnecessarily with libX11
Date: Tue, 5 Jun 2001 22:30:01 +0200 (MET DST)

Hi,

 There is a problem with AC_PATH_XTRA -- it may link in libdnet
unnecessarily when linking with libX11.  There are two scenarios it can
happen:

1. Libdnet is available but no DECnet support is built in into X11.

2. Libdnet is available and X11 support DECnet but libX11 and other
relevant libraries are ELF and explicitly linked against libdnet, so they
include appropriate DT_NEEDED entries in their dynamic sections.

In both cases the resulting executable depends on libdnet even though it
usually has no idea of DECnet and the binary would otherwise run fine
whether a given system supports DECnet or not.  The libdnet dependency
prevents it from running on systems missing it.

 For example, on my i386-linux-gnu system, I have:

$ LD_TRACE_LOADED_OBJECTS=1 /usr/X11R6/bin/xev
        libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4001f000)
        libc.so.6 => /lib/libc.so.6 (0x400c9000)
        libdnet.so.2 => /lib/libdnet.so.2 (0x401f1000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
$ readelf -d /usr/X11R6/bin/xev

Dynamic segment at offset 0x32a0 contains 21 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libX11.so.6]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000c (INIT)                       0x8048858
[...]
$ readelf -d /usr/X11R6/lib/libX11.so.6

Dynamic segment at offset 0xa8494 contains 21 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libdnet.so.2]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000e (SONAME)                     Library soname: [libX11.so.6]
 0x0000000c (INIT)                       0x11a3c
[...]

No need to link against libdnet explicitly as libX11 already carries an
appropriate dependency.

 The following patch tries to link against libX11 first and only if that
fails it checks for libdnet.  This way libdnet is still linked in if
building statically or libX11 lacks the dependency.  It works fine for
some time now (as indicated by the date within -- I should have really
submitted it long time ago -- sorry).  It applies against 2.50 cleanly. 

2001-06-05  Maciej W. Rozycki  <address@hidden>

        * acspecific.m4 (AC_PATH_XTRA): Check if linking against libX11
        succeeds and only try adding libdnet upon a failure. 

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: address@hidden, PGP key available        +

autoconf-2.13-X-dnet.patch
diff -u --recursive --new-file autoconf-2.13.macro/acspecific.m4 
autoconf-2.13/acspecific.m4
--- autoconf-2.13.macro/acspecific.m4   Tue Jan  5 13:27:52 1999
+++ autoconf-2.13/acspecific.m4 Sun Dec 19 00:24:44 1999
@@ -2549,11 +2549,14 @@
     # address@hidden says this is needed for Ultrix, if the X
     # libraries were built with DECnet support.  And address@hidden says
     # the Alpha needs dnet_stub (dnet does not exist).
-    AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
+    ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
+    AC_TRY_LINK(, [XOpenDisplay()], ,
+    [AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
     if test $ac_cv_lib_dnet_dnet_ntoa = no; then
       AC_CHECK_LIB(dnet_stub, dnet_ntoa,
        [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
-    fi
+    fi])
+    LIBS="$ac_xsave_LIBS"
 
     # address@hidden says -lnsl (and -lsocket) are needed for his 386/AT,
     # to get the SysV transport functions.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]