Skip to content

Commit 3dc4094

Browse files
authored
Merge pull request #2092 from ggouaillardet/topic/v2.x/nag_configury
configury: improve NAG compiler support
2 parents 8eb60ac + 09554af commit 3dc4094

File tree

7 files changed

+134
-11
lines changed

7 files changed

+134
-11
lines changed

autogen.pl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,10 +918,15 @@ sub patch_autotools_output {
918918
# enough Libtool that dosn't need this patch. But don't alarm the
919919
# user and make them think that autogen failed if this patch fails --
920920
# make the errors be silent.
921+
# Also patch ltmain.sh for NAG compiler
921922
if (-f "config/ltmain.sh") {
922923
verbose "$indent_str"."Patching PGI compiler version numbers in ltmain.sh\n";
923924
system("$patch_prog -N -p0 < $topdir/config/ltmain_pgi_tp.diff >/dev/null 2>&1");
924925
unlink("config/ltmain.sh.rej");
926+
927+
verbose "$indent_str"."Patching \"-pthread\" option for NAG compiler in ltmain.sh\n";
928+
system("$patch_prog -N -p0 < $topdir/config/ltmain_nag_pthread.diff >/dev/null 2>&1");
929+
unlink("config/ltmain.sh.rej");
925930
}
926931

927932
# If there's no configure script, there's nothing else to do.
@@ -994,6 +999,25 @@ sub patch_autotools_output {
994999
$c =~ s/$search_string/$replace_string/;
9951000
}
9961001

1002+
foreach my $tag (("", "_FC")) {
1003+
1004+
# We have to change the search pattern and substitution on each
1005+
# iteration to take into account the tag changing
1006+
my $search_string = 'lf95\052.*# Lahey Fortran 8.1\n\s+' .
1007+
"whole_archive_flag_spec${tag}=" . '\n\s+' .
1008+
"tmp_sharedflag='--shared' ;;" . '\n\s+' .
1009+
'xl';
1010+
my $replace_string = "lf95*) # Lahey Fortran 8.1
1011+
whole_archive_flag_spec${tag}=
1012+
tmp_sharedflag='--shared' ;;
1013+
nagfor*) # NAGFOR 5.3
1014+
tmp_sharedflag='-Wl,-shared';;
1015+
xl";
1016+
1017+
push(@verbose_out, $indent_str . "Patching configure for NAG compiler ($tag)\n");
1018+
$c =~ s/$search_string/$replace_string/;
1019+
}
1020+
9971021
# Oracle has apparently begun (as of 12.5-beta) removing the "Sun" branding.
9981022
# So this patch (cumulative over the previous one) is required.
9991023
push(@verbose_out, $indent_str . "Patching configure for Oracle Studio Fortran version strings\n");

config/Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# Copyright (c) 2010 Oracle and/or its affiliates. All rights
1414
# reserved.
1515
# Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
16+
# Copyright (c) 2016 Research Organization for Information Science
17+
# and Technology (RIST). All rights reserved.
1618
# $COPYRIGHT$
1719
#
1820
# Additional copyrights may follow
@@ -23,6 +25,7 @@
2325
EXTRA_DIST = \
2426
distscript.sh \
2527
opal_get_version.m4sh \
28+
ltmain_nag_pthread.diff \
2629
ltmain_pgi_tp.diff \
2730
opal_mca_priority_sort.pl \
2831
find_common_syms

config/ltmain_nag_pthread.diff

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--- config/ltmain.sh
2+
+++ config/ltmain.sh
3+
@@ -6417,8 +6417,14 @@
4+
func_source "$lib"
5+
6+
# Convert "-framework foo" to "foo.ltframework"
7+
+ # and "-pthread" to "-Wl,-pthread" if NAG compiler
8+
if test -n "$inherited_linker_flags"; then
9+
- tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
10+
+ case "$CC" in
11+
+ nagfor*)
12+
+ tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g' | $SED 's/-pthread/-Wl,-pthread/g'`;;
13+
+ *)
14+
+ tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`;;
15+
+ esac
16+
for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
17+
case " $new_inherited_linker_flags " in
18+
*" $tmp_inherited_linker_flag "*) ;;

config/ompi_setup_fc.m4

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dnl Copyright (c) 2007 Los Alamos National Security, LLC. All rights
1414
dnl reserved.
1515
dnl Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
1616
dnl Copyright (c) 2009-2014 Cisco Systems, Inc. All rights reserved.
17-
dnl Copyright (c) 2015 Research Organization for Information Science
17+
dnl Copyright (c) 2015-2016 Research Organization for Information Science
1818
dnl and Technology (RIST). All rights reserved.
1919
dnl $COPYRIGHT$
2020
dnl
@@ -43,7 +43,7 @@ AC_DEFUN_ONCE([_OMPI_SETUP_FC_COMPILER],[
4343
# Fortran compilers (excluding the f77 compiler names) from AC's
4444
# default list of compilers and use it here. This is the main
4545
# reason we have an OMPI-ized version of the PROG_FC macro.
46-
AC_PROG_FC([gfortran f95 fort xlf95 ifort ifc efc pgfortran pgf95 lf95 f90 xlf90 pgf90 epcf90])
46+
AC_PROG_FC([gfortran f95 fort xlf95 ifort ifc efc pgfortran pgf95 lf95 f90 xlf90 pgf90 epcf90 nagfor])
4747
FCFLAGS="$ompi_fcflags_save"
4848
OPAL_VAR_SCOPE_POP
4949
])
@@ -114,13 +114,19 @@ AC_DEFUN([OMPI_SETUP_FC],[
114114
# "ignore TKR" comment pragmas that it doesn't understand, and
115115
# will warn about them. From Tony Goetz at Absoft, we can use the
116116
# -Z790 flag to quell these warnings.
117+
# The NAG compiler is too picky about naming conventions, so use the
118+
# -mismatch flag to keep it happy
117119
AC_MSG_CHECKING([for $FC warnings flags])
118120
fc_version=`$FC --version 2>&1`
119121
case "$fc_version" in
120122
*Absoft*)
121123
AC_MSG_RESULT([-Z790])
122124
FCFLAGS="$FCFLAGS -Z790"
123125
;;
126+
*NAG*)
127+
AC_MSG_RESULT([-mismatch])
128+
FCFLAGS="$FCFLAGS -mismatch"
129+
;;
124130
*)
125131
AC_MSG_RESULT([none])
126132
;;

config/opal_setup_wrappers.m4

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dnl Copyright (c) 2004-2005 The Regents of the University of California.
1212
dnl All rights reserved.
1313
dnl Copyright (c) 2006-2010 Oracle and/or its affiliates. All rights reserved.
1414
dnl Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
15-
dnl Copyright (c) 2015 Research Organization for Information Science
15+
dnl Copyright (c) 2015-2016 Research Organization for Information Science
1616
dnl and Technology (RIST). All rights reserved.
1717
dnl Copyright (c) 2016 IBM Corporation. All rights reserved.
1818
dnl $COPYRIGHT$
@@ -173,7 +173,33 @@ EOF
173173

174174
AS_IF([test -n "$rpath_args"],
175175
[WRAPPER_RPATH_SUPPORT=rpath
176-
AC_MSG_RESULT([yes ($rpath_args)])],
176+
cat > $rpath_script <<EOF
177+
#!/bin/sh
178+
179+
# Slurp in the libtool config into my environment
180+
181+
# Apparently, "libtoool --config" calls "exit", so we can't source it
182+
# (because if script A sources script B, and B calls "exit", then both
183+
# B and A will exit). Instead, we have to send the output to a file
184+
# and then source that.
185+
$OPAL_TOP_BUILDDIR/libtool --tag=FC --config > $rpath_outfile
186+
187+
chmod +x $rpath_outfile
188+
. ./$rpath_outfile
189+
rm -f $rpath_outfile
190+
191+
# Evaluate \$hardcode_libdir_flag_spec, and substitute in LIBDIR for \$libdir
192+
libdir=LIBDIR
193+
flags="\`eval echo \$hardcode_libdir_flag_spec\`"
194+
echo \$flags
195+
196+
# Done
197+
exit 0
198+
EOF
199+
chmod +x $rpath_script
200+
rpath_fc_args=`./$rpath_script`
201+
rm -f $rpath_script
202+
AC_MSG_RESULT([yes ($rpath_args + $rpath_fc_args)])],
177203
[WRAPPER_RPATH_SUPPORT=unnecessary
178204
AC_MSG_RESULT([yes (no extra flags needed)])])
179205

@@ -192,7 +218,7 @@ EOF
192218
# If DT_RUNPATH is supported, then we'll use *both* the RPATH and
193219
# RUNPATH flags in the LDFLAGS.
194220
AC_DEFUN([OPAL_SETUP_RUNPATH],[
195-
OPAL_VAR_SCOPE_PUSH([LDFLAGS_save])
221+
OPAL_VAR_SCOPE_PUSH([LDFLAGS_save rpath_script rpath_outfile wl_fc])
196222

197223
AC_MSG_CHECKING([if linker supports RUNPATH])
198224
# Set the output in $runpath_args
@@ -206,6 +232,45 @@ AC_DEFUN([OPAL_SETUP_RUNPATH],[
206232
AC_MSG_RESULT([yes (-Wl,--enable-new-dtags)])],
207233
[AC_MSG_RESULT([no])])
208234
AC_LANG_POP([C])
235+
m4_ifdef([project_ompi],[
236+
# Output goes into globally-visible $rpath_args. Run this in a
237+
# sub-process so that we don't pollute the current process
238+
# environment.
239+
rpath_script=conftest.$$.sh
240+
rpath_outfile=conftest.$$.out
241+
rm -f $rpath_script $rpath_outfile
242+
cat > $rpath_script <<EOF
243+
#!/bin/sh
244+
245+
# Slurp in the libtool config into my environment
246+
247+
# Apparently, "libtoool --config" calls "exit", so we can't source it
248+
# (because if script A sources script B, and B calls "exit", then both
249+
# B and A will exit). Instead, we have to send the output to a file
250+
# and then source that.
251+
$OPAL_TOP_BUILDDIR/libtool --tag=FC--config > $rpath_outfile
252+
253+
chmod +x $rpath_outfile
254+
. ./$rpath_outfile
255+
rm -f $rpath_outfile
256+
257+
wl="\`eval echo \$wl\`"
258+
echo \$wl
259+
260+
# Done
261+
exit 0
262+
EOF
263+
chmod +x $rpath_script
264+
wl_fc=`./$rpath_script`
265+
rm -f $rpath_script
266+
267+
LDFLAGS="$LDFLAGS_save ${wl_fc}--enable-new-dtags"
268+
AC_LANG_PUSH([Fortran])
269+
AC_LINK_IFELSE([AC_LANG_SOURCE([[program test
270+
end program]])],
271+
[runpath_fc_args="${wl_fc}--enable-new-dtags"],
272+
[runpath_fc_args=""])
273+
AC_LANG_POP([Fortran])])
209274
LDFLAGS=$LDFLAGS_save
210275

211276
OPAL_VAR_SCOPE_POP
@@ -215,27 +280,30 @@ AC_DEFUN([OPAL_SETUP_RUNPATH],[
215280
# for each of them. Then also add in an RPATH for @{libdir} (which
216281
# will be replaced by the wrapper compile to the installdir libdir at
217282
# runtime), and the RUNPATH args, if we have them.
218-
AC_DEFUN([RPATHIFY_LDFLAGS],[
283+
AC_DEFUN([RPATHIFY_LDFLAGS_INTERNAL],[
219284
OPAL_VAR_SCOPE_PUSH([rpath_out rpath_dir rpath_tmp])
220285
AS_IF([test "$enable_wrapper_rpath" = "yes" && test "$WRAPPER_RPATH_SUPPORT" != "disabled" && test "$WRAPPER_RPATH_SUPPORT" != "unnecessary"], [
221286
rpath_out=""
222287
for val in ${$1}; do
223288
case $val in
224289
-L*)
225290
rpath_dir=`echo $val | cut -c3-`
226-
rpath_tmp=`echo $rpath_args | sed -e s@LIBDIR@$rpath_dir@`
291+
rpath_tmp=`echo ${$2} | sed -e s@LIBDIR@$rpath_dir@`
227292
rpath_out="$rpath_out $rpath_tmp"
228293
;;
229294
esac
230295
done
231296

232297
# Now add in the RPATH args for @{libdir}, and the RUNPATH args
233-
rpath_tmp=`echo $rpath_args | sed -e s/LIBDIR/@{libdir}/`
234-
$1="${$1} $rpath_out $rpath_tmp $runpath_args"
298+
rpath_tmp=`echo ${$2} | sed -e s/LIBDIR/@{libdir}/`
299+
$1="${$1} $rpath_out $rpath_tmp ${$3}"
235300
])
236301
OPAL_VAR_SCOPE_POP
237302
])
238303

304+
AC_DEFUN([RPATHIFY_LDFLAGS],[RPATHIFY_LDFLAGS_INTERNAL([$1], [rpath_args], [runpath_args])])
305+
306+
AC_DEFUN([RPATHIFY_FC_LDFLAGS],[RPATHIFY_LDFLAGS_INTERNAL([$1], [rpath_fc_args], [runpath_fc_args])])
239307

240308
dnl
241309
dnl Avoid some repetitive code below
@@ -410,9 +478,12 @@ AC_DEFUN([OPAL_SETUP_WRAPPER_FINAL],[
410478

411479
AC_MSG_CHECKING([for OMPI LDFLAGS])
412480
OMPI_WRAPPER_EXTRA_LDFLAGS="$ompi_mca_wrapper_extra_ldflags $wrapper_extra_ldflags $with_wrapper_ldflags"
481+
OMPI_WRAPPER_EXTRA_FC_LDFLAGS=$OMPI_WRAPPER_EXTRA_LDFLAGS
413482
RPATHIFY_LDFLAGS([OMPI_WRAPPER_EXTRA_LDFLAGS])
414483
AC_SUBST([OMPI_WRAPPER_EXTRA_LDFLAGS])
415484
AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_LDFLAGS])
485+
RPATHIFY_FC_LDFLAGS([OMPI_WRAPPER_EXTRA_FC_LDFLAGS])
486+
AC_SUBST([OMPI_WRAPPER_EXTRA_FC_LDFLAGS])
416487

417488
# Convert @{libdir} to ${libdir} for pkg-config
418489
_OPAL_SETUP_WRAPPER_FINAL_PKGCONFIG([OMPI])
@@ -421,6 +492,7 @@ AC_DEFUN([OPAL_SETUP_WRAPPER_FINAL],[
421492
OMPI_WRAPPER_EXTRA_LIBS="$ompi_mca_wrapper_extra_libs"
422493
OPAL_FLAGS_APPEND_UNIQ([OMPI_WRAPPER_EXTRA_LIBS], [$wrapper_extra_libs])
423494
OMPI_WRAPPER_EXTRA_LIBS="$OMPI_WRAPPER_EXTRA_LIBS $with_wrapper_libs"
495+
OPAL_FLAGS_APPEND_UNIQ([OMPI_WRAPPER_EXTRA_LIBS], [$LIBS])
424496
AC_SUBST([OMPI_WRAPPER_EXTRA_LIBS])
425497
AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_LIBS])
426498

ompi/tools/wrappers/mpifort-wrapper-data.txt.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ compiler_flags_env=FCFLAGS
1414
compiler=@FC@
1515
preprocessor_flags=
1616
compiler_flags=@OMPI_WRAPPER_EXTRA_FCFLAGS@
17-
linker_flags=@OMPI_WRAPPER_EXTRA_LDFLAGS@
17+
linker_flags=@OMPI_WRAPPER_EXTRA_FC_LDFLAGS@
1818
# Note that per https://svn.open-mpi.org/trac/ompi/ticket/3422, we
1919
# intentionally only link in the MPI libraries (ORTE, OPAL, etc. are
2020
# pulled in implicitly) because we intend MPI applications to only use

oshmem/tools/wrappers/shmemfort-wrapper-data.txt.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ compiler_flags_env=FCFLAGS
2424
compiler=@FC@
2525
preprocessor_flags=
2626
compiler_flags=@OMPI_WRAPPER_EXTRA_FCFLAGS@
27-
linker_flags=@OMPI_WRAPPER_EXTRA_LDFLAGS@
27+
linker_flags=@OMPI_WRAPPER_EXTRA_FC_LDFLAGS@
2828
# Note that per https://svn.open-mpi.org/trac/ompi/ticket/3422, we
2929
# intentionally only link in the SHMEM and MPI libraries (ORTE, OPAL,
3030
# etc. are pulled in implicitly) because we intend SHMEM/MPI

0 commit comments

Comments
 (0)