Add --with-host-libstdcxx configure option to allow Graphite build with static PPL etc.

Joseph S. Myers joseph@codesourcery.com
Mon Mar 16 01:06:00 GMT 2009


As previously discussed on the mailing lists and elsewhere (see
e.g. PR 38862, although that was for a slightly different issue that's
now fixed), building GCC with Graphite enabled using static PPL and
GMP libraries is broken because the linking does not use -lstdc++ and
so relies on one of the C++ libraries (PPL or the GMP C++ interface)
being a shared library with a shared library dependency on libstdc++.
Using static versions of all the libraries GCC links with is a
convenient way of avoiding any dependence on the system having the
right versions installed and producing binaries that do not depend on
any non-system shared libraries.

This patch adds a --with-host-libstdcxx configure option to allow you
to specify how to link libstdc++ in this case; this way you can choose
to link with either static or shared libstdc++ depending on the option
you pass.  Tested x86_64-linux-gnu (where building in this
configuration failed before, and passes given this option).  OK to
commit?

(I think this option still makes sense with gcc-in-cxx; it will be
useful to be able to link a cross compiler using gcc not g++ and
specifying how to link against libstdc++, including linking it
statically with libstdc++ or linking it with a shared libstdc++ and a
-rpath option specified.  Though it's quite likely more work will be
needed to get --with-host-libstdcxx arguments involving
-Wl,-rpath,$ORIGIN/some/where passed correctly through the various
layers of make and shell without the $ getting in the way.)

2009-03-15  Joseph Myers  <joseph@codesourcery.com>

	* configure.ac (--with-host-libstdcxx): New option.
	* configure: Regenerate.

gcc/doc:
2009-03-15  Joseph Myers  <joseph@codesourcery.com>

	* doc/install.texi (--with-host-libstdcxx): Document.

Index: configure.ac
===================================================================
--- configure.ac	(revision 144874)
+++ configure.ac	(working copy)
@@ -1315,11 +1315,20 @@
 AC_SUBST(gmplibs)
 AC_SUBST(gmpinc)
 
+# Allow host libstdc++ to be specified for static linking with PPL.
+AC_ARG_WITH(host-libstdcxx, [  --with-host-libstdcxx=L Use linker arguments L to link with libstdc++
+                          when linking with PPL])
 
+case $with_host_libstdcxx in
+  no|yes)
+    AC_MSG_ERROR([-with-host-libstdcxx needs an argument])
+    ;;
+esac
+
 # Check for PPL
 ppl_major_version=0
 ppl_minor_version=10
-ppllibs=" -lppl_c -lppl -lgmpxx "
+ppllibs=" -lppl_c -lppl -lgmpxx $with_host_libstdcxx "
 pplinc=
 
 AC_ARG_WITH(ppl, [  --with-ppl=PATH         Specify prefix directory for the installed PPL package
@@ -1333,7 +1342,7 @@
     ppllibs=
     ;;
   *)
-    ppllibs="-L$with_ppl/lib -lppl_c -lppl -lgmpxx"
+    ppllibs="-L$with_ppl/lib -lppl_c -lppl -lgmpxx $with_host_libstdcxx"
     pplinc="-I$with_ppl/include $pplinc"
     LIBS="$ppllibs $LIBS"
     ;;
@@ -1342,11 +1351,11 @@
   pplinc="-I$with_ppl_include $pplinc"
 fi
 if test "x$with_ppl_lib" != x; then
-  ppllibs="-L$with_ppl_lib -lppl_c -lppl -lgmpxx"
+  ppllibs="-L$with_ppl_lib -lppl_c -lppl -lgmpxx $with_host_libstdcxx"
   LIBS="$ppllibs $LIBS"
 fi
 if test "x$with_ppl$with_ppl_include$with_ppl_lib" = x && test -d ${srcdir}/ppl; then
-  ppllibs='-L$$r/$(HOST_SUBDIR)/ppl/.libs -L$$r/$(HOST_SUBDIR)/ppl/_libs -lppl_c -lppl -lgmpxx '
+  ppllibs='-L$$r/$(HOST_SUBDIR)/ppl/.libs -L$$r/$(HOST_SUBDIR)/ppl/_libs -lppl_c -lppl -lgmpxx '"$with_host_libstdcxx "
   pplinc='-I$$r/$(HOST_SUBDIR)/ppl/include -I$$s/ppl/include '
   LIBS="$ppllibs $LIBS"
 fi
Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi	(revision 144874)
+++ gcc/doc/install.texi	(working copy)
@@ -1476,6 +1476,15 @@
 shorthand assumptions are not correct, you can use the explicit
 include and lib options directly.
 
+@item --with-host-libstdcxx=@var{linker-args}
+If you are linking with a static copy of PPL, you can use this option
+to specify how the linker should find the standard C++ library used
+internally by PPL.  Typical values of @var{linker-args} might be
+@samp{-lstdc++} or @samp{-Wl,-Bstatic,-lstdc++,-Bdynamic -lm}.  If you are
+linking with a shared copy of PPL, you probably do not need this
+option; shared library dependencies will cause the linker to search
+for the standard C++ library automatically.
+
 @item --with-debug-prefix-map=@var{map}
 Convert source directory names using @option{-fdebug-prefix-map} when
 building runtime libraries.  @samp{@var{map}} is a space-separated

-- 
Joseph S. Myers
joseph@codesourcery.com



More information about the Gcc-patches mailing list