mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Change use of AC_CHECK_LIB to AC_SEARCH_LIBS.
Patch from Zack Weinberg. His message: This one eliminates all use of AC_CHECK_LIB in the configure script. AC_CHECK_LIB has a serious flaw: if the library you mention *exists* but is not *necessary* for the function you want, it adds it to $(LIBS) anyway. This was fine in the days of static libraries, because the linker would ignore an .a library that didn't contain anything you needed. However, ELF shared libraries are different (let's not get into why): the linker will by default record a DT_NEEDED entry for every shared object mentioned on the link command line. Thus, every use of AC_CHECK_LIB is a potential unnecessary DT_NEEDED, making extra work for the dynamic loader. The cure is simply to use AC_SEARCH_LIBS instead; it first tries to find the function you ask for in libc, and only if that doesn't work does it try to use the extra library you mention. For the same reasons, pkg-config .pc files should distinguish between the libraries to use for shared linkage (Libs:) and the additional libraries needed for static linkage (Libs.private:). I have also made that correction in this patch. I also took the opportunity to clean up the substitution variables a little and make absolutely sure that the core library does not get linked against zlib. svn:r1338
This commit is contained in:
parent
a501d6833b
commit
d3a8ccb807
@ -41,6 +41,7 @@ Changes in 2.0.2-alpha:
|
|||||||
o Allow specifying the output filename for rpcgen; based on work by jmansion; patch from Zack Weinberg.
|
o Allow specifying the output filename for rpcgen; based on work by jmansion; patch from Zack Weinberg.
|
||||||
o Allow C identifiers as struct names; allow multiple comments in .rpc files; from Zack Weinberg
|
o Allow C identifiers as struct names; allow multiple comments in .rpc files; from Zack Weinberg
|
||||||
o Mitigate a race condition when using socket bufferevents in multiple threads.
|
o Mitigate a race condition when using socket bufferevents in multiple threads.
|
||||||
|
o Use AC_SEARCH_LIBS, not AC_CHECK_LIB to avoid needless library use.
|
||||||
|
|
||||||
|
|
||||||
Changes in 2.0.1-alpha:
|
Changes in 2.0.1-alpha:
|
||||||
|
24
configure.in
24
configure.in
@ -45,22 +45,24 @@ dnl AC_DISABLE_SHARED
|
|||||||
AC_SUBST(LIBTOOL_DEPS)
|
AC_SUBST(LIBTOOL_DEPS)
|
||||||
|
|
||||||
dnl Checks for libraries.
|
dnl Checks for libraries.
|
||||||
AC_CHECK_LIB(socket, socket, [AC_SUBST( [LIBSOCKET], ["-lsocket"] )] )
|
AC_SEARCH_LIBS([inet_ntoa], [nsl])
|
||||||
AC_CHECK_LIB(resolv, inet_aton, [AC_SUBST( [LIBRESOLV], ["-lresolv"] )] )
|
AC_SEARCH_LIBS([socket], [socket])
|
||||||
AC_CHECK_LIB(rt, clock_gettime, [AC_SUBST( [LIBRT], ["-lrt"] )] )
|
AC_SEARCH_LIBS([inet_aton], [resolv])
|
||||||
AC_CHECK_LIB(nsl, inet_ntoa, [AC_SUBST( [LIBNSL], ["-lnsl"] )] )
|
AC_SEARCH_LIBS([clock_gettime], [rt])
|
||||||
|
|
||||||
dnl Determine if we have zlib for regression tests
|
dnl Determine if we have zlib for regression tests
|
||||||
|
dnl Don't put this one in LIBS
|
||||||
|
save_LIBS="$LIBS"
|
||||||
|
LIBS=""
|
||||||
ZLIB_LIBS=""
|
ZLIB_LIBS=""
|
||||||
ZLIB_CFLAGS=""
|
have_zlib=no
|
||||||
AC_CHECK_LIB(z, inflateEnd,
|
AC_SEARCH_LIBS([inflateEnd], [z],
|
||||||
[have_zlib=yes
|
[have_zlib=yes
|
||||||
ZLIB_LIBS="-lz"
|
ZLIB_LIBS="$LIBS"
|
||||||
AC_DEFINE(HAVE_LIBZ, 1, [Define if the system has zlib])],
|
AC_DEFINE(HAVE_LIBZ, 1, [Define if the system has zlib])])
|
||||||
[have_zlib=no])
|
LIBS="$save_LIBS"
|
||||||
AC_SUBST(ZLIB_LIBS)
|
AC_SUBST(ZLIB_LIBS)
|
||||||
AC_SUBST(ZLIB_CFLAGS)
|
AM_CONDITIONAL(ZLIB_REGRESS, [test "$have_zlib" = "yes"])
|
||||||
AM_CONDITIONAL(ZLIB_REGRESS, [test "$have_zlib" != "no"])
|
|
||||||
|
|
||||||
dnl Checks for header files.
|
dnl Checks for header files.
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
|
@ -10,6 +10,7 @@ Description: libevent is an asynchronous notification event loop library
|
|||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Requires:
|
Requires:
|
||||||
Conflicts:
|
Conflicts:
|
||||||
Libs: -L${libdir} -levent @LIBSOCKET@ @LIBRESOLV@ @LIBRT@ @LIBNSL@ @ZLIB_LIBS@
|
Libs: -L${libdir} -levent
|
||||||
|
Libs.private: @LIBS@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user