This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java 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]

fixing library dependencies for -Wl,--as-needed (PR 38298)


When building with
  configure --with-boot-ldflags=-Wl,--as-needed \
            --with-stage1-ldflags=-Wl,--as-needed \
            LDFLAGS_FOR_TARGET=-Wl,--as-needed
  make LDFLAGS_FOR_TARGET=-Wl,--as-needed

I get two failures.  One is PR libgcj/38298,  causing some programs in
libjava fail to link due to missing -lm (see the PR for details), the
other is during all-stage1-gcc:

gcc  -g -fkeep-inline-functions -DIN_GCC   -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H -Wl,--as-needed -o cc1-dummy c-lang.o stub-objc.o attribs.o c-errors.o c-lex.o c-pragma.o c-decl.o c-typeck.o c-convert.o c-aux-info.o c-common.o c-opts.o c-format.o c-semantics.o c-ppoutput.o c-cppbuiltin.o c-objc-common.o c-dump.o c-pch.o c-parser.o i386-c.o c-gimplify.o tree-mudflap.o c-pretty-print.o c-omp.o \
          dummy-checksum.o main.o tree-browser.o libbackend.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a ../libcpp/libcpp.a   ../libiberty/libiberty.a ../libdecnumber/libdecnumber.a    -lmpfr -lgmp -rdynamic 
libbackend.a(plugin.o): In function `try_init_one_plugin':
/tmp/build/gcc/../../gcc/gcc/plugin.c:599: undefined reference to `dlopen'
/tmp/build/gcc/../../gcc/gcc/plugin.c:602: undefined reference to `dlerror'
[...]

which is due to a bogus test in gcc/configure:

| gcc -o conftest -g -fkeep-inline-functions   -Wl,--as-needed -rdynamic -ldl conftest.c

This fails to link because -ldl needs to be specified after the
objects or sources that need them (conftest.c).

This patch fixes these issues, and cause bootstrap to finish
successfully on x86_64-unknown-linux-gnu.  OK for trunk?

Thanks,
Ralf

gcc/ChangeLog:
2009-09-26  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>

	* configure.ac: Use $LIBS for '-ldl', not $LDFLAGS.
	* configure: Regenerate.

libjava/ChangeLog:
2009-09-26  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>

	PR libgcj/38298
	* Makefile.am (libgcj_tools_la_LIBADD): Add '-lm'.
	* Makefile.in: Regenerate.

diff --git a/gcc/configure.ac b/gcc/configure.ac
index a90585a..649ec4d 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4228,7 +4228,7 @@ if test x"$enable_plugin" = x"yes"; then
   fi
 
   # Check -ldl
-  LDFLAGS="$LDFLAGS -ldl"
+  LIBS="$LIBS -ldl"
   AC_MSG_CHECKING([for -ldl])
   AC_TRY_LINK(
     [#include <dlfcn.h>],
diff --git a/libjava/Makefile.am b/libjava/Makefile.am
index e923fa3..ad4fca2 100644
--- a/libjava/Makefile.am
+++ b/libjava/Makefile.am
@@ -496,7 +496,7 @@ libgcj_tools_la_GCJFLAGS = $(AM_GCJFLAGS) -findirect-dispatch \
 libgcj_tools_la_LDFLAGS = -rpath $(toolexeclibdir) \
  -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
  $(LIBGCJ_LD_SYMBOLIC_FUNCTIONS) -no-undefined -bindir $(bindir)
-libgcj_tools_la_LIBADD = libgcj.la
+libgcj_tools_la_LIBADD = libgcj.la -lm
 libgcj_tools_la_DEPENDENCIES = libgcj.la libgcj.spec
 if BUILD_SUBLIBS
 libgcj_tools_la_DEPENDENCIES += libgcj-noncore.la


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