[mpich2-commits] r7413 - in mpich2/trunk: . maint src/util

gropp at mcs.anl.gov gropp at mcs.anl.gov
Thu Nov 4 10:19:03 CDT 2010


Author: gropp
Date: 2010-11-04 10:19:03 -0500 (Thu, 04 Nov 2010)
New Revision: 7413

Modified:
   mpich2/trunk/Makefile.sm
   mpich2/trunk/maint/simplemake.in
   mpich2/trunk/src/util/createshlib.in
Log:
Possible fixes for #1117, need to build shared library for C++ files with the C++ compiler rather than the C compiler

Modified: mpich2/trunk/Makefile.sm
===================================================================
--- mpich2/trunk/Makefile.sm	2010-11-04 13:13:05 UTC (rev 7412)
+++ mpich2/trunk/Makefile.sm	2010-11-04 15:19:03 UTC (rev 7413)
@@ -156,6 +156,7 @@
 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
 

Modified: mpich2/trunk/maint/simplemake.in
===================================================================
--- mpich2/trunk/maint/simplemake.in	2010-11-04 13:13:05 UTC (rev 7412)
+++ mpich2/trunk/maint/simplemake.in	2010-11-04 15:19:03 UTC (rev 7413)
@@ -194,6 +194,7 @@
 $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 @@
 	    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 @@
     $depadd_all = "";
     %altCompile = ();
     %altCompileSources = ();
+    %libLinker = ();
+    %installExtraArgs = ();
 
     $gSubdirSMVarsSeen = "";
 
@@ -3369,6 +3379,10 @@
     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 @@
 	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 @@
     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 @@
 	    $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 @@
 	    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 @@
 		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 @@
 	# 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;

Modified: mpich2/trunk/src/util/createshlib.in
===================================================================
--- mpich2/trunk/src/util/createshlib.in	2010-11-04 13:13:05 UTC (rev 7412)
+++ mpich2/trunk/src/util/createshlib.in	2010-11-04 15:19:03 UTC (rev 7413)
@@ -95,12 +95,12 @@
        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"
        ;;



More information about the mpich2-commits mailing list