Patches for support of Cray's compiler

2014-11-20 Thread Eric Bavier
I'm sending two patches that are the beginnings of support for Cray's
compiler in libtool.  I believe this bit of porting will be sufficient
for most uses of libtool at this point, and is of course much better
than the current state.

The first patch is a trivial change to an assumption made in one of
the tests and can certainly be contested.

The second patch contains the heart of the port.  I'd be interested to
know if there are preferable methods for achieving the necessary
behavior, which is hopefully conveyed well enough in the commit
messages and code comments.

I was able to get roughly 166 of the 169 tests to pass.  Some of the
fortran tests required some patches that I am not posting here because
I do not think the solutions are general enough yet.

Comments and questions are certainly welcome.


___
https://lists.gnu.org/mailman/listinfo/libtool


[PATCH 1/2] tests: Do not assume compiler prefers shared libraries.

2014-11-20 Thread Eric Bavier
Testing whether -static-libtool-libs causes a non-libtool library to be
linked dynamically is effectively a test of the compiler's preference in
this case.  The Cray compiler prefers static libraries if not told
otherwise.

* tests/static.at [static linking flags for programs]: Do not expect
  -static-libtool-libs to fail.
---
 tests/static.at | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/static.at b/tests/static.at
index 19125de..5f4eace 100644
--- a/tests/static.at
+++ b/tests/static.at
@@ -344,7 +344,7 @@ for withdep in no yes; do
   echo "### test whether non-libtool library liba3 was linked statically"
   func_move_libs a3 $prefix3 $prefix1 $prefix2
   func_test_exec $all_static `$per_deplib && echo 3 13 23 31 123 123a`
-  func_test_exec_fail -static -static-libtool-libs `$per_deplib && echo 1 2 12`
+  func_test_exec_fail -static `$per_deplib && echo 1 2 12`
   func_restore_libs a3 $prefix3
 
   cd ..
-- 
2.0.0


___
https://lists.gnu.org/mailman/listinfo/libtool


[PATCH 2/2] libtool: preliminary support for the Cray compiler.

2014-11-20 Thread Eric Bavier
This patch adds preliminary support for the Cray Compiler
Environment (CCE) to libtool.  Main issues:

  - When linking a static executable, the value of the STRIP environment
variable must be an absolute file name.

  - Symbols will be stripped from shared libraries during creation if
the STRIP environment variable is set.

  - When linking against shared libraries, or dlopening a library, a
"-dynamic" option needs to be given to the compiler that it can make
sure that linked system libraries are shared libraries.
---
 build-aux/ltmain.in | 38 +++---
 m4/libtool.m4   | 48 +++-
 2 files changed, 82 insertions(+), 4 deletions(-)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index 85e2809..c6b532b 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -5134,7 +5134,7 @@ func_mode_link ()
;;
 
   -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
-  |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
+  |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*|-h*omp)
func_append compiler_flags " $arg"
func_append compile_command " $arg"
func_append finalize_command " $arg"
@@ -5665,7 +5665,7 @@ func_mode_link ()
found=false
case $deplib in
-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
-|-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
+|-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*|-h*omp)
  if test prog,link = "$linkmode,$pass"; then
compile_deplibs="$deplib $compile_deplibs"
finalize_deplibs="$deplib $finalize_deplibs"
@@ -6206,6 +6206,21 @@ func_mode_link ()
  esac
  # This is a shared library
 
+ # Cray's compiler drivers need a -dynamic flag if any linked
+ # library is a shared library.  Ensure it gets this flag.
+ case `$CC -V 2>&1 | sed 5q` in
+ *Cray*)
+ case " $compile_command " in
+ *" -dynamic ") ;;
+ *) func_append compile_command " -dynamic" ;;
+ esac
+ case " $finalize_command " in
+ *" -dynamic ") ;;
+ *) func_append finalize_command " -dynamic" ;;
+ esac
+ ;;
+ esac
+
  # Warn about portability, can't link against -module's on some
  # systems (darwin).  Don't bleat about dlopened modules though!
  dlopenmodule=
@@ -8246,7 +8261,24 @@ EOF
finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ 
$]*\).ltframework% -framework \1%g'`
;;
   esac
-
+  if test -n "$dlfiles" ||
+test "$dlself" = "yes" ||
+test "$export_dynamic" = "yes"; then
+   # Cray's compiler drivers need a -dynamic flag if the program
+   # is going to be dlopening itself or any libraries.
+   case `$CC -V 2>&1 | sed 5q` in
+   *Cray*)
+   case " $compile_command " in
+   *" -dynamic ") ;;
+   *) func_append compile_command " -dynamic" ;;
+   esac
+   case " $finalize_command " in
+   *" -dynamic ") ;;
+   *) func_append finalize_command " -dynamic" ;;
+   esac
+   ;;
+   esac
+  fi
 
   # move library search paths that coincide with paths to not yet
   # installed libraries to the beginning of the library search list
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 6143541..bda4b07 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -1499,7 +1499,9 @@ _LT_DECL([], [archiver_list_spec], [1],
 m4_defun([_LT_CMD_OLD_ARCHIVE],
 [_LT_PROG_AR
 
-AC_CHECK_TOOL(STRIP, strip, :)
+# Cray's compiler drivers need STRIP to be an absolute file name when
+# static linking.
+AC_PATH_TOOL(STRIP, strip, :)
 test -z "$STRIP" && STRIP=:
 _LT_DECL([], [STRIP], [1], [A symbol stripping program])
 
@@ -4262,6 +4264,12 @@ m4_if([$1], [CXX], [
  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
  ;;
+   *Cray\ C*)
+ # Cray C++ compiler
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-hpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ ;;
esac
;;
esac
@@ -4619,6 +4627,11 @@ m4_if([$1], [CXX], [
  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
  ;;
+   *Cray\ Fortran* | *Cray\ C*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-hpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
esac
;;
   esac
@@ -5098,6 +5111,14 @@ _LT_EOF
  fi