Commit 56eb6698 authored by Sergey Kosukhin's avatar Sergey Kosukhin
Browse files

Update libtool patches.

parent 249e1fb6
......@@ -11,29 +11,38 @@ libtool_version=`libtool --version | awk 'NR==1 {print $4}'`
verlte $libtool_version 2.4.2 && {
# fix m4/libtool.m4 for nagfor sharedflag
# see https://trac.mpich.org/projects/mpich/ticket/1870 for details
patch --forward --no-backup-if-mismatch -p0 -s -l < maint/libtool.m4.patch
patch --forward --no-backup-if-mismatch -p0 -s -i maint/libtool.m4.patch
# The program 'patch' exits with exitcode=1 if the patch has already been applied.
# Consider this a normal scenario:
exitcode=$?; test $exitcode -ne 0 && test $exitcode -ne 1 && exit $exitcode
}
# Fix the problem when creating shared library with libtool and using MPI
# compiler wrapper. When LT_INIT is called before AX_PROG_FC_MPI in the
# configure.ac, the generated ./libtool doesn't know about the MPI
# compiler wrapper, which we do need since the logic of the script
# depends on the name of the compiler executable name (e.g. nagfor).
# But we also want to be able to link shared libraries using MPIFC.
# AX_PROG_FC_MPI sets FC=$MPIFC but ./libtool keeps using the hardcoded
# command that uses the actual compiler when creating a shared library.
# This patch instructs ./libtool to check whether $FC is set. If $FC
# is set ./libtool will use it for linking, and will act as usual otherwise.
# See also https://lists.gnu.org/archive/html/libtool/2012-05/msg00002.html
patch --forward --no-backup-if-mismatch -p0 -s -l < maint/libtool.m4.hardcoded.patch
# rebuild configure
# compiler wrapper:
patch --forward --no-backup-if-mismatch -p1 -s -l -i maint/libtool.m4.nag_wrapper.patch
exitcode=$?; test $exitcode -ne 0 && test $exitcode -ne 1 && exit $exitcode
# Fix the bug with spaces between flags and their arguments:
patch --forward --no-backup-if-mismatch -p1 -s -l -i maint/libtool.m4.arg_spaces.patch
exitcode=$?; test $exitcode -ne 0 && test $exitcode -ne 1 && exit $exitcode
# Rebuild configure:
autoconf -f || exit $?
# Reset libtool.m4 timestamps to avoid confusing make
touch -r m4/ltversion.m4 m4/libtool.m4
# Reset libtool.m4 timestamps to avoid confusing make:
touch -r m4/ltversion.m4 m4/libtool.m4 || exit $?
# Fix the bug related to '-pthread' in the list of inherited flags, which is not
# recognized by nagfor:
patch --forward --no-backup-if-mismatch -p1 -s -l -i maint/ltmain.sh.nag_pthread.patch
exitcode=$?; test $exitcode -ne 0 && test $exitcode -ne 1 && exit $exitcode
# Libtool might duplicate some of the compilation or linking flags (e.g. -fopenmp)
# when calling the actual compiler, which is considered and error by nagfor:
patch --forward --no-backup-if-mismatch -p1 -s -l -i maint/ltmain.sh.no_flag_duplication.patch
exitcode=$?; test $exitcode -ne 0 && test $exitcode -ne 1 && exit $exitcode
# Libtool duplicates some of the command line flags (e.g. -fopenmp)
# when calling the actual compiler. nagfor considers this as an error.
patch --forward --no-backup-if-mismatch -p0 -s -l < maint/ltmain.sh.patch
# All went fine since we have not exited before:
exit 0
......@@ -19,8 +19,6 @@ AM_INIT_AUTOMAKE([1.14 silent-rules no-dependencies])
AM_EXTRA_RECURSIVE_TARGETS([doc])
AC_CONFIG_SRCDIR([src/sct_reporter.c])
dnl LT_INIT must be called before AX_PROG_FC_MPI, otherwise
dnl it won't find out how to work with the underlying compiler.
LT_INIT([pic-only])
#
......
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -7532,10 +7532,11 @@ if AC_TRY_EVAL(ac_compile); then
case $prev$p in
-L* | -R* | -l*)
- # Some compilers place space between "-{L,R}" and the path.
+ # Some compilers place space between "-{L,R,l}" and the path (value).
# Remove the space.
- if test x-L = "$p" ||
- test x-R = "$p"; then
+ if test x-L = x"$p" ||
+ test x-R = x"$p" ||
+ test x-l = x"$p"; then
prev=$p
continue
fi
--- m4/libtool.m4 2018-07-19 16:29:39.928156909 +0200
+++ m4/libtool.m4.hardcoded.patched 2018-07-19 16:26:58.730540710 +0200
@@ -6048,6 +6048,9 @@
esac
fi
fi
+ m4_ifval([$1],
+ [_LT_TAGVAR(archive_cmds, $1)=`AS_ECHO(["$_LT_TAGVAR(archive_cmds, $1)"]) | sed 's%\(\\\\\)*$CC%\1${$1:-\1$CC}%g'`
+ _LT_TAGVAR(archive_expsym_cmds, $1)=`AS_ECHO(["$_LT_TAGVAR(archive_expsym_cmds, $1)"]) | sed 's%\(\\\\\)*$CC%\1${$1:-\1$CC}%g'`])
])
AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no
--- a/config/ltmain.sh
+++ b/config/ltmain.sh
@@ -8903,7 +8903,8 @@ func_mode_link ()
xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
# On Darwin other compilers
- case $CC in
+ func_cc_basename $CC
+ case $func_cc_basename_result in
nagfor*)
verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
;;
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -118,6 +118,12 @@ func_cc_basename ()
esac
done
func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+
+ # Set result to 'nagfor-wrapper' when NAG compiler is called via a wrapper (e.g. mpif90).
+ case $func_cc_basename_result in
+ nagfor*) ;;
+ *) $cc_temp -V 2>&1 | $GREP '^NAG Fortran Compiler Release' >/dev/null 2>&1 && func_cc_basename_result='nagfor-wrapper' ;;
+ esac
}
])# _LT_PREPARE_CC_BASENAME
--- a/config/ltmain.sh
+++ b/config/ltmain.sh
@@ -7862,6 +7862,13 @@ func_mode_link ()
# Convert "-framework foo" to "foo.ltframework"
if test -n "$inherited_linker_flags"; then
tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
+
+ # Additionally convert " -pthread" to " -Wl,-pthread" for nagfor
+ func_cc_basename $CC
+ case $func_cc_basename_result in
+ nagfor*) tmp_inherited_linker_flags=`$ECHO "$tmp_inherited_linker_flags" | $SED 's/ -pthread/ -Wl,-pthread/g'` ;;
+ esac
+
for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
case " $new_inherited_linker_flags " in
*" $tmp_inherited_linker_flag "*) ;;
@@ -9493,6 +9500,22 @@ EOF
;;
esac
+ # Time to revert the changes made for nagfor. This might be required if
+ # we need to make the output '*.la' file to be correctly interpreted for
+ # gcc (e.g. the output library that we are linking now with nagfor needs
+ # to be linked by gcc later). In this case, the libtool script of a
+ # package that will try to link our library will have to make similar
+ # non-standard nagfor-specific modifications of the '-pthread' flag.
+ # Thus, if we are creating a Fortran library for nagfor only, it is
+ # better not to revert the changes, otherwise, uncomment the following
+ # lines.
+
+ func_cc_basename $CC
+ case $func_cc_basename_result in
+ nagfor*)
+ new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% -Wl,-pthread% -pthread%g'` ;;
+ esac
+
# move library search paths that coincide with paths to not yet
# installed libraries to the beginning of the library search list
new_libs=
--- config/ltmain.sh 2018-07-18 09:43:57.970408086 +0200
+++ config/ltmain.sh.patched 2018-07-18 09:48:08.236884128 +0200
@@ -8539,11 +8539,33 @@
--- a/config/ltmain.sh
+++ b/config/ltmain.sh
@@ -8539,11 +8539,33 @@ func_mode_link ()
fi # linkmode = lib
done # for deplib in $libs
if test link = "$pass"; then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment