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: build failure, --enable-targets=all vs plugin support


On Sun, Oct 18, 2009 at 11:11:19AM -0700, Doug Evans wrote:
> With cvs head I'm getting a build failure,
> all programs using bfd are failing to link:
> 
> ../bfd/.libs/libbfd.so: undefined reference to `dlsym'
> ../bfd/.libs/libbfd.so: undefined reference to `dlerror'
> ../bfd/.libs/libbfd.so: undefined reference to `dlopen'

Hmm, so --enable-targets=all and --enable-shared.

> I haven't been following bfd plugin support,
> so I'm not sure what the right fix is.

Two options:
Take plugins out of --enable-targets=all.  Like this

	* plugin.c: Produce empty object if not BFD_SUPPORTS_PLUGINS.

Index: bfd/plugin.c
===================================================================
RCS file: /cvs/src/src/bfd/plugin.c,v
retrieving revision 1.4
diff -u -p -r1.4 plugin.c
--- bfd/plugin.c	29 Aug 2009 22:10:58 -0000	1.4
+++ bfd/plugin.c	19 Oct 2009 10:27:24 -0000
@@ -20,6 +20,10 @@
    MA 02110-1301, USA.  */
 
 #include "config.h"
+#include "bfd.h"
+
+#if BFD_SUPPORTS_PLUGINS
+
 #include <assert.h>
 #include <dlfcn.h>
 #include <stdarg.h>
@@ -492,3 +496,4 @@ const bfd_target plugin_vec =
 
   NULL  			/* backend_data.  */
 };
+#endif /* BFD_SUPPORTS_PLUGIN */


Or add -ldl to SHARED_LIBADD as required in configure.in.  I took this
approach first but the first one is probably better since the addition
of plugin.c will have broken --enable-shared for any host without -ldl.
Opinions?

	* configure.in (PLUGINS): Delete.
	(BFD_LDFLAGS): Rename from SHARED_LDFLAGS.
	(BFD_LIBADD): Rename from SHARED_LIBADD.  Add -ldl when plugins
	or shared and all targets.
	* configure: Regenerate.
	* Makefile.am: Delete all references to LIBDL.  Rename references
	to SHARED_LDFLAGS and SHARED_LIBADD.
	* Makefile.in: Regenerate.

Index: bfd/configure.in
===================================================================
RCS file: /cvs/src/src/bfd/configure.in,v
retrieving revision 1.272
diff -u -p -r1.272 configure.in
--- bfd/configure.in	29 Sep 2009 14:17:03 -0000	1.272
+++ bfd/configure.in	19 Oct 2009 09:42:14 -0000
@@ -27,8 +27,6 @@ LT_INIT([dlopen])
 
 AC_PLUGINS
 
-AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
-
 if test "$plugins" = "yes"; then
   if test "$enable_dlopen" != "yes" ; then
     AC_MSG_ERROR([
@@ -525,38 +523,50 @@ LT_LIB_M
 # libbfd references.
 # We can't do that if a pic libiberty is unavailable since including non-pic
 # code would insert text relocations into libbfd.
-SHARED_LIBADD=
-SHARED_LDFLAGS=
+BFD_LIBADD=
+BFD_LDFLAGS=
 if test "$enable_shared" = "yes"; then
 changequote(,)dnl
   x=`sed -n -e 's/^[ 	]*PICFLAG[ 	]*=[ 	]*//p' < ../libiberty/Makefile | sed -n '$p'`
 changequote([,])dnl
   if test -n "$x"; then
-    SHARED_LIBADD="-L`pwd`/../libiberty/pic -liberty"
+    BFD_LIBADD="-L`pwd`/../libiberty/pic -liberty"
   fi
 
 # More hacks to build DLLs on Windows.
   case "${host}" in
   *-*-cygwin*)
-    SHARED_LDFLAGS="-no-undefined"
-    SHARED_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin -lkernel32"
+    BFD_LDFLAGS="-no-undefined"
+    BFD_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin -lkernel32"
   ;;
   esac
 
-  if test -n "$SHARED_LIBADD"; then
+  if test -n "$BFD_LIBADD"; then
     if test -n "$LIBM"; then
       if test x"$bfd_cv_ld_as_needed" = xyes; then
 	# Link against libm only when needed.  Put -lc, -lm inside -Wl
 	# to stop libtool reordering these options.
-	SHARED_LIBADD="$SHARED_LIBADD -Wl,-lc,--as-needed,`echo $LIBM | sed 's/ /,/g'`,--no-as-needed"
+	BFD_LIBADD="$BFD_LIBADD -Wl,-lc,--as-needed,`echo $LIBM | sed 's/ /,/g'`,--no-as-needed"
       else
-	SHARED_LIBADD="$SHARED_LIBADD $LIBM"
+	BFD_LIBADD="$BFD_LIBADD $LIBM"
       fi
     fi
   fi
 fi
-AC_SUBST(SHARED_LDFLAGS)
-AC_SUBST(SHARED_LIBADD)
+
+case " $enable_targets " in
+  *" plugin "*)
+    BFD_LIBADD="$BFD_LIBADD -ldl"
+    ;;
+  *" all "*)
+    if test "$enable_shared" = "yes"; then
+      BFD_LIBADD="$BFD_LIBADD -ldl"
+    fi
+    ;;
+esac
+
+AC_SUBST(BFD_LDFLAGS)
+AC_SUBST(BFD_LIBADD)
 
 # target stuff:
 
Index: bfd/Makefile.am
===================================================================
RCS file: /cvs/src/src/bfd/Makefile.am,v
retrieving revision 1.243
diff -u -p -r1.243 Makefile.am
--- bfd/Makefile.am	29 Sep 2009 14:17:03 -0000	1.243
+++ bfd/Makefile.am	19 Oct 2009 09:43:48 -0000
@@ -32,9 +32,6 @@ WARN_CFLAGS = @WARN_CFLAGS@
 NO_WERROR = @NO_WERROR@
 AM_CFLAGS = $(WARN_CFLAGS)
 AM_CPPFLAGS = -DBINDIR='"$(bindir)"'
-if PLUGINS
-LIBDL = -ldl
-endif
 
 # bfd.h goes here, for now
 BFD_H = bfd.h
@@ -762,8 +759,8 @@ ofiles: stamp-ofiles ; @true
 libbfd_la_SOURCES = $(BFD32_LIBS_CFILES)
 EXTRA_libbfd_la_SOURCES = $(CFILES)
 libbfd_la_DEPENDENCIES = $(OFILES) ofiles
-libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL)
-libbfd_la_LDFLAGS += -release `cat libtool-soversion` @SHARED_LDFLAGS@
+libbfd_la_LIBADD = `cat ofiles` @BFD_LIBADD@
+libbfd_la_LDFLAGS += -release `cat libtool-soversion` @BFD_LDFLAGS@
 
 # libtool will build .libs/libbfd.a.  We create libbfd.a in the build
 # directory so that we don't have to convert all the programs that use

-- 
Alan Modra
Australia Development Lab, IBM


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