]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
libtool: check Sun Pro CXX ABI postdeps at libtool time.
authorGary V. Vaughan <gary@gnu.org>
Fri, 12 Dec 2014 18:35:45 +0000 (18:35 +0000)
committerGary V. Vaughan <gary@gnu.org>
Fri, 12 Dec 2014 18:35:45 +0000 (18:35 +0000)
* m4/libtool.m4 (_LT_PREPARE_CC_BASENAME): Factor cc_basename
calculation into a shell function...
(_LT_CONFIG_SAVE_COMMAND): ...and expand it into generated
libtool script.
(_LT_CC_BASENAME): Adjust accordingly.
(_LT_FUNC_SUNCC_CSTD_ABI): Remove from here...
* build-aux/ltmain.in (func_suncc_cstd_abi): ...and reimplement
here.
* m4/libtool.m4 (_LT_SYS_HIDDEN_LIBDEPS): Remove postdeps
augmentation from here...
* build-aux/ltmain.in (func_mode_link): ...and reimplement here
just before postdeps are added.
* NEWS: Update.

Signed-off-by: Gary V. Vaughan <gary@gnu.org>
NEWS
build-aux/ltmain.in
m4/libtool.m4

diff --git a/NEWS b/NEWS
index c2f667b405a487f7197c9eb7075a329d11edc380..7b242ebe097f274ca90255217256fe1c115daa37 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,13 +21,20 @@ NEWS - list of user-visible changes between releases of GNU Libtool
   - Fix a 2.4.4 regression so that libltdl subprojects do not warn
     about missing libltdl/libltdl directory as in prior releases.
 
+  - When using Sun C++ on Solaris or GNU/Linux we used to set libtool's
+    postdeps permanently, based on the contents of $CXX and $CXXFLAGS at
+    configure time, which was brittle and error-prone.  Now, we no
+    longer check for a SunCC ABI at configure time, but augment the
+    postdeps at libtool time based on the current invocation flags on
+    each call.
+
 ** Changes in supported systems or compilers:
 
   - /usr/local prefixed rpaths are now added to the link-line on
     ia64-hp-hpux*, because the default system runtime loader path does
     not contain them.
 
-  - Previously, when using Sun C++ on Solaris or Linux, `-Cstd -Crun`
+  - Previously, when using Sun C++ on Solaris or GNU/Linux, `-Cstd -Crun`
     flags were added to $postdeps unless CXX or CXXFLAGS contained
     `-library=stlport4`.  Newer releases have added other compiler flags
     that are also incompatible with `-Cstd -Crun`, so now we don't add
index 42048dfe346afa9a184002204347f729151e110c..b901c1b45549276d12dbdac762428cb9bb13130a 100644 (file)
@@ -4549,6 +4549,24 @@ func_win32_import_lib_p ()
     esac
 }
 
+# func_suncc_cstd_abi
+# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
+# Several compiler flags select an ABI that is incompatible with the
+# Cstd library. Avoid specifying it if any are in CXXFLAGS.
+func_suncc_cstd_abi ()
+{
+    $debug_cmd
+
+    case " $compile_command " in
+    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
+      suncc_use_cstd_abi=no
+      ;;
+    *)
+      suncc_use_cstd_abi=yes
+      ;;
+    esac
+}
+
 # func_mode_link arg...
 func_mode_link ()
 {
@@ -6690,6 +6708,37 @@ func_mode_link ()
          eval $var=\"$tmp_libs\"
        done # for var
       fi
+
+      # Add Sun CC postdeps if required:
+      test CXX = "$tagname" && {
+        case $host_os in
+        linux*)
+          case `$CC -V 2>&1 | sed 5q` in
+          *Sun\ C*) # Sun C++ 5.9
+            func_suncc_cstd_abi
+
+            if test no != "$suncc_use_cstd_abi"; then
+              func_append postdeps ' -library=Cstd -library=Crun'
+            fi
+            ;;
+          esac
+          ;;
+
+        solaris*)
+          func_cc_basename "$CC"
+          case $func_cc_basename_result in
+          CC* | sunCC*)
+            func_suncc_cstd_abi
+
+            if test no != "$suncc_use_cstd_abi"; then
+              func_append postdeps ' -library=Cstd -library=Crun'
+            fi
+            ;;
+          esac
+          ;;
+        esac
+      }
+
       # Last step: remove runtime libs from dependency_libs
       # (they stay in deplibs)
       tmp_libs=
index 22a72849ebf76c14459092f0fd6b5cb8eb7bdae7..f8799880f7ff814b29c33e1807758da2124071db 100644 (file)
@@ -103,19 +103,36 @@ dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
 dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
 
 
+# _LT_PREPARE_CC_BASENAME
+# -----------------------
+m4_defun([_LT_PREPARE_CC_BASENAME], [
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+func_cc_basename ()
+{
+    for cc_temp in @S|@*""; do
+      case $cc_temp in
+        compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+        distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+        \-*) ;;
+        *) break;;
+      esac
+    done
+    func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+}
+])# _LT_PREPARE_CC_BASENAME
+
+
 # _LT_CC_BASENAME(CC)
 # -------------------
-# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME,
+# but that macro is also expanded into generated libtool script, which
+# arranges for $SED and $ECHO to be set by different means.
 m4_defun([_LT_CC_BASENAME],
-[for cc_temp in $1""; do
-  case $cc_temp in
-    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
-    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+[m4_require([_LT_PREPARE_CC_BASENAME])dnl
+AC_REQUIRE([_LT_DECL_SED])dnl
+AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
+func_cc_basename $1
+cc_basename=$func_cc_basename_result
 ])
 
 
@@ -736,6 +753,7 @@ _LT_EOF
 ## -------------------------------------- ##
 
 _LT_PREPARE_MUNGE_PATH_LIST
+_LT_PREPARE_CC_BASENAME
 
 _LT_EOF
 
@@ -7423,27 +7441,6 @@ func_stripname_cnf ()
 ])# _LT_FUNC_STRIPNAME_CNF
 
 
-# _LT_FUNC_SUNCC_CSTD_ABI
-# -----------------------
-# func_suncc_cstd_abi
-# Several compiler flags select an ABI that is
-# incompatible with the Cstd library. Avoid specifying
-# it if any are in CXXFLAGS.
-m4_defun([_LT_FUNC_SUNCC_CSTD_ABI], [[
-func_suncc_cstd_abi ()
-{
-    case " $CXX $CXXFLAGS " in
-    *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
-      suncc_use_cstd_abi=no
-      ;;
-    *)
-      suncc_use_cstd_abi=yes
-      ;;
-    esac
-} # func_suncc_cstd_abi
-]])# _LT_FUNC_SUNCC_CSTD_ABI
-
-
 # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
 # ---------------------------------
 # Figure out "hidden" library dependencies from verbose
@@ -7452,7 +7449,6 @@ func_suncc_cstd_abi ()
 # objects, libraries and library flags.
 m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
 [m4_require([_LT_FILEUTILS_DEFAULTS])dnl
-m4_require([_LT_FUNC_SUNCC_CSTD_ABI])dnl
 AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl
 # Dependencies to place before and after the object being linked:
 _LT_TAGVAR(predep_objects, $1)=
@@ -7623,30 +7619,6 @@ interix[[3-9]]*)
   _LT_TAGVAR(postdep_objects,$1)=
   _LT_TAGVAR(postdeps,$1)=
   ;;
-
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*) # Sun C++ 5.9
-    func_suncc_cstd_abi
-
-    if test no != "$suncc_use_cstd_abi"; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
-
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    func_suncc_cstd_abi
-
-    if test no != "$suncc_use_cstd_abi"; then
-      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
-    fi
-    ;;
-  esac
-  ;;
 esac
 ])