[Darshan-commits] [Git][darshan/darshan][carns/dev-dyn-link-updates] 2 commits: add no-as-needed, needed at least for cxx dyn link

Philip Carns xgitlab at cels.anl.gov
Fri Mar 20 11:40:07 CDT 2020



Philip Carns pushed to branch carns/dev-dyn-link-updates at darshan / darshan


Commits:
90d72e5e by Phil Carns at 2020-03-20T12:39:11-04:00
add no-as-needed, needed at least for cxx dyn link

- - - - -
5d642083 by Phil Carns at 2020-03-20T12:39:53-04:00
carry darshan-gen-cc changes to darshan-gen-cxx

- - - - -


2 changed files:

- darshan-runtime/darshan-config.in
- darshan-runtime/darshan-gen-cxx.pl.in


Changes:

=====================================
darshan-runtime/darshan-config.in
=====================================
@@ -16,8 +16,9 @@ POST_LD_FLAGS="-L$DARSHAN_LIB_PATH -Wl,--start-group -ldarshan -ldarshan-stubs -
 
 # NOTE:
 # - when dynamic linking there is no need for wrapping options, we simply
-#   need to get the darshan symbol definitions early enough in the link order.
-DYN_LD_FLAGS="-L$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -Wl,-rpath=$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -ldarshan"
+#   need to get the darshan symbol definitions early enough in the link
+#   order.  We also set no-as-needed for linkers that may not identify
+DYN_LD_FLAGS="-L$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -Wl,-rpath=$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -Wl,-no-as-needed -ldarshan"
 
 usage="\
 Usage: darshan-config [--pre-ld-flags] [--post-ld-flags] [--dyn-ld-flags]"


=====================================
darshan-runtime/darshan-gen-cxx.pl.in
=====================================
@@ -83,6 +83,7 @@ $CXX_from_link=$1;
 $link_cmd_prefix=$2;
 $base_link_cmd_suffix="\"\$\{allargs\[\@\]\}\" $4";
 $link_cmd_suffix="\"\$\{newallargs\[\@\]\}\" \$CXXMPICH `$PREFIX/bin/darshan-config --pre-ld-flags` $4 `$PREFIX/bin/darshan-config --post-ld-flags`";
+$dyn_link_cmd_suffix="\"\$\{newallargs\[\@\]\}\" \$CXXMPICH `$PREFIX/bin/darshan-config --dyn-ld-flags` $4";
 
 # repeat the above step for the compilation command line
 if(!($compile_cmd =~ /(\S+)(.+)(-c foo.c)\s+(.*)/))
@@ -198,15 +199,8 @@ if [ "$linking" = yes ] ; then
     fi
 EOF
 print OUTPUT<<"EOF";
-    # Trial run to generate a symbol listing.  We only enable Darshan if:
-    # a) MPI is used
-    # b) PMPI is _not_ used
-    #
-    # We want Darshan to get out of the way if the user is doing a runtime
-    # test in configure (in which case MPI objects break the executable) or
-    # if the user is using another PMPI based tool
-
-    # if allargs includes any libraries, then we need to get 
+
+    # if allargs includes any libraries, then we need to get
     # -ldarshan in there first
     argno=0;
     once=0;
@@ -244,6 +238,14 @@ print OUTPUT<<"EOF";
 
     used_darshan=0
 
+    # Perform a test link before the real link.  This allows us to check
+    # for two things:
+    # 1) Are MPI symbols present? Technically Darshan should not harm
+    #    non-MPI programs, but it may bring in unwanted dependencies or
+    #    interfere with autoconf checks.
+    # 2) Is this link command line going to produce a static or dynamic
+    #    linked executable?  We will adjust Darshan link strategy accordingly.
+
     # create a temporary file
     tmpfile=`mktemp`
     binfile=`mktemp`
@@ -263,9 +265,9 @@ print OUTPUT<<"EOF";
     grep MPI \$tmpfile >& /dev/null
     rc_mpi=\$?
 
-    # is PMPI being used for PMPI_File_open?
-    grep -E PMPI_File_open \$tmpfile | grep -v -E \\(mpich.*\\.a\\) |grep \\(PMPI >& /dev/null
-    rc_pmpi=\$?
+    # did the link options produce a dynamic executable?
+    ldd \$binfile >& /dev/null
+    rc_dyn=\$?
 
     CXXMPICH=-lmpichcxx
 
@@ -288,27 +290,17 @@ print OUTPUT<<"EOF";
     fi
 
     rm \$tmpfile >& /dev/null
-
-    # is MPI_Init a weak symbol?
-    # disable darshan if it is not
-    if [ -e \$binfile ];
-    then
-        nm \$binfile | grep -i "mpi_init" | grep -i "w" >& /dev/null
-        rc_weak=\$?
-    else
-        rc_weak=1
-    fi
     rm \$binfile >& /dev/null
 
-    # disable darshan if the executable is not an MPI program (this feature
-    # mainly allows runtime configure tests to work
-    if [ \$rc_mpi -eq 0 ] ; then
-        # disable darshan if something else is already using PMPI; we don't
-        # want to cause any symbol conflicts
-        if [ \$rc_pmpi -ne 0 ] && [ \$compiler_check -eq 0 ] && [ \$rc_weak -eq 0 ]; then
+    # disable darshan if the executable is not an MPI program or we've
+    # detected an incompatible compiler
+    if [ \$rc_mpi -eq 0 ] && [ \$compiler_check -eq 0 ]; then
+        if [ \$rc_dyn -eq 0 ]; then
+            \$Show \$CXX $link_cmd_prefix $dyn_link_cmd_suffix
+        else
             \$Show \$CXX $link_cmd_prefix $link_cmd_suffix
-            used_darshan=1
         fi
+        used_darshan=1
     fi
 
     # otherwise use the normal command line



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/fb87d7c66702d86e1a488267ebc92e5b05a73074...5d6420830e264204e62a0bdf62e3d535c8f970c3

-- 
View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/fb87d7c66702d86e1a488267ebc92e5b05a73074...5d6420830e264204e62a0bdf62e3d535c8f970c3
You're receiving this email because of your account on xgitlab.cels.anl.gov.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20200320/9cd03cfb/attachment-0001.html>


More information about the Darshan-commits mailing list