1
1

On a day brain-fried from other heavy-duty bug chasing, and while

waiting for a few other things to stabalize in teh tree, tackle one of
my other small to-do items that might as well get done.  
- put doxygen docs in .h file
- re-indent to 4 space tabs, as per team guidelines
- clean up the code and use the notation xflags and xppflags to denote
  that they're for any compiler
- add something that LAM users have been asking about for quite a
  while -- environment variable overrides for just about everything

This commit was SVN r2859.
Этот коммит содержится в:
Jeff Squyres 2004-09-25 19:31:17 +00:00
родитель c3c63b57c4
Коммит cbefdfe013
9 изменённых файлов: 774 добавлений и 708 удалений

Просмотреть файл

@ -1,11 +1,9 @@
# -*- makefile -*-
#
# $HEADER$
#
include $(top_srcdir)/config/Makefile.options
libs = $(top_builddir)/src/libmpi.la
# This is ugly, but we need it so that people can change things at
# "make" time (e.g., "make sysconfdir=/foo/bar all") as documented in
# autoconf.
@ -15,76 +13,43 @@ AM_CPPFLAGS = \
-DOMPI_INCDIR="\"$(includedir)\"" \
-DOMPI_LIBDIR="\"$(libdir)\""
EXTRA_DIST = wrap.cc wrap_engine.cc $(pkgdata_DATA)
pkgdata_DATA = help-wrapper.txt
bin_PROGRAMS = mpicc mpic++ mpif77 mpif90
# We unfortunately can't make a library for the common sources because
# making a library of C++ sources is not standardized. :-( We also
# can't just list the same .cc files in multiple targets, because some
# C++ compilers will actually compile them multiple times (i.e., once
# for each target). This results in a timestamp for wrap.o being
# later than already-finished targets (e.g., when wrap.o may end up
# with a timestamp before mpif77, but after mpicc). So we have to sym
# link the common sources to unique names for each wrapper compiler
# and let them effectively be compiled once for each wrapper.
noinst_LIBRARIES = libompi_wrap.a
EXTRA_DIST = wrap.cc wrap_engine.cc
libs = $(noinst_LIBRARIES) $(top_builddir)/src/libmpi.la
mpicc_SOURCES = mpicc.cc wrap_cc.cc wrap_engine_cc.cc ompi_wrap.h
libompi_wrap_a_SOURCES = wrap.cc wrap_engine.cc ompi_wrap.h
mpicc_SOURCES = mpicc.cc ompi_wrap.h
mpicc_LDADD = $(libs) $(LIBOMPI_EXTRA_LIBS)
mpicc_LDFLAGS = $(LIBOMPI_EXTRA_LDFLAGS)
mpicc_DEPENDENCIES = $(libs)
mpic___SOURCES = mpicxx.cc wrap_cxx.cc wrap_engine_cxx.cc ompi_wrap.h
mpic___SOURCES = mpicxx.cc ompi_wrap.h
mpic___LDADD = $(libs) $(LIBOMPI_EXTRA_LIBS)
mpic___LDFLAGS = $(LIBOMPI_EXTRA_LDFLAGS)
mpic___DEPENDENCIES = $(libs)
mpif77_SOURCES = mpif77.cc wrap_f77.cc wrap_engine_f77.cc ompi_wrap.h
mpif77_SOURCES = mpif77.cc ompi_wrap.h
mpif77_LDADD = $(libs) $(LIBOMPI_EXTRA_LIBS)
mpif77_LDFLAGS = $(LIBOMPI_EXTRA_LDFLAGS)
mpif77_DEPENDENCIES = $(libs)
mpif90_SOURCES = mpif90.cc wrap_f90.cc wrap_engine_f90.cc ompi_wrap.h
mpif90_SOURCES = mpif90.cc ompi_wrap.h
mpif90_LDADD = $(libs) $(LIBOMPI_EXTRA_LIBS)
mpif90_LDFLAGS = $(LIBOMPI_EXTRA_LDFLAGS)
mpif90_DEPENDENCIES = $(libs)
# Make the sym links
wrap_cc.cc:
ln -s $(top_srcdir)/src/tools/wrappers/wrap.cc wrap_cc.cc
wrap_engine_cc.cc:
ln -s $(top_srcdir)/src/tools/wrappers/wrap_engine.cc wrap_engine_cc.cc
wrap_cxx.cc:
ln -s $(top_srcdir)/src/tools/wrappers/wrap.cc wrap_cxx.cc
wrap_engine_cxx.cc:
ln -s $(top_srcdir)/src/tools/wrappers/wrap_engine.cc wrap_engine_cxx.cc
wrap_f77.cc:
ln -s $(top_srcdir)/src/tools/wrappers/wrap.cc wrap_f77.cc
wrap_engine_f77.cc:
ln -s $(top_srcdir)/src/tools/wrappers/wrap_engine.cc wrap_engine_f77.cc
wrap_f90.cc:
ln -s $(top_srcdir)/src/tools/wrappers/wrap.cc wrap_f90.cc
wrap_engine_f90.cc:
ln -s $(top_srcdir)/src/tools/wrappers/wrap_engine.cc wrap_engine_f90.cc
# Since this is C++ and we use templates (the STL), also ditch the
# template repository directory
clean-local:
test -z "$(OMPI_CXX_TEMPLATE_REPOSITORY)" || $(RM) -rf $(OMPI_CXX_TEMPLATE_REPOSITORY)
rm -f wrap_cc.cc wrap_engine_cc.cc
rm -f wrap_cxx.cc wrap_engine_cxx.cc
rm -f wrap_f77.cc wrap_engine_f77.cc
rm -f wrap_f90.cc wrap_engine_f90.cc
# Per bug 476, the "wipe" command is now "ompi_wipe". So that we don't
# break backwards compatability, we provide sym link names to the old
# names (i.e., ompi_wipe -> wipe). However, we provide a
# --disable-deprecated-executable-names option that will disable this
# behavior. Someday, we'll change the default and the option will
# become --enable-deprecated-executable-names.
if WANT_DEPRECATED_EXECUTABLE_NAMES
if CASE_SENSITIVE_FS

20
src/tools/wrappers/help-wrapper.txt Обычный файл
Просмотреть файл

@ -0,0 +1,20 @@
# -*- text -*-
#
# $HEADER$
#
# This is the US/English help file for Open MPI wrapper compiler error
# messages.
#
[no-fortran-support]
Unfortunately, this installation of Open MPI was not compiled with
Fortran %d support. As such, the %s compiler is non-functional.
[no-profilig-support]
warning: "-lpmpi" was included on the command line indicating use of MPI
warning: profiling layer. However, Open MPI was not compiled with support
warning: for the MPI profiling layer; this flag has been ignored.
[no-compiler-found]
The Open MPI wrapper compiler was unable to find the specified compiler
%s in your PATH.
Note that this compiler was either specified at configure time or in
one of several possible environment variables.

Просмотреть файл

@ -1,6 +1,5 @@
//
// $HEADER$
// Function: - wrapper for C program compilation
//
#include "ompi_config.h"
@ -12,17 +11,36 @@ main(int argc, char *argv[])
{
// The four wrapper compilers are extremely similar. So similar,
// in fact, that they can be parameterized on what is different.
// Hence, we call the "wrapper compiler engine" to do all the work,
// and pass in just a few arguments to customize for the language of
// this wrapper compiler.
// Hence, we call the "wrapper compiler engine" to do all the
// work, and pass in just a few arguments to customize for the
// language of this wrapper compiler.
ompi_sv_t str_vec;
ompi_sv_t compiler;
ompi_sv_t cppflags;
ompi_sv_t cflags;
ompi_sv_t ldflags;
ompi_sv_t libs;
str_vec.clear();
str_vec.push_back("OMPI_MPICC");
str_vec.push_back("OMPI_CC");
compiler.clear();
compiler.push_back("OMPI_MPICC");
return ompi_wrap_engine(argc, argv,
str_vec, OMPI_CC, false, false,
WRAPPER_EXTRA_CFLAGS);
cppflags.clear();
cppflags.push_back("OMPI_MPICC_CPPFLAGS");
cppflags.push_back("OMPI_CPPFLAGS");
cflags.clear();
cflags.push_back("OMPI_MPICC_CFLAGS");
cflags.push_back("OMPI_CFLAGS");
ldflags.clear();
ldflags.push_back("OMPI_MPICC_LDFLAGS");
ldflags.push_back("OMPI_LDFLAGS");
libs.clear();
libs.push_back("OMPI_MPICC_LIBS");
libs.push_back("OMPI_LIBS");
return ompi_wrap_engine(argc, argv, compiler, cppflags, cflags,
ldflags, libs, OMPI_CC, WRAPPER_EXTRA_CFLAGS,
false, false);
}

Просмотреть файл

@ -1,6 +1,5 @@
//
// $HEADER$
// Function: - wrapper for C++ program compilation
//
#include "ompi_config.h"
@ -12,17 +11,36 @@ main(int argc, char *argv[])
{
// The four wrapper compilers are extremely similar. So similar,
// in fact, that they can be parameterized on what is different.
// Hence, we call the "wrapper compiler engine" to do all the work,
// and pass in just a few arguments to customize for the language of
// this wrapper compiler.
// Hence, we call the "wrapper compiler engine" to do all the
// work, and pass in just a few arguments to customize for the
// language of this wrapper compiler.
ompi_sv_t str_vec;
ompi_sv_t compiler;
ompi_sv_t cxxcppflags;
ompi_sv_t cxxflags;
ompi_sv_t ldflags;
ompi_sv_t libs;
str_vec.clear();
str_vec.push_back("OMPI_MPICXX");
str_vec.push_back("OMPI_CXX");
compiler.clear();
compiler.push_back("OMPI_MPICXX");
return ompi_wrap_engine(argc, argv,
str_vec, OMPI_CXX,true, false,
WRAPPER_EXTRA_CXXFLAGS);
cxxcppflags.clear();
cxxcppflags.push_back("OMPI_MPICXX_CXXCPPFLAGS");
cxxcppflags.push_back("OMPI_CXXCPPFLAGS");
cxxflags.clear();
cxxflags.push_back("OMPI_MPICXX_CXXFLAGS");
cxxflags.push_back("OMPI_CXXFLAGS");
ldflags.clear();
ldflags.push_back("OMPI_MPICXX_LDFLAGS");
ldflags.push_back("OMPI_LDFLAGS");
libs.clear();
libs.push_back("OMPI_MPICXX_LIBS");
libs.push_back("OMPI_LIBS");
return ompi_wrap_engine(argc, argv, compiler, cxxcppflags, cxxflags,
ldflags, libs, OMPI_CXX,
WRAPPER_EXTRA_CXXFLAGS, true, false);
}

Просмотреть файл

@ -1,39 +1,56 @@
//
// $HEADER$
// Function: - wrapper for fortran program compilation
//
#include "ompi_config.h"
#include "util/show_help.h"
#include "tools/wrappers/ompi_wrap.h"
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
// The four wrapper compilers are extremely similar. So similar,
// in fact, that they can be parameterized on what is different.
// Hence, we call the "wrapper compiler engine" to do all the work,
// and pass in just a few arguments to customize for the language of
// this wrapper compiler.
// Hence, we call the "wrapper compiler engine" to do all the
// work, and pass in just a few arguments to customize for the
// language of this wrapper compiler.
#if !OMPI_WANT_F77_BINDINGS
#if 0
show_help("hf77", "no-fortran-support", NULL);
#endif
cerr << "Open MPI was not compiled with f77 support" << endl
<< "(waiting for show_help for a proper error message)" << endl;
ompi_show_help("help-wrapper.txt", "no-fortran-support", true,
77, "mpif77");
return 1;
#else
ompi_sv_t str_vec;
ompi_sv_t compiler;
ompi_sv_t fppflags;
ompi_sv_t fflags;
ompi_sv_t ldflags;
ompi_sv_t libs;
str_vec.clear();
str_vec.push_back("OMPI_MPIF77");
str_vec.push_back("OMPI_F77");
compiler.clear();
compiler.push_back("OMPI_MPIF77");
return ompi_wrap_engine(argc, argv,
str_vec, OMPI_F77, false, true,
WRAPPER_EXTRA_FFLAGS);
fppflags.clear();
fppflags.push_back("OMPI_MPIF77_FPPFLAGS");
fppflags.push_back("OMPI_FPPFLAGS");
fflags.clear();
fflags.push_back("OMPI_MPIF77_FFLAGS");
fflags.push_back("OMPI_FFLAGS");
ldflags.clear();
ldflags.push_back("OMPI_MPIF77_LDFLAGS");
ldflags.push_back("OMPI_LDFLAGS");
libs.clear();
libs.push_back("OMPI_MPIF77_LIBS");
libs.push_back("OMPI_LIBS");
return ompi_wrap_engine(argc, argv, compiler, fppflags, fflags,
ldflags, libs, OMPI_F77, WRAPPER_EXTRA_FFLAGS,
false, true);
#endif
}

Просмотреть файл

@ -1,39 +1,56 @@
//
// $HEADER$
// Function: - wrapper for fortran program compilation
//
#include "ompi_config.h"
#include "util/show_help.h"
#include "tools/wrappers/ompi_wrap.h"
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
// The four wrapper compilers are extremely similar. So similar,
// in fact, that they can be parameterized on what is different.
// Hence, we call the "wrapper compiler engine" to do all the work,
// and pass in just a few arguments to customize for the language of
// this wrapper compiler.
// Hence, we call the "wrapper compiler engine" to do all the
// work, and pass in just a few arguments to customize for the
// language of this wrapper compiler.
#if !OMPI_WANT_F90_BINDINGS
#if 0
show_help("hf90", "no-fortran-support", NULL);
#endif
cerr << "Open MPI was not compiled with f90 support" << endl
<< "(waiting for show_help for a proper error message)" << endl;
ompi_show_help("help-wrapper.txt", "no-fortran-support", true,
90, "mpif90");
return 1;
#else
ompi_sv_t str_vec;
ompi_sv_t compiler;
ompi_sv_t fcppflags;
ompi_sv_t fcflags;
ompi_sv_t ldflags;
ompi_sv_t libs;
str_vec.clear();
str_vec.push_back("OMPI_MPIF90");
str_vec.push_back("OMPI_F90");
compiler.clear();
compiler.push_back("OMPI_MPIF90");
return ompi_wrap_engine(argc, argv,
str_vec, OMPI_F90, false, false,
WRAPPER_EXTRA_FCFLAGS);
fcppflags.clear();
fcppflags.push_back("OMPI_MPIF90_FCPPFLAGS");
fcppflags.push_back("OMPI_FCPPFLAGS");
fcflags.clear();
fcflags.push_back("OMPI_MPIF90_FCFLAGS");
fcflags.push_back("OMPI_FCFLAGS");
ldflags.clear();
ldflags.push_back("OMPI_MPIF90_LDFLAGS");
ldflags.push_back("OMPI_LDFLAGS");
libs.clear();
libs.push_back("OMPI_MPIF90_LIBS");
libs.push_back("OMPI_LIBS");
return ompi_wrap_engine(argc, argv, compiler, fcflags, fcflags,
ldflags, libs, OMPI_F90, WRAPPER_EXTRA_FCFLAGS,
false, true);
#endif
}

Просмотреть файл

@ -1,7 +1,13 @@
//
// $HEADER$
//
/** @file **/
/// @file
///
/// All of these types, global variables, and functions are internal
/// to the ompi_info program. There is probably noting here of value
/// outside of ompi_info.
///
#ifndef OMPI_WRAP_H
#define OMPI_WRAP_H 1
@ -10,66 +16,181 @@
#include <string>
#include <vector>
//
// Commonly used type
//
///
/// Commonly used type
///
typedef std::vector <std::string> ompi_sv_t;
//
// Global variables
//
extern bool fl_libs;
extern bool fl_building;
extern bool fl_profile;
extern bool fl_cpp;
/// Whether we're showing the entire command or not
extern bool showme_cmd;
/// Whether we're showing the compile command or not
extern bool showme_compile;
/// Whether we're showing the link command or not
extern bool showme_link;
//
// Functions in the helper OMPI wrapper compiler library
//
// This is the granddaddy that will invoke the rest
int
ompi_wrap_engine(int argc, char* argv[],
const ompi_sv_t& env_vars, const std::string& default_compiler,
bool want_cxx_libs, bool want_f77_includes,
const std::string& extra_args);
// Parse the command line and get some environment information
///
/// Functions in the helper OMPI wrapper compiler library;
/// this is the granddaddy that will invoke the rest
///
/// \param argc argc from main()
/// \param argv argv from main()
/// \param compiler_env_var List of environment variables for the compiler
/// \param xppflags_env_var List of environment variables for
/// preprocessor flags
/// \param xflags_env_var List of environment variables for compiler flags
/// \param ldflags_env_var List of environment variables for linker flags
/// \param libs_env_var List of environment variables for linker flags
/// \param default_compiler The compiler chosen by configure
/// \param default_xflags Flags chosen by configure
/// \param want_cxx_libs Do we want to link in the C++ libraries?
/// \param want_f77_inclues Do we want to force the f77 includes?
///
int ompi_wrap_engine(int argc, char *argv[],
const ompi_sv_t & compiler_env_var,
const ompi_sv_t & xppflags_env_var,
const ompi_sv_t & xflags_env_var,
const ompi_sv_t & ldflags_env_var,
const ompi_sv_t & libs_env_var,
const std::string & default_compiler,
const std::string & default_xflags,
bool want_cxx_libs, bool want_f77_includes);
///
/// Parse the command line arguments of the wrapper compiler
///
/// \param argc Number of command line parameters
/// \param argv Vector containing command line parameters
/// \param want_flags True if extra flags are needed
///
void ompi_wrap_parse_args(int argc, char *argv[], bool & want_flags);
// Build up various argument lists
///
/// Figure out what the back-end compiler is (even if it's multiple
/// tokens)
///
/// \param env_list List of environment variables passed by the user
/// \param default_comp Defaultl backend compiler
/// \param out Compiler to use (return value)
///
void ompi_wrap_get_compiler(const ompi_sv_t & env_list,
const std::string & default_comp, ompi_sv_t & out);
///
/// Build up a list of arguments for XPPFLAGS (CPPFLAGS, CXXCPPFLAGS
/// or FPPFFLAGS, depending on what the front-end wrapper compiler
/// is).
///
/// \param want_f77_includes If F77 includes are wanted
/// \param cflags Vector of strings containing the cflags (returned)
///
void ompi_wrap_build_xppflags(const ompi_sv_t & env_list,
bool want_f77_includes, ompi_sv_t & xppflags);
///
/// Build of a list of XFLAGS (CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS) to
/// go to the back-end compiler. These are typically extra flags that
/// come from the configure script.
///
/// \param extra_string Extra flags to be passed to backend compiler
/// \param extra_flags Vector of strings to be pased to backend
/// compiler (return value)
///
void ompi_wrap_build_xflags(const ompi_sv_t & env_list,
const std::string & default_xflags,
ompi_sv_t & xflags);
///
/// Build up a list of user arguments (from argc/argv) that will be
/// plugged into the command line that will invoke the back-end
/// compiler.
///
/// \param argc Number of command line parameters
/// \param argv Vector containing the command line parameters
/// \param user_args List of user arguments that will be passed to
/// the back-end compiler (return value)
///
void ompi_wrap_build_user_args(int argc, char *argv[], ompi_sv_t & user_args);
void ompi_wrap_build_cflags(bool want_f77_includes, ompi_sv_t& cflags);
void ompi_wrap_build_ldflags(ompi_sv_t& ldflags);
void ompi_wrap_build_libs(bool want_cxx_libs, ompi_sv_t& libs);
void ompi_wrap_build_extra_flags(const std::string& extra_string,
ompi_sv_t& extra_flags);
// Print or execute the file list of arguments
///
/// Build up a list of LDFLAGS that will be given to the back-end
/// compiler.
///
/// \param ldflags Vector of strings comtaining the LDFLAGS
///
void ompi_wrap_build_ldflags(const ompi_sv_t & env_list, ompi_sv_t & ldflags);
///
/// Build up a list of LIBS that will be given to the back-end
/// compiler.
///
/// \param want_cxx_libs Are we building mpiCC?
/// \param libs Vector of strings containing the libraries to be
/// linked to the backend compiler
///
void ompi_wrap_build_libs(const ompi_sv_t & env_list,
bool want_cxx_libs, ompi_sv_t & libs);
///
/// Print out a vector of strings
///
/// \param sv Vector of strings to be printed out
///
void ompi_wrap_print_sv(const ompi_sv_t & sv);
///
/// Execute a vector of strings (ultimately results down to a call to
/// some flavor of exec()).
///
/// \param sv Vector of strings to be exec()'ed
///
int ompi_wrap_exec_sv(const ompi_sv_t & sv);
// Various helper functions
///
/// Remove leading and trailing white space from a given string.
/// Must be sent a null-terminated string.
///
/// \param str String from which leading and trailing spaces should
/// be removed
///
void ompi_wrap_strip_white(std::string & str);
bool ompi_wrap_split(const std::string& str, char c,
ompi_sv_t& out);
///
/// Split a string into a vector of strings
//
/// \param str String which has to be split into a vector of strings
/// \param c Charecter which demarkates 2 strings
/// \param out Vector of strings (return value)
///
bool ompi_wrap_split(const std::string & str, char c, ompi_sv_t & out);
///
/// Take a string, split it into tokens, and append it to an existing
/// vector of strings
///
/// \param str String which is to be split into tokens
/// \param out Vector of strings to which the tokens are appended
///
void ompi_wrap_split_append_sv(const std::string & str, ompi_sv_t & out);
///
/// Append one vector of strings onto the end of another.
///
/// \param in Vector of strings to be appended
/// \param out Vector of strings to which "in" will be appended
///
void ompi_wrap_append_sv(const ompi_sv_t & in, ompi_sv_t & out);
///
/// Check for the presence of a file
///
/// \param dir Directory in which the file should be present
/// \param file Name of the file
///
bool ompi_wrap_check_file(const std::string & dir, const std::string & file);
#endif // OMPI_WRAP_H

Просмотреть файл

@ -1,10 +1,7 @@
//
// $HEADER$
// Function: - helper library for wrapper compilers
//
/** @file **/
#include "ompi_config.h"
#include <iostream>
@ -20,10 +17,11 @@
#include <errno.h>
#include "util/path.h"
#include "tools/wrappers/ompi_wrap.h"
#include "util/argv.h"
#include "util/few.h"
#include "util/path.h"
#include "util/show_help.h"
#include "tools/wrappers/ompi_wrap.h"
extern char **environ;
@ -50,15 +48,6 @@ bool showme_link(false);
static string cmd_name("<unknown>");
///
/// \internal
///
/// Parse the command line arguments of the wrapper compiler
///
/// \param argc Number of command line parameters
/// \param argv Vector containing command line parameters
/// \param want_flags True if extra flags are needed
///
void
ompi_wrap_parse_args(int argc, char *argv[], bool & want_flags)
{
@ -73,8 +62,8 @@ ompi_wrap_parse_args(int argc, char* argv[], bool& want_flags)
want_flags = false;
for (int i = 1; i < argc; ++i) {
str = argv[i];
if ("-showme" == str.substr(0, 7) || "--showme" == str.substr(0, 8) ||
"-show" == str || "--show" == str) {
if ("-showme" == str.substr(0, 7) || "--showme" == str.substr(0, 8)
|| "-show" == str || "--show" == str) {
want_flags = true;
fl_want_show_error = true;
if ("-showme:" == str.substr(0, 8)) {
@ -111,46 +100,35 @@ ompi_wrap_parse_args(int argc, char* argv[], bool& want_flags)
fl_want_show_error = true;
}
}
#if !OMPI_ENABLE_MPI_PROFILING
// Sanity check
if (fl_profile) {
#if 0
show_help("compile", "no-profiling-support", argv[0], NULL);
#endif
ompi_show_help("help-wrapper.txt", "no-profiling-support", true,
argv[0], NULL);
fl_profile = false;
}
#endif
}
///
/// \internal
///
/// Figure out what the back-end compiler is (even if it's multiple
/// tokens)
///
/// \param env_list List of environment variables passed by the user
/// \param default_comp Defaultl backend compiler
/// \param out Compiler to use (return value)
///
void
ompi_wrap_get_compiler(const ompi_sv_t& env_list, const string& default_comp,
ompi_sv_t& out)
ompi_wrap_get_compiler(const ompi_sv_t & env_list,
const string & default_comp, ompi_sv_t & out)
{
int i;
char *env;
string comp;
string temp1, temp2;
string::size_type pos;
string::size_type i, pos;
string compiler0;
out.clear();
// Check for environment variable overrides
for (i = 0; (string::size_type) i < env_list.size(); ++i) {
for (i = 0; i < env_list.size(); ++i) {
env = getenv(env_list[i].c_str());
if (0 != env) {
if (NULL != env) {
comp = env;
ompi_wrap_split(comp, ' ', out);
break;
@ -162,7 +140,6 @@ ompi_wrap_get_compiler(const ompi_sv_t& env_list, const string& default_comp,
if (out.empty()) {
ompi_wrap_split(default_comp, ' ', out);
}
// If we're preprocessing, we need to know the basename of argv0
// (see below).
@ -175,7 +152,6 @@ ompi_wrap_get_compiler(const ompi_sv_t& env_list, const string& default_comp,
compiler0 = out[0];
}
}
// Ugh. If we're acting as the preprocessor, ditch any libtool
// arguments.
@ -186,8 +162,7 @@ ompi_wrap_get_compiler(const ompi_sv_t& env_list, const string& default_comp,
if ("libtool" == compiler0) {
i = 1;
while ((string::size_type) i < out.size() &&
"--" == out[i].substr(0, 2)){
while (i < out.size() && "--" == out[i].substr(0, 2)) {
++i;
}
out.erase(out.begin(), out.begin() + i);
@ -196,22 +171,27 @@ ompi_wrap_get_compiler(const ompi_sv_t& env_list, const string& default_comp,
}
///
/// \internal
///
/// Build up a list of arguments for CFLAGS (a bit of a misnomer,
/// because it may actually be CXXFLAGS or FFLAGS, depending on what
/// the front-end wrapper compiler is).
///
/// \param want_f77_includes If F77 includes are wanted
/// \param cflags Vector of strings containing the cflags (returned)
///
void
ompi_wrap_build_cflags(bool want_f77_includes, ompi_sv_t& cflags)
ompi_wrap_build_xppflags(const ompi_sv_t & env_list,
bool want_f77_includes, ompi_sv_t & xppflags)
{
string incdir(OMPI_INCDIR);
char *env;
string temp;
cflags.clear();
xppflags.clear();
// Check for environment variable overrides. If we find some, use
// them, regardless of the f77_include setting.
for (string::size_type i = 0; i < env_list.size(); ++i) {
env = getenv(env_list[i].c_str());
if (NULL != env) {
temp = env;
ompi_wrap_split(temp, ' ', xppflags);
return;
}
}
// Ensure that we don't -I/usr/include, for the reasons listed
// above. EXCEPTION: If this is fortran, then we add -I regardless
@ -219,11 +199,11 @@ ompi_wrap_build_cflags(bool want_f77_includes, ompi_sv_t& cflags)
// -I/usr/include automatically.
if (want_f77_includes || "/usr/include" != incdir) {
cflags.push_back("-I" + incdir);
xppflags.push_back("-I" + incdir);
}
#if OMPI_WANT_CXX_BINDINGS
cflags.push_back("-I" + incdir + "/openmpi");
xppflags.push_back("-I" + incdir + "/openmpi");
#endif
#if defined(WIN32) && WIN32
@ -232,18 +212,31 @@ ompi_wrap_build_cflags(bool want_f77_includes, ompi_sv_t& cflags)
}
///
/// \internal
///
/// Build up a list of user arguments (from argc/argv) that will be
/// plugged into the command line that will invoke the back-end
/// compiler.
///
/// \param argc Number of command line parameters
/// \param argv Vector containing the command line parameters
/// \param user_args List of user arguments that will be passed to
/// the back-end compiler (return value)
///
void
ompi_wrap_build_xflags(const ompi_sv_t & env_list,
const string & default_xflags, ompi_sv_t & xflags)
{
char *env;
string temp;
// Check for environment variable overrides. If we find some, use
// them, regardless of the f77_include setting.
for (string::size_type i = 0; i < env_list.size(); ++i) {
env = getenv(env_list[i].c_str());
if (NULL != env) {
temp = env;
ompi_wrap_split(temp, ' ', xflags);
return;
}
}
if (!default_xflags.empty()) {
ompi_wrap_split_append_sv(default_xflags, xflags);
}
}
void
ompi_wrap_build_user_args(int argc, char *argv[], ompi_sv_t & user_args)
{
@ -256,27 +249,19 @@ ompi_wrap_build_user_args(int argc, char* argv[], ompi_sv_t& user_args)
str = argv[i];
if ("-showme" != str.substr(0, 7) &&
"--showme" != str.substr(0, 8) &&
"-show" != str &&
"--show" != str &&
"-lpmpi" != str){
"-show" != str && "--show" != str && "-lpmpi" != str) {
user_args.push_back(str);
}
}
}
///
/// \internal
///
/// Build up a list of LDFLAGS that will be given to the back-end
/// compiler.
///
/// \param ldflags Vector of strings comtaining the LDFLAGS
///
void
ompi_wrap_build_ldflags(ompi_sv_t& ldflags)
ompi_wrap_build_ldflags(const ompi_sv_t & env_list, ompi_sv_t & ldflags)
{
char *env;
string s;
string temp;
string libdir(OMPI_LIBDIR);
ompi_sv_t sv;
ompi_sv_t::iterator svi;
@ -289,6 +274,16 @@ ompi_wrap_build_ldflags(ompi_sv_t& ldflags)
if (!fl_libs) {
return;
}
// Check for environment variable overrides
for (string::size_type i = 0; i < env_list.size(); ++i) {
env = getenv(env_list[i].c_str());
if (NULL != env) {
temp = env;
ompi_wrap_split(temp, ' ', ldflags);
return;
}
}
// Add in the extra flags passed by configure. Do the same kinds of
// checks that we do below -- ensure that we don't add a "-L/usr" to
@ -304,7 +299,6 @@ ompi_wrap_build_ldflags(ompi_sv_t& ldflags)
}
}
}
// Form library directory pathname.
//
// Add "-L$prefix/lib".
@ -319,24 +313,13 @@ ompi_wrap_build_ldflags(ompi_sv_t& ldflags)
}
///
/// \internal
///
/// Build up a list of LIBS that will be given to the back-end
/// compiler.
///
/// \param want_cxx_libs Are we building mpiCC?
/// \param libs Vector of strings containing the libraries to be
/// linked to the backend compiler
void
ompi_wrap_build_libs(bool want_cxx_libs, ompi_sv_t& libs)
ompi_wrap_build_libs(const ompi_sv_t & env_list,
bool want_cxx_libs, ompi_sv_t & libs)
{
char *env;
string temp;
string libdir(OMPI_LIBDIR);
#if 0
#if OMPI_WANT_ROMIO && HAVE_LIBAIO
bool want_aio(false);
#endif
#endif
libs.clear();
@ -345,27 +328,19 @@ ompi_wrap_build_libs(bool want_cxx_libs, ompi_sv_t& libs)
if (!fl_libs) {
return;
}
// Check for environment variable overrides
for (string::size_type i = 0; i < env_list.size(); ++i) {
env = getenv(env_list[i].c_str());
if (NULL != env) {
temp = env;
ompi_wrap_split(temp, ' ', libs);
return;
}
}
// Now we start adding libraries to libs
// ROMIO comes first. Check to ensure that it exists (and that the
// profiling library was previously found).
#if 0
#if OMPI_WANT_ROMIO
if (!ompi_wrap_check_file(libdir, "libompi_mpio.a") &&
!ompi_wrap_check_file(libdir, "libompi_mpio.so")) {
cerr << "WARNING: " << cmd_name
<< " expected to find libompi_mpio.* in " << libdir << endl
<< "WARNING: MPI-2 IO support will be disabled" << endl;
} else {
libs.push_back("-lompi_mpio");
#if HAVE_LIBAIO
want_aio = true;
#endif
}
#endif
#endif
#if OMPI_WANT_CXX_BINDINGS
// The C++ bindings come next
if (want_cxx_libs) {
@ -381,92 +356,36 @@ ompi_wrap_build_libs(bool want_cxx_libs, ompi_sv_t& libs)
}
#endif
// Next comes the fortran MPI library
#if 0
#if BUILD_MPI_F77
if (!ompi_wrap_check_file(libdir, "libompif77mpi.a") &&
!ompi_wrap_check_file(libdir, "libompif77mpi.so")) {
cerr << "WARNING: " << cmd_name
<< " expected to find libompif77mpi.* in " << libdir << endl
<< "WARNING: MPI Fortran support will be disabled" << endl;
} else {
libs.push_back("-lompif77mpi");
}
#endif
#endif
// Next comes the MPI library
libs.push_back("-lmpi");
// Finally, any system libraries
#if 0
#if OMPI_WANT_ROMIO && HAVE_LIBAIO
if (want_aio) {
libs.push_back("-laio");
}
#endif
#endif
ompi_wrap_split_append_sv(WRAPPER_EXTRA_LIBS, libs);
}
///
/// \internal
///
/// Build of a list of extra flags to go to the back-end compiler.
/// These are typically extra flags that come from the configure
/// script.
///
/// \param extra_string Extra flags to be passed to backend compiler
/// \param extra_flags Vector of strings to be pased to backend
/// compiler (return value)
///
void
ompi_wrap_build_extra_flags(const string& extra_string, ompi_sv_t& extra_flags)
{
if (!extra_string.empty()) {
ompi_wrap_split_append_sv(extra_string, extra_flags);
}
}
///
/// \internal
///
/// Print out a vector of strings
///
/// \param sv Vector of strings to be printed out
///
void
ompi_wrap_print_sv(const ompi_sv_t & sv)
{
for (int i = 0; (string::size_type) i < sv.size(); ++i) {
for (string::size_type i = 0; i < sv.size(); ++i) {
cout << sv[i] << " ";
}
}
///
/// \internal
///
/// Execute a vector of strings (ultimately results down to a call to
/// some flavor of exec()).
///
/// \param sv Vector of strings to be exec()'ed
///
int
ompi_wrap_exec_sv(const ompi_sv_t & sv)
{
int status;
int ret;
int i, ac = 0;
int ac = 0;
char **av = 0;
char *tmp = NULL;
string::size_type i;
// Build up a C array of the args
for (i = 0; (string::size_type) i < sv.size(); ++i) {
for (i = 0; i < sv.size(); ++i) {
ompi_argv_append(&ac, &av, (char *) sv[i].c_str());
}
@ -476,9 +395,8 @@ ompi_wrap_exec_sv(const ompi_sv_t& sv)
// compiler first, just to try to eliminate that case.
tmp = ompi_path_env_findv(av[0], 0, environ, NULL);
if (NULL == tmp) {
#if 0
show_help("compile", "no-compiler-found", av[0], NULL);
#endif
ompi_show_help("help-wrapper.txt", "no-compiler-found", true,
av[0], NULL);
errno = 0;
status = -1;
} else {
@ -500,15 +418,6 @@ ompi_wrap_exec_sv(const ompi_sv_t& sv)
}
///
/// \internal
///
/// Remove leading and trailing white space from a given string.
/// Must be sent a null-terminated string.
///
/// \param str String from which leading and trailing spaces should
/// be removed
///
void
ompi_wrap_strip_white(string & str)
{
@ -534,15 +443,6 @@ ompi_wrap_strip_white(string& str)
}
///
/// \internal
///
/// Split a string into a vector of strings
//
/// \param str String which has to be split into a vector of strings
/// \param c Charecter which demarkates 2 strings
/// \param out Vector of strings (return value)
///
bool
ompi_wrap_split(const string & str, char c, ompi_sv_t & out)
{
@ -558,7 +458,6 @@ ompi_wrap_split(const string& str, char c, ompi_sv_t& out)
if (i >= size) {
return false;
}
// Now start making a vector of the strings
while (i < size) {
@ -576,54 +475,28 @@ ompi_wrap_split(const string& str, char c, ompi_sv_t& out)
}
///
/// \internal
///
/// Take a string, split it into tokens, and append it to an existing
/// vector of strings
///
/// \param str String which is to be split into tokens
/// \param out Vector of strings to which the tokens are appended
///
void
ompi_wrap_split_append_sv(const string & str, ompi_sv_t & out)
{
int i;
ompi_sv_t temp;
ompi_wrap_split(str, ' ', temp);
for (i = 0; (string::size_type) i < temp.size(); ++i){
for (string::size_type i = 0; i < temp.size(); ++i) {
out.push_back(temp[i]);
}
}
///
/// \internal
///
/// Append one vector of strings onto the end of another.
///
/// \param in Vector of strings to be appended
/// \param out Vector of strings to which "in" will be appended
///
void
ompi_wrap_append_sv(const ompi_sv_t & in, ompi_sv_t & out)
{
// JMS Is there a better way to do this?
for (int i = 0; (string::size_type) i < in.size(); ++i){
for (string::size_type i = 0; i < in.size(); ++i) {
out.push_back(in[i]);
}
}
///
/// \internal
///
/// Check for the presence of a file
///
/// \param dir Directory in which the file should be present
/// \param file Name of the file
///
bool
ompi_wrap_check_file(const string & dir, const string & file)
{

Просмотреть файл

@ -20,11 +20,25 @@ using namespace std;
/// \param want_f77_includes Whether F77 include path should be added
/// \param extra_args Extra arguments which need to be added
///
/// At most, we end up with a command line in the following form:
///
/// [compiler(*)] [Xppflags(*)] [Xflags(*)] [user args] [ldflags(*)] [libs(*)]
///
/// Items with (*) can be overridden at run time with environment variables.
///
/// X can be replaced with C, CXX, F, and FC for C, C++, Fortran 77,
/// and Fortran 90, respectively.
///
int
ompi_wrap_engine(int argc, char *argv[],
const ompi_sv_t& env_vars, const string& default_compiler,
bool want_cxx_libs, bool want_f77_includes,
const string& extra_args)
const ompi_sv_t & compiler_env_var,
const ompi_sv_t & xppflags_env_var,
const ompi_sv_t & xflags_env_var,
const ompi_sv_t & ldflags_env_var,
const ompi_sv_t & libs_env_var,
const std::string & default_compiler,
const std::string & default_xflags,
bool want_cxx_libs, bool want_f77_includes)
{
int ret(0);
@ -33,7 +47,8 @@ ompi_wrap_engine(int argc, char* argv[],
ompi_sv_t str_vec;
ompi_sv_t compiler;
ompi_sv_t cflags;
ompi_sv_t xppflags;
ompi_sv_t xflags;
ompi_sv_t user_args;
ompi_sv_t ldflags;
ompi_sv_t libs;
@ -47,49 +62,50 @@ ompi_wrap_engine(int argc, char* argv[],
// Get the compiler
ompi_wrap_get_compiler(env_vars, default_compiler, compiler);
ompi_wrap_get_compiler(compiler_env_var, default_compiler, compiler);
// Build the CFLAGS
// Build the XPPFLAGS (-I stuff only)
ompi_wrap_build_cflags(want_f77_includes, cflags);
ompi_wrap_build_xppflags(xppflags_env_var, want_f77_includes,
xppflags);
// Build any XFLAGS
ompi_wrap_build_xflags(xflags_env_var, default_xflags, xflags);
// Build the user arguments
ompi_wrap_build_user_args(argc, argv, user_args);
// Build the LDFLAGS
// Build the LDFLAGS (-L stuff and WRAPPER_EXTRA_LDFLAGS)
ompi_wrap_build_ldflags(ldflags);
ompi_wrap_build_ldflags(ldflags_env_var, ldflags);
// Build the LIBS
// Build the LIBS (-l stuff and WRAPPER_EXTRA_LIBS)
ompi_wrap_build_libs(want_cxx_libs, libs);
// Build any extra arguments
ompi_wrap_build_extra_flags(extra_args, extra_flags);
ompi_wrap_build_libs(libs_env_var, want_cxx_libs, libs);
// Now assemble the command line
cmd_line.clear();
ompi_wrap_append_sv(compiler, cmd_line);
if (want_flags) {
ompi_wrap_append_sv(cflags, cmd_line);
ompi_wrap_append_sv(extra_flags, cmd_line);
ompi_wrap_append_sv(xppflags, cmd_line);
ompi_wrap_append_sv(xflags, cmd_line);
}
ompi_wrap_append_sv(user_args, cmd_line);
if (want_flags) {
ompi_wrap_append_sv(ldflags, cmd_line);
ompi_wrap_append_sv(libs, cmd_line);
}
// Display or execute?
if (showme_cmd)
if (showme_cmd) {
ompi_wrap_print_sv(compiler);
}
if (showme_cmd || showme_compile) {
ompi_wrap_print_sv(cflags);
ompi_wrap_print_sv(extra_flags);
ompi_wrap_print_sv(xppflags);
ompi_wrap_print_sv(xflags);
}
if (showme_cmd || showme_compile || showme_link)
ompi_wrap_print_sv(user_args);
@ -97,10 +113,11 @@ ompi_wrap_engine(int argc, char* argv[],
ompi_wrap_print_sv(ldflags);
ompi_wrap_print_sv(libs);
}
if (showme_cmd || showme_compile || showme_link)
if (showme_cmd || showme_compile || showme_link) {
cout << endl;
else
} else {
ret = ompi_wrap_exec_sv(cmd_line);
}
// That's all she wrote