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]

fix PR 6768


This ought to add a DT_NEEDED tag against libm on libbfd.so and
libopcodes.so for systems that don't supply frexp in libc.so, fixing
the --enable-shared build breakage reported in PR 6768.

bfd/
	PR 6768
	* configure.in: Test for ld --as-needed support.  Link shared
	libbfd against libm.
	* configure: Regenerate.
opcodes/
	PR 6768
	* configure.in: Test for ld --as-needed support.  Link shared
	libopcodes against libm.
	* configure: Regenerate.


Index: bfd/configure.in
===================================================================
RCS file: /cvs/src/src/bfd/configure.in,v
retrieving revision 1.255
diff -u -p -r1.255 configure.in
--- bfd/configure.in	2 Mar 2009 10:33:05 -0000	1.255
+++ bfd/configure.in	4 Mar 2009 01:24:56 -0000
@@ -494,6 +494,16 @@ if test -n "$TRAD_HEADER"; then
     [Name of host specific header file to include in trad-core.c.])
 fi
 
+# Check if linker supports --as-needed and --no-as-needed options
+AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
+	[bfd_cv_ld_as_needed=no
+	if $LD --help 2>/dev/null | grep as-needed > /dev/null; then
+		bfd_cv_ld_as_needed=yes
+	fi
+	])
+
+LT_LIB_M
+
 # When building a shared libbfd, link against the pic version of libiberty
 # so that apps that use libbfd won't need libiberty just to satisfy any
 # libbfd references.
@@ -516,6 +526,18 @@ changequote([,])dnl
     SHARED_LIBADD="-L`pwd`/../libiberty -liberty -L`pwd`/../intl -lintl -lcygwin -lkernel32"
   ;;
   esac
+
+  if test -n "$SHARED_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"
+      else
+	SHARED_LIBADD="$SHARED_LIBADD $LIBM"
+      fi
+    fi
+  fi
 fi
 AC_SUBST(SHARED_LDFLAGS)
 AC_SUBST(SHARED_LIBADD)
Index: opcodes/configure.in
===================================================================
RCS file: /cvs/src/src/opcodes/configure.in,v
retrieving revision 1.88
diff -u -p -r1.88 configure.in
--- opcodes/configure.in	2 Mar 2009 10:33:08 -0000	1.88
+++ opcodes/configure.in	4 Mar 2009 01:25:06 -0000
@@ -91,6 +91,16 @@ AC_SUBST(cgendir)
 
 using_cgen=no
 
+# Check if linker supports --as-needed and --no-as-needed options
+AC_CACHE_CHECK(linker --as-needed support, bfd_cv_ld_as_needed,
+	[bfd_cv_ld_as_needed=no
+	if $LD --help 2>/dev/null | grep as-needed > /dev/null; then
+		bfd_cv_ld_as_needed=yes
+	fi
+	])
+
+LT_LIB_M
+
 # Horrible hacks to build DLLs on Windows and a shared library elsewhere.
 SHARED_LDFLAGS=
 SHARED_LIBADD=
@@ -132,6 +142,18 @@ changequote([,])dnl
       SHARED_DEPENDENCIES="../bfd/libbfd.la"
       ;;
   esac
+
+  if test -n "$SHARED_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"
+      else
+	SHARED_LIBADD="$SHARED_LIBADD $LIBM"
+      fi
+    fi
+  fi
 fi
 AC_SUBST(SHARED_LDFLAGS)
 AC_SUBST(SHARED_LIBADD)

-- 
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]