[Darshan-commits] [Git][darshan/darshan][carns/dev-dyn-link-updates] 2 commits: set rpath in dyn flags too

Philip Carns xgitlab at cels.anl.gov
Fri Mar 20 07:59:57 CDT 2020



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


Commits:
9b46f03e by Phil Carns at 2020-03-20T08:57:57-04:00
set rpath in dyn flags too

- - - - -
2fcecf5a by Phil Carns at 2020-03-20T08:58:34-04:00
modernize darshan-gen-cc and support dynamic link

- PMPI checks are no longer relevant
- weak symbol checks are no longer relevant
- if link command would produce a dynamically linked object, then switch
  to different link option to add darshan instrumentation

- - - - -


2 changed files:

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


Changes:

=====================================
darshan-runtime/darshan-config.in
=====================================
@@ -17,7 +17,7 @@ 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 -ldarshan"
+DYN_LD_FLAGS="-L$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -Wl,-rpath=$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -ldarshan"
 
 usage="\
 Usage: darshan-config [--pre-ld-flags] [--post-ld-flags] [--dyn-ld-flags]"


=====================================
darshan-runtime/darshan-gen-cc.pl.in
=====================================
@@ -83,6 +83,7 @@ $CC_from_link=$1;
 $link_cmd_prefix=$2;
 $base_link_cmd_suffix="\"\$\{allargs\[\@\]\}\" $4";
 $link_cmd_suffix="\"\$\{newallargs\[\@\]\}\" `$PREFIX/bin/darshan-config --pre-ld-flags` $4 `$PREFIX/bin/darshan-config --post-ld-flags`";
+$dyn_link_cmd_suffix="\"\$\{newallargs\[\@\]\}\" `$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,13 +199,6 @@ 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 
     # -ldarshan in there first
@@ -243,6 +237,11 @@ print OUTPUT<<"EOF";
 
     used_darshan=0
 
+    # Trial run to generate a symbol listing.  We only enable Darshan if MPI
+    # symbols are present. Technically Darshan should not harm
+    # non-MPI programs, but it may bring in unwanted dependencies or
+    # interfere with autoconf checks.
+
     # create a temporary file
     tmpfile=`mktemp`
     binfile=`mktemp`
@@ -261,31 +260,23 @@ print OUTPUT<<"EOF";
     # is MPI in there?
     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=\$?
-    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
+    # did the link options produce a dynamic executable?
+    ldd \$binfile >& /dev/null
+    rc_dyn=\$?
+
+    rm \$tmpfile >& /dev/null
     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
+    if [ \$rc_mpi -eq 0 ] && [ \$compiler_check -eq 0 ]; then
+        if [ \$rc_dyn -eq 0 ]; then
+            \$Show \$CC $link_cmd_prefix $dyn_link_cmd_suffix
+        else
             \$Show \$CC $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/6bab9ceac34c9104bbe9fddb90ba11d8bbd04947...2fcecf5a14882980465857b9779fb58d80bfe725

-- 
View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/6bab9ceac34c9104bbe9fddb90ba11d8bbd04947...2fcecf5a14882980465857b9779fb58d80bfe725
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/7c8f8066/attachment-0001.html>


More information about the Darshan-commits mailing list