This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] bfd: Conditionally link against libdl for plugin support


Ping.

On 09/24/2012 05:59 PM, Meador Inge wrote:
> Hi All,
> 
> A few months back Kai fixed PR ld/12742 to enable plugins to work
> with mingw host binaries.  With a current binutils source tree I can't
> build for a i686-pc-mingw32 host (using Fedora MinGW 4.6.1-3.fc16)
> because -ldl is unconditionally placed on the link line whenever
> things are configured with --enable-plugins.
> 
> By my reading of PR ld/12742 others have gotten this to work.  I am not sure
> how since the -ldl seems unconditional is support for plugins is enabled.  The
> attached patch fixed things for me, but maybe I am missing something since
> others seem to have gotten this to work with unpatched sources.
> 
> Comments?
> 
> 2012-09-24  Meador Inge  <meadori@codesourcery.com>
> 
> 	* Makefile.am (LIBDL): Use @plugin_libs@.
> 	* Makefile.in: Regenerated.
> 	* doc/Makefile.in: Likewise.
> 	* configure.in (plugin_libs): New variable.
> 	* configure: Regenerated.
> 
> diff --git a/bfd/Makefile.am b/bfd/Makefile.am
> index 49f9662..8908c2c 100644
> --- a/bfd/Makefile.am
> +++ b/bfd/Makefile.am
> @@ -35,7 +35,7 @@ AM_CFLAGS = $(WARN_CFLAGS)
>  AM_CPPFLAGS = -DBINDIR='"$(bindir)"'
>  if PLUGINS
>  bfdinclude_HEADERS += $(INCDIR)/plugin-api.h
> -LIBDL = -ldl
> +LIBDL = @plugin_libs@
>  endif
>  
>  # bfd.h goes here, for now
> diff --git a/bfd/Makefile.in b/bfd/Makefile.in
> index 5718fab..78177ad 100644
> --- a/bfd/Makefile.in
> +++ b/bfd/Makefile.in
> @@ -297,6 +297,7 @@ mandir = @mandir@
>  mkdir_p = @mkdir_p@
>  oldincludedir = @oldincludedir@
>  pdfdir = @pdfdir@
> +plugin_libs = @plugin_libs@
>  prefix = @prefix@
>  program_transform_name = @program_transform_name@
>  psdir = @psdir@
> @@ -336,7 +337,7 @@ libbfd_la_LDFLAGS = $(am__append_1) -release `cat libtool-soversion` \
>  @INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la
>  AM_CFLAGS = $(WARN_CFLAGS)
>  AM_CPPFLAGS = -DBINDIR='"$(bindir)"'
> -@PLUGINS_TRUE@LIBDL = -ldl
> +@PLUGINS_TRUE@LIBDL = @plugin_libs@
>  
>  # bfd.h goes here, for now
>  BFD_H = bfd.h
> diff --git a/bfd/configure b/bfd/configure
> index d81719d..5472b1d 100755
> --- a/bfd/configure
> +++ b/bfd/configure
> @@ -660,6 +660,7 @@ REPORT_BUGS_TEXI
>  REPORT_BUGS_TO
>  PKGVERSION
>  DEBUGDIR
> +plugin_libs
>  PLUGINS_FALSE
>  PLUGINS_TRUE
>  OTOOL64
> @@ -11414,7 +11415,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11417 "configure"
> +#line 11418 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -11520,7 +11521,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11523 "configure"
> +#line 11524 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -12003,6 +12004,7 @@ else
>    PLUGINS_FALSE=
>  fi
>  
> +plugin_libs=''
>  
>  if test "$plugins" = "yes"; then
>    if test "$enable_dlopen" != "yes" ; then
> @@ -12010,7 +12012,65 @@ if test "$plugins" = "yes"; then
>        Building BFD with plugin support requires a host that supports -ldl." "$LINENO" 5
>    fi
>    enable_targets="$enable_targets plugin"
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5
> +$as_echo_n "checking for library containing dlopen... " >&6; }
> +if test "${ac_cv_search_dlopen+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  ac_func_search_save_LIBS=$LIBS
> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
> +/* Override any GCC internal prototype to avoid an error.
> +   Use char because int might match the return type of a GCC
> +   builtin and then its argument prototype would still apply.  */
> +#ifdef __cplusplus
> +extern "C"
> +#endif
> +char dlopen ();
> +int
> +main ()
> +{
> +return dlopen ();
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +for ac_lib in '' dl; do
> +  if test -z "$ac_lib"; then
> +    ac_res="none required"
> +  else
> +    ac_res=-l$ac_lib
> +    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> +  fi
> +  if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_search_dlopen=$ac_res
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext
> +  if test "${ac_cv_search_dlopen+set}" = set; then :
> +  break
>  fi
> +done
> +if test "${ac_cv_search_dlopen+set}" = set; then :
> +
> +else
> +  ac_cv_search_dlopen=no
> +fi
> +rm conftest.$ac_ext
> +LIBS=$ac_func_search_save_LIBS
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5
> +$as_echo "$ac_cv_search_dlopen" >&6; }
> +ac_res=$ac_cv_search_dlopen
> +if test "$ac_res" != no; then :
> +  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> +  plugin_libs="-ldl"
> +fi
> +
> +fi
> +
> +
>  
>  # Check whether --enable-64-bit-bfd was given.
>  if test "${enable_64_bit_bfd+set}" = set; then :
> diff --git a/bfd/configure.in b/bfd/configure.in
> index 612d032..f86079d 100644
> --- a/bfd/configure.in
> +++ b/bfd/configure.in
> @@ -29,6 +29,7 @@ LT_INIT([dlopen])
>  ACX_LARGEFILE
>  
>  AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
> +plugin_libs=''
>  
>  if test "$plugins" = "yes"; then
>    if test "$enable_dlopen" != "yes" ; then
> @@ -36,8 +37,11 @@ if test "$plugins" = "yes"; then
>        Building BFD with plugin support requires a host that supports -ldl.])
>    fi
>    enable_targets="$enable_targets plugin"
> +  AC_SEARCH_LIBS([dlopen], [dl], [plugin_libs="-ldl"])
>  fi
>  
> +AC_SUBST(plugin_libs)
> +
>  AC_ARG_ENABLE(64-bit-bfd,
>  [  --enable-64-bit-bfd     64-bit support (on hosts with narrower word sizes)],
>  [case "${enableval}" in
> diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in
> index 7ba351d..169e9d5 100644
> --- a/bfd/doc/Makefile.in
> +++ b/bfd/doc/Makefile.in
> @@ -251,6 +251,7 @@ mandir = @mandir@
>  mkdir_p = @mkdir_p@
>  oldincludedir = @oldincludedir@
>  pdfdir = @pdfdir@
> +plugin_libs = @plugin_libs@
>  prefix = @prefix@
>  program_transform_name = @program_transform_name@
>  psdir = @psdir@


-- 
Meador Inge
CodeSourcery / Mentor Embedded
http://www.mentor.com/embedded-software


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]