Skip to content

Commit dc5adc5

Browse files
committed
configury: pass -Wl,-Wl,,--enable-new-dtags when NAG compiler is used for linking
Thanks Paul Hargrove for the report
1 parent 11b3bc9 commit dc5adc5

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

config/opal_setup_wrappers.m4

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ EOF
217217
# If DT_RUNPATH is supported, then we'll use *both* the RPATH and
218218
# RUNPATH flags in the LDFLAGS.
219219
AC_DEFUN([OPAL_SETUP_RUNPATH],[
220-
OPAL_VAR_SCOPE_PUSH([LDFLAGS_save])
220+
OPAL_VAR_SCOPE_PUSH([LDFLAGS_save rpath_script rpath_outfile wl_fc])
221221

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

236274
OPAL_VAR_SCOPE_POP
@@ -256,14 +294,14 @@ AC_DEFUN([RPATHIFY_LDFLAGS_INTERNAL],[
256294

257295
# Now add in the RPATH args for @{libdir}, and the RUNPATH args
258296
rpath_tmp=`echo ${$2} | sed -e s/LIBDIR/@{libdir}/`
259-
$1="${$1} $rpath_out $rpath_tmp $runpath_args"
297+
$1="${$1} $rpath_out $rpath_tmp ${$3}"
260298
])
261299
OPAL_VAR_SCOPE_POP
262300
])
263301

264-
AC_DEFUN([RPATHIFY_LDFLAGS],[RPATHIFY_LDFLAGS_INTERNAL([$1], [rpath_args])])
302+
AC_DEFUN([RPATHIFY_LDFLAGS],[RPATHIFY_LDFLAGS_INTERNAL([$1], [rpath_args], [runpath_args])])
265303

266-
AC_DEFUN([RPATHIFY_FC_LDFLAGS],[RPATHIFY_LDFLAGS_INTERNAL([$1], [rpath_fc_args])])
304+
AC_DEFUN([RPATHIFY_FC_LDFLAGS],[RPATHIFY_LDFLAGS_INTERNAL([$1], [rpath_fc_args], [runpath_fc_args])])
267305

268306

269307
dnl

0 commit comments

Comments
 (0)