Commit 328be2c4 authored by William Gropp's avatar William Gropp
Browse files

[svn-r7413] Possible fixes for #1117, need to build shared library for C++...

[svn-r7413] Possible fixes for #1117, need to build shared library for C++ files with the C++ compiler rather than the C compiler
parent 0871d44f
......@@ -156,6 +156,7 @@ lib${MPILIBNAME}_so_LIBS = -L. @LDFLAGS_DEPS@ @LIB_DEPS@
libf${MPILIBNAME}_so_LIBS = -L. @LDFLAGS_DEPS@ -l$(MPILIBNAME) @LIB_DEPS@
lib${MPILIBNAME}f90_so_LIBS = -L. @LDFLAGS_DEPS@ -l$(MPILIBNAME) @LIB_DEPS@
lib${MPICXXLIBNAME}_so_LIBS = -L. @LDFLAGS_DEPS@ -l$(MPILIBNAME) @LIB_DEPS@
lib${MPICXXLIBNAME}_so_LINKER = @CXX_SHL@
install_INCLUDE = src/include/mpi.h
......
......@@ -194,6 +194,7 @@ if (defined($ENV{"DEBUG_SUBDIRVAR"})) { $gDebugSubdirVar = 1; }
$quiet = 0;
%libdir = ();
%liblinker = ();
#
# While simplemake doesn't support ext->other (e.g., .c to .s),
# the rules have been added.
......@@ -849,6 +850,13 @@ sub ReadMfile {
print "Setting libdir{$1} to $2/\n" if $debug;
$libdir{$1} = "$2/";
}
elsif (/^lib([@\${}\(\)\w-]*)_so_LINKER\s*=\s*(\S+)\s*$/) {
$libLinker{$1} = $2;
# This selects a specific format for specifing the linker
# when installing the shared library
print "setting installExtraArgs $1 to --clink=$2\n" if $debug;
$installExtraArgs{$1} = "--clink=\"$2\"";
}
elsif (/^install_local_DIR\s*=\s*(.*)\s*$/) {
$install_local_dirs = $1;
}
......@@ -1942,6 +1950,8 @@ sub ClearVars {
$depadd_all = "";
%altCompile = ();
%altCompileSources = ();
%libLinker = ();
%installExtraArgs = ();
$gSubdirSMVarsSeen = "";
......@@ -3369,6 +3379,10 @@ sub TargetSharedLibraryFinal {
my $newlibname = $_[1];
my $libdir = $_[2];
# Some shared libraries may need to be built with a compiler other than
# the C compiler. This will let us define that.
my $linkerOption = "";
my $libbasename = $libname;
$libbasename =~ s/^lib//;
$libbasename =~ s/\.la$//;
......@@ -3379,9 +3393,14 @@ sub TargetSharedLibraryFinal {
return;
}
# If the linker should not be the C compiler, this selects it
if (defined($libLinker{$libbasename})) {
$linkerOption = "--clink=\"" . $libLinker{$libbasename} . "\"";
}
if ($libdir eq "" || $newlibname eq "" || $libname eq "") {
# If we don't have these names, we cannot create a valid library
print STDOUT "Unable to create shared libary target (no directory\n\
print STDOUT "Unable to create shared library target (no directory\n\
library, or new library name)\n" if $debug;
return;
}
......@@ -3409,7 +3428,7 @@ library, or new library name)\n" if $debug;
if (!defined($usertargets{"$libdir/$newlibname"})) {
print FD "# Build the shared library from the shared object files\n";
print FD "$libdir/$newlibname: $libdir/$libname
\t(cd $libdir && \$(CREATESHLIB) --mode=link -version-info \"\$(ABIVERSION)\" -o $libname $exports -rpath \$(libdir) $otherlibs -ldflags \"\$(LDFLAGS)\" \$(LIBS))\n";
\t(cd $libdir && \$(CREATESHLIB) --mode=link $linkerOption -version-info \"\$(ABIVERSION)\" -o $libname $exports -rpath \$(libdir) $otherlibs -ldflags \"\$(LDFLAGS)\" \$(LIBS))\n";
}
# If there is a profiling library, we need to build it
# now, as part of this target, to handle the case where the
......@@ -3445,7 +3464,7 @@ library, or new library name)\n" if $debug;
$otherlibs = $shared_libraries_libs{$libbasename};
}
print FD "\t(cd $libdir && \$(CREATESHLIB) --mode=link -version-info \"\$(ABIVERSION)\" -o $libname $exports -rpath \$(libdir) $otherlibs);\\\n";
print FD "\t(cd $libdir && \$(CREATESHLIB) --mode=link $linkerOption -version-info \"\$(ABIVERSION)\" -o $libname $exports -rpath \$(libdir) $otherlibs);\\\n";
print FD "\tfi\n";
}
......@@ -3967,7 +3986,22 @@ sub TargetInstall {
if ($this_install_method eq "") {
$this_install_method = '$(INSTALL)';
}
print FD "\t$this_install_method $file \${DESTDIR}\${$dir}/$destfile$newline";
$extraArgs = "";
#print STDOUT "DEBUG: file = $file\n";
if (defined($installExtraArgs{$file})) {
$extraArgs = $installExtraArgs{$file};
}
if ($kind eq "SHLIB" && $extraArgs eq "") {
# This is a hack
$basefile = $file;
$basefile =~ s/^.*\/lib//;
$basefile =~ s/\.[^\.]*$//;
#print STDOUT "DEBUG: basefile = $basefile\n";
if (defined($installExtraArgs{$basefile})) {
$extraArgs = $installExtraArgs{$basefile};
}
}
print FD "\t$this_install_method $extraArgs $file \${DESTDIR}\${$dir}/$destfile$newline";
}
}
......@@ -4043,7 +4077,22 @@ sub TargetInstall {
else {
$this_install_choice = $install_methods{$kind};
}
print FD "\tif [ -s $file ] ; then $this_install_choice $file \${DESTDIR}\${$dir}/$destfile ; fi$newline";
$extraArgs = "";
#print STDOUT "DEBUG: file = $file\n";
if (defined($installExtraArgs{$file})) {
$extraArgs = $installExtraArgs{$file};
}
if ($kind eq "SHLIB" && $extraArgs eq "") {
# This is a hack
$basefile = $file;
$basefile =~ s/^.*\/lib//;
$basefile =~ s/\.[^\.]*$//;
#print STDOUT "DEBUG: basefile = $basefile\n";
if (defined($installExtraArgs{$basefile})) {
$extraArgs = $installExtraArgs{$basefile};
}
}
print FD "\tif [ -s $file ] ; then $this_install_choice $extraArgs $file \${DESTDIR}\${$dir}/$destfile ; fi$newline";
}
}
}
......@@ -4424,12 +4473,12 @@ in the build directory\n";
# We always use a "newalldeps" incase there is a failure
# creating the new list of dependency files.
print FD "\trm -f \$(DEPS_DIR)/newalldeps$newline";
my %sawFile = ();
%sawFile = ();
foreach $lib (keys(%libraries)) {
foreach $sourcefile (split(/\s+/,&ExpandMakeVars($libraries{$lib}))) {
if (defined($sawFile{$sourcefile})) { next; }
$sawFile{$sourcefile} = 1;
my $srcdirloc = '$(srcdir)/';
$srcdirloc = '$(srcdir)/';
$ext = $sourcefile;
$ext =~ s/^.*\.//g;
$sourcebasename = $sourcefile;
......
......@@ -95,12 +95,12 @@ for arg in "$@" ; do
nextarg=$arg
;;
-echo) set -x ;;
-dryrun) Show=echo ;;
-dryrun|--dryrun) Show=echo ;;
# -cc and -clink allow us to override the commands used to
# build the shared library
-cc=*) CC_SHL=$option ;;
-clink=*) C_LINK_SHL=$option ;;
-libtype=*) libtype=$option ;;
-cc=*|--cc=*) CC_SHL=$option ;;
-clink=*|--clink=*) C_LINK_SHL=$option ;;
-libtype=*|--libtype=*) libtype=$option ;;
-l*|-L*)
dependentLibs="$dependentLibs $arg"
;;
......
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