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

[libgfortran, build] Use -z ignore instead of --as-needed on Solaris


As requested by Tobias, this patch supports -z ignore with Solaris ld
instead of GNU ld's --as-needed.

i386-pc-solaris2.10 and x86_64-unknown-linux-gnu bootstraps are still
running.  In both cases, the correct options were detected and written
into libgfortran.spec.  AFAICS the -static-libgfortran option isn't
exercised anywhere in the testsuite, so I've both relinked one of the
gfortran.dg testcases and a trivial FORTRAN hello world program with
-static-libgfortran.  -z ignore/--as-needed is passed correctly in both
cases, but while libgfortran is now linked statically, libquadmath.so is
still dragged in due to references to at least quadmath_snprintf.  I
thus can't tell if this --as-needed/-z ignore stuff ever does any good.

Ok for mainline if testing passes?

Thanks.
        Rainer


2013-05-14  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* acinclude.m4 (libgfor_cv_have_as_needed): Check for -z ignore, too.
	* configure: Regenerate.

# HG changeset patch
# Parent 552725704163412331462fc576619c0e82697a9a
 Use -z ignore instead of --as-needed on Solaris

diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4
--- a/libgfortran/acinclude.m4
+++ b/libgfortran/acinclude.m4
@@ -296,7 +296,7 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
   if test "x$libgfor_cv_have_float128" = xyes; then
     AC_DEFINE(HAVE_FLOAT128, 1, [Define if have a usable __float128 type.])
 
-    dnl Check whether -Wl,--as-needed is supported
+    dnl Check whether -Wl,--as-needed resp. -Wl,-zignore is supported
     dnl 
     dnl Turn warnings into error to avoid testsuite breakage.  So enable
     dnl AC_LANG_WERROR, but there's currently (autoconf 2.64) no way to turn
@@ -304,23 +304,39 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
     dnl AC_PATH_XTRA.
     dnl Cf. http://gcc.gnu.org/ml/gcc-patches/2010-05/msg01889.html
     ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag=$ac_[]_AC_LANG_ABBREV[]_werror_flag
-    AC_CACHE_CHECK([whether --as-needed works],
+    AC_CACHE_CHECK([whether --as-needed/-z ignore works],
       [libgfor_cv_have_as_needed],
       [
+      # Test for native Solaris options first.
+      # No whitespace after -z to pass it through -Wl.
+      libgfor_cv_as_needed_option="-zignore"
+      libgfor_cv_no_as_needed_option="-zrecord"
       save_LDFLAGS="$LDFLAGS"
-      LDFLAGS="$LDFLAGS -Wl,--as-needed -lm -Wl,--no-as-needed"
+      LDFLAGS="$LDFLAGS -Wl,$libgfor_cv_as_needed_option -lm -Wl,$libgfor_cv_no_as_needed_option"
       libgfor_cv_have_as_needed=no
       AC_LANG_WERROR
       AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
 		     [libgfor_cv_have_as_needed=yes],
 		     [libgfor_cv_have_as_needed=no])
       LDFLAGS="$save_LDFLAGS"
+      if test "x$libgfor_cv_have_as_needed" = xno; then
+	libgfor_cv_as_needed_option="--as-needed"
+	libgfor_cv_no_as_needed_option="--no-as-needed"
+	save_LDFLAGS="$LDFLAGS"
+	LDFLAGS="$LDFLAGS -Wl,$libgfor_cv_as_needed_option -lm -Wl,$libgfor_cv_no_as_needed_option"
+	libgfor_cv_have_as_needed=no
+	AC_LANG_WERROR
+	AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
+		       [libgfor_cv_have_as_needed=yes],
+		       [libgfor_cv_have_as_needed=no])
+	LDFLAGS="$save_LDFLAGS"
+      fi
       ac_[]_AC_LANG_ABBREV[]_werror_flag=$ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag
     ])
 
     dnl For static libgfortran linkage, depend on libquadmath only if needed.
     if test "x$libgfor_cv_have_as_needed" = xyes; then
-      LIBQUADSPEC="%{static-libgfortran:--as-needed} -lquadmath %{static-libgfortran:--no-as-needed}"
+      LIBQUADSPEC="%{static-libgfortran:$libgfor_cv_as_needed_option} -lquadmath %{static-libgfortran:$libgfor_cv_no_as_needed_option}"
     else
       LIBQUADSPEC="-lquadmath"
     fi
-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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