Commit cb4904ec authored by Philip Carns's avatar Philip Carns

first step in support -cc in darshan-gen-cc.pl; detect the CC portion of the

command line and track it separately


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@497 3b7491f3-a168-0410-bf4b-c445ed680a29
parent b12850c2
......@@ -72,18 +72,42 @@ if ($trim_exe_path)
open (OUTPUT, ">$output_file") || die("Error opening output file: $!");
# substitute arguments and darshan options into commands
$base_link_cmd = $link_cmd;
$base_link_cmd =~ s/foo.o -o foo/"\$\{allargs\[\@\]\}"/g;
$link_cmd =~ s/foo.o -o foo/"\$\{newallargs\[\@\]\}" -L$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -ldarshan-mpi-io -lz $CP_WRAPPERS/g;
$link_cmd =~ s/$/ -L$DARSHAN_LIB_PATH -ldarshan-posix/g;
$compile_cmd =~ s/-c foo.c/"\$\{allargs\[\@\]\}"/g;
# split the link command from the original mpicc script so that we have the
# part before the "foo.o -o foo", which is assumed to be CC, and the part
# that comes afterwards, which is assumed to be the required link flags and
# libraries.
if(!($link_cmd =~ /(.+)\s+(foo.o -o foo)\s+(.*)/))
{
printf STDERR "Error: improperly formatted link cmd: $link_cmd\n";
exit(1);
}
$CC_from_link=$1;
$base_link_cmd_suffix="\"\$\{allargs\[\@\]\}\" $3";
$link_cmd_suffix="\"\$\{newallargs\[\@\]\}\" -L$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -ldarshan-mpi-io -lz $CP_WRAPPERS $3 -L$DARSHAN_LIB_PATH -ldarshan-posix";
# repeat the above step for the compilation command line
if(!($compile_cmd =~ /(.+)\s+(-c foo.c)\s+(.*)/))
{
printf STDERR "Error: improperly formatted compile cmd: $compile_cmd\n";
exit(1);
}
$CC_from_compile=$1;
$compile_cmd_suffix="\"\$\{allargs\[\@\]\}\" $3";
# we expect to see the same CC command in both the link and compile steps
if($CC_from_link ne $CC_from_compile)
{
printf STDERR "Error: cannot find matching CC from: $compile_cmd\n";
printf STDERR "and: $link_cmd\n";
exit(1);
}
$CC=$CC_from_compile;
# create link cmd with noshrargs variable
$link_cmd_no_shared = $base_link_cmd;
$link_cmd_no_shared =~ s/allargs/noshrargs/;
$link_cmd_no_shared_suffix = $base_link_cmd_suffix;
$link_cmd_no_shared_suffix =~ s/allargs/noshrargs/;
print OUTPUT<<'EOF';
print OUTPUT<<"EOF";
#!/bin/bash
#
# Auto-generated mpicc script from darshan-gen-cc.pl
......@@ -93,6 +117,7 @@ print OUTPUT<<'EOF';
# Show is set to echo to cause the compilation command to be echoed instead
# of executed.
Show=
CC="$CC"
EOF
if ($xl_check == 1)
......@@ -225,7 +250,7 @@ print OUTPUT<<"EOF";
fi
argno=`expr \$argno + 1`
done
$link_cmd_no_shared -Wl,-Map,\$tmpfile \$LDFLAGS -o /dev/null >& /dev/null
\$CC $link_cmd_no_shared_suffix -Wl,-Map,\$tmpfile \$LDFLAGS -o /dev/null >& /dev/null
# is MPI in there?
grep MPI \$tmpfile >& /dev/null
......@@ -241,18 +266,18 @@ print OUTPUT<<"EOF";
# 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 ]; then
\$Show $link_cmd
\$Show \$CC $link_cmd_suffix
used_darshan=1
fi
fi
# otherwise use the normal command line
if [ "\$used_darshan" = "0" ] ; then
\$Show $base_link_cmd
\$Show \$CC $base_link_cmd_suffix
fi
rc=\$?
else
\$Show $compile_cmd
\$Show \$CC $compile_cmd_suffix
rc=\$?
fi
......
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