Skip to content

Commit 97cc916

Browse files
committed
Per discussion at the Open MPI developer meeting last week:
1. Restore libopen-pal.la, libopen-rte.la, and libmpi.la to be separate entities (i.e., don't have libopen-rte.la include libopen-pal.la, and don't have libmpi.la include libopen-pal.la). Yay! 1. Consequently, make the wrapper compilers look for flags indicating that the user wants to compile statically (currently: -static, !--static, -Bstatic, and "-Wl," in front of all of those). If it is, follow a 6-way matrix for determinining which libraries to list on the underlying command line. 1. To support that, add the name of a token static and dynamic library to look for in each of the wrapper compiler data files. 1. Fix a long-standing typo in the opalcc wrapper data file. This commit was SVN r27662.
1 parent a454341 commit 97cc916

12 files changed

+137
-32
lines changed

configure.ac

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,34 @@ LTDL_CONVENIENCE
10831083
LT_INIT([dlopen win32-dll])
10841084
])
10851085

1086+
# What's the suffix of shared libraries? Inspired by generated
1087+
# Libtool code (even though we don't support several of these
1088+
# platforms, there didn't seem to be any harm in leaving in some of
1089+
# them, alhtough I did remove some that we have never/will never
1090+
# support, like OS/2).
1091+
case $host_os in
1092+
cygwin* | mingw* | pw32* | cegcc*)
1093+
OPAL_DYN_LIB_SUFFIX=dll
1094+
;;
1095+
darwin* | rhapsody*)
1096+
OPAL_DYN_LIB_SUFFIX=dylib
1097+
;;
1098+
hpux9* | hpux10* | hpux11*)
1099+
case $host_cpu in
1100+
ia64*)
1101+
OPAL_DYN_LIB_SUFFIX=so
1102+
;;
1103+
*)
1104+
OPAL_DYN_LIB_SUFFIX=sl
1105+
;;
1106+
esac
1107+
;;
1108+
*)
1109+
OPAL_DYN_LIB_SUFFIX=so
1110+
;;
1111+
esac
1112+
AC_SUBST(OPAL_DYN_LIB_SUFFIX)
1113+
10861114
OPAL_SETUP_LIBLTDL
10871115

10881116

ompi/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ libmpi_la_LIBADD = \
138138
$(MCA_ompi_FRAMEWORK_LIBS) \
139139
$(OMPI_MPIEXT_C_LIBS) \
140140
$(OMPI_LIBMPI_EXTRA_LIBS) \
141-
$(top_ompi_builddir)/orte/libopen-rte-lt.la
141+
$(top_ompi_builddir)/orte/libopen-rte.la
142142
libmpi_la_DEPENDENCIES = $(libmpi_la_LIBADD)
143143
libmpi_la_LDFLAGS = \
144144
-version-info $(libmpi_so_version) \

ompi/tools/wrappers/mpic++-wrapper-data.txt.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ compiler_flags_prefix=@OMPI_WRAPPER_EXTRA_CXXFLAGS_PREFIX@
1818
compiler_flags=@OMPI_WRAPPER_EXTRA_CXXFLAGS@
1919
linker_flags=@OMPI_WRAPPER_EXTRA_LDFLAGS@
2020
libs=@OMPI_WRAPPER_CXX_LIB@ -lmpi @OMPI_WRAPPER_EXTRA_LIBS@
21+
libs_static=@OMPI_WRAPPER_CXX_LIB@ -lmpi @OMPI_WRAPPER_EXTRA_LIBS@ -lopen-rte @ORTE_WRAPPER_EXTRA_LIBS@ -lopen-pal @OPAL_WRAPPER_EXTRA_LIBS@
22+
dyn_lib_file=libmpi.@OPAL_DYN_LIB_SUFFIX@
23+
static_lib_file=libmpi.a
2124
required_file=@OMPI_WRAPPER_CXX_REQUIRED_FILE@
2225
includedir=${includedir}
2326
libdir=${libdir}

ompi/tools/wrappers/mpicc-wrapper-data.txt.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ compiler_flags_prefix=@OMPI_WRAPPER_EXTRA_CFLAGS_PREFIX@
1818
compiler_flags=@OMPI_WRAPPER_EXTRA_CFLAGS@
1919
linker_flags=@OMPI_WRAPPER_EXTRA_LDFLAGS@
2020
libs=-lmpi @OMPI_WRAPPER_EXTRA_LIBS@
21+
libs_static=-lmpi @OMPI_WRAPPER_EXTRA_LIBS@ -lopen-rte @ORTE_WRAPPER_EXTRA_LIBS@ -lopen-pal @OPAL_WRAPPER_EXTRA_LIBS@
22+
dyn_lib_file=libmpi.@OPAL_DYN_LIB_SUFFIX@
23+
static_lib_file=libmpi.a
2124
required_file=
2225
includedir=${includedir}
2326
libdir=${libdir}

ompi/tools/wrappers/mpifort-wrapper-data.txt.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ preprocessor_flags=
1818
compiler_flags=@OMPI_WRAPPER_EXTRA_FCFLAGS@
1919
linker_flags=@OMPI_WRAPPER_EXTRA_LDFLAGS@
2020
libs=@OMPI_FORTRAN_USEMPIF08_LIB@ @OMPI_FORTRAN_USEMPI_LIB@ -lmpi_mpifh -lmpi -lopen-rte -lopen-pal @OMPI_WRAPPER_EXTRA_LIBS@
21+
libs_static=@OMPI_FORTRAN_USEMPIF08_LIB@ @OMPI_FORTRAN_USEMPI_LIB@ -lmpi_mpifh -lmpi @OMPI_WRAPPER_EXTRA_LIBS@ -lopen-rte @ORTE_WRAPPER_EXTRA_LIBS@ -lopen-pal @OPAL_WRAPPER_EXTRA_LIBS@
22+
dyn_lib_file=libmpi.@OPAL_DYN_LIB_SUFFIX@
23+
static_lib_file=libmpi.a
2124
required_file=@OMPI_WRAPPER_FORTRAN_REQUIRED_FILE@
2225
includedir=${includedir}
2326
libdir=${libdir}

opal/Makefile.am

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,3 @@ include mca/Makefile.am
8686
include win32/Makefile.am
8787
include tools/Makefile.am
8888
include dss/Makefile.am
89-
90-
# Set the convenience library to be the same as the non-convenience
91-
# library, but a) it's marked as "noinst", so LT knows it's a
92-
# convenience library, and b) no .so version number is assigned here.
93-
# Note that we only need to make the convenience library if the ORTE
94-
# project is being built (i.e., if there is an upper layer that needs
95-
# to slurp in OPAL as a convenience library).
96-
97-
if PROJECT_ORTE
98-
noinst_LTLIBRARIES += libopen-pal-lt.la
99-
endif
100-
libopen_pal_lt_la_SOURCES = $(libopen_pal_la_SOURCES)
101-
libopen_pal_lt_la_LIBADD = $(libopen_pal_la_LIBADD)
102-
libopen_pal_lt_la_DEPENDENCIES = $(libopen_pal_la_DEPENDENCIES)

opal/tools/wrappers/opal_wrapper.c

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ struct options_data_t {
7979
char **comp_flags_prefix;
8080
char **link_flags;
8181
char **libs;
82+
char **libs_static;
83+
char *dyn_lib_file;
84+
char *static_lib_file;
8285
char *req_file;
8386
char *path_includedir;
8487
char *path_libdir;
@@ -100,6 +103,7 @@ static int default_data_idx = -1;
100103
#define COMP_WANT_COMPILE 0x010
101104
#define COMP_WANT_LINK 0x020
102105
#define COMP_WANT_PMPI 0x040
106+
#define COMP_WANT_STATIC 0x080
103107

104108
static void
105109
options_data_init(struct options_data_t *data)
@@ -124,6 +128,10 @@ options_data_init(struct options_data_t *data)
124128
data->link_flags[0] = NULL;
125129
data->libs = (char **) malloc(sizeof(char*));
126130
data->libs[0] = NULL;
131+
data->libs_static = (char **) malloc(sizeof(char*));
132+
data->libs_static[0] = NULL;
133+
data->dyn_lib_file = NULL;
134+
data->static_lib_file = NULL;
127135
data->req_file = NULL;
128136
data->path_includedir = NULL;
129137
data->path_libdir = NULL;
@@ -149,6 +157,9 @@ options_data_free(struct options_data_t *data)
149157
opal_argv_free(data->comp_flags_prefix);
150158
opal_argv_free(data->link_flags);
151159
opal_argv_free(data->libs);
160+
opal_argv_free(data->libs_static);
161+
if (NULL != data->dyn_lib_file) free(data->dyn_lib_file);
162+
if (NULL != data->static_lib_file) free(data->static_lib_file);
152163
if (NULL != data->req_file) free(data->req_file);
153164
if (NULL != data->path_includedir) free(data->path_includedir);
154165
if (NULL != data->path_libdir) free(data->path_libdir);
@@ -323,6 +334,16 @@ data_callback(const char *key, const char *value)
323334
opal_argv_count(options_data[parse_options_idx].libs),
324335
values);
325336
opal_argv_free(values);
337+
} else if (0 == strcmp(key, "libs_static")) {
338+
char **values = opal_argv_split(value, ' ');
339+
opal_argv_insert(&options_data[parse_options_idx].libs_static,
340+
opal_argv_count(options_data[parse_options_idx].libs_static),
341+
values);
342+
opal_argv_free(values);
343+
} else if (0 == strcmp(key, "dyn_lib_file")) {
344+
if (NULL != value) options_data[parse_options_idx].dyn_lib_file = strdup(value);
345+
} else if (0 == strcmp(key, "static_lib_file")) {
346+
if (NULL != value) options_data[parse_options_idx].static_lib_file = strdup(value);
326347
} else if (0 == strcmp(key, "required_file")) {
327348
if (NULL != value) options_data[parse_options_idx].req_file = strdup(value);
328349
} else if (0 == strcmp(key, "project_short")) {
@@ -696,6 +717,13 @@ main(int argc, char *argv[])
696717
/* remove element from user_argv */
697718
opal_argv_delete(&user_argc, &user_argv, i, 1);
698719
--i;
720+
} else if (0 == strcmp(user_argv[i], "-static") ||
721+
0 == strcmp(user_argv[i], "--static") ||
722+
0 == strcmp(user_argv[i], "-Bstatic") ||
723+
0 == strcmp(user_argv[i], "-Wl,-static") ||
724+
0 == strcmp(user_argv[i], "-Wl,--static") ||
725+
0 == strcmp(user_argv[i], "-Wl,-Bstatic")) {
726+
flags |= COMP_WANT_STATIC;
699727
} else if ('-' != user_argv[i][0]) {
700728
disable_flags = false;
701729
flags |= COMP_SHOW_ERROR;
@@ -793,10 +821,66 @@ main(int argc, char *argv[])
793821

794822
/* link flags and libs */
795823
if (flags & COMP_WANT_LINK) {
824+
bool have_static_lib;
825+
bool have_dyn_lib;
826+
bool use_static_libs;
827+
char *filename;
828+
struct stat buf;
829+
796830
opal_argv_insert(&exec_argv, exec_argc, options_data[user_data_idx].link_flags);
797831
exec_argc = opal_argv_count(exec_argv);
798832

799-
opal_argv_insert(&exec_argv, exec_argc, options_data[user_data_idx].libs);
833+
/* Are we linking statically? If so, decide what libraries to
834+
list. It depends on two factors:
835+
836+
1. Was --static (etc.) specified?
837+
2. Does OMPI have static, dynamic, or both libraries installed?
838+
839+
Here's a matrix showing what we'll do in all 6 cases:
840+
841+
What's installed --static no --static
842+
---------------- ---------- -----------
843+
ompi .so libs -lmpi -lmpi
844+
ompi .a libs all all
845+
ompi both libs all -lmpi
846+
847+
*/
848+
849+
filename = opal_os_path( false, options_data[user_data_idx].path_libdir, options_data[user_data_idx].static_lib_file, NULL );
850+
if (0 == stat(filename, &buf)) {
851+
have_static_lib = true;
852+
} else {
853+
have_static_lib = false;
854+
}
855+
856+
filename = opal_os_path( false, options_data[user_data_idx].path_libdir, options_data[user_data_idx].dyn_lib_file, NULL );
857+
if (0 == stat(filename, &buf)) {
858+
have_dyn_lib = true;
859+
} else {
860+
have_dyn_lib = false;
861+
}
862+
863+
/* Determine which set of libs to use: dynamic or static. Be
864+
pedantic to make the code easy to read. */
865+
if (flags & COMP_WANT_STATIC) {
866+
if (have_static_lib) {
867+
use_static_libs = true;
868+
} else {
869+
use_static_libs = false;
870+
}
871+
} else {
872+
if (have_dyn_lib) {
873+
use_static_libs = false;
874+
} else {
875+
use_static_libs = true;
876+
}
877+
}
878+
879+
if (use_static_libs) {
880+
opal_argv_insert(&exec_argv, exec_argc, options_data[user_data_idx].libs_static);
881+
} else {
882+
opal_argv_insert(&exec_argv, exec_argc, options_data[user_data_idx].libs);
883+
}
800884
exec_argc = opal_argv_count(exec_argv);
801885
}
802886

opal/tools/wrappers/opalc++-wrapper-data.txt.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ compiler_flags_prefix=@OPAL_WRAPPER_EXTRA_CXXFLAGS_PREFIX@
1818
compiler_flags=@OPAL_WRAPPER_EXTRA_CXXFLAGS@
1919
linker_flags=@OPAL_WRAPPER_EXTRA_LDFLAGS@
2020
libs=-lopen-pal @OPAL_WRAPPER_EXTRA_LIBS@
21+
libs_static=-lopen-pal @OPAL_WRAPPER_EXTRA_LIBS@
22+
dyn_lib_file=libopen-pal.@OPAL_DYN_LIB_SUFFIX@
23+
static_lib_file=libopen-pal.a
2124
required_file=
2225
includedir=${includedir}
2326
libdir=${libdir}

opal/tools/wrappers/opalcc-wrapper-data.txt.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ version=@OPAL_VERSION@
1111
language=C
1212
compiler_env=CC
1313
compiler_flags_env=CFLAGS
14-
compiler=@OPAL_WRAPPER_CC@
14+
compiler=@WRAPPER_CC@
1515
extra_includes=@OPAL_WRAPPER_EXTRA_INCLUDES@
1616
preprocessor_flags=@OPAL_WRAPPER_EXTRA_CPPFLAGS@
1717
compiler_flags_prefix=@OPAL_WRAPPER_EXTRA_CFLAGS_PREFIX@
1818
compiler_flags=@OPAL_WRAPPER_EXTRA_CFLAGS@
1919
linker_flags=@OPAL_WRAPPER_EXTRA_LDFLAGS@
2020
libs=-lopen-pal @OPAL_WRAPPER_EXTRA_LIBS@
21+
libs_static=-lopen-pal @OPAL_WRAPPER_EXTRA_LIBS@
22+
dyn_lib_file=libopen-pal.@OPAL_DYN_LIB_SUFFIX@
23+
static_lib_file=libopen-pal.a
2124
required_file=
2225
includedir=${includedir}
2326
libdir=${libdir}

orte/Makefile.am

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ lib_LTLIBRARIES = libopen-rte.la
3737
libopen_rte_la_SOURCES =
3838
libopen_rte_la_LIBADD = \
3939
$(MCA_orte_FRAMEWORK_LIBS) \
40-
$(top_ompi_builddir)/opal/libopen-pal-lt.la
40+
$(top_ompi_builddir)/opal/libopen-pal.la
4141
libopen_rte_la_DEPENDENCIES = $(libopen_rte_la_LIBADD)
4242
libopen_rte_la_LDFLAGS = -version-info $(libopen_rte_so_version)
4343

@@ -63,17 +63,3 @@ include tools/Makefile.am
6363
include orted/Makefile.am
6464
include test/mpi/Makefile.include
6565
include test/system/Makefile.include
66-
67-
# Set the convenience library to be the same as the non-convenience
68-
# library, but a) it's marked as "noinst", so LT knows it's a
69-
# convenience library, and b) no .so version number is assigned here.
70-
# Note that we only need to make the convenience library if the OMPI
71-
# project is being built (i.e., if there is an upper layer that needs
72-
# to slurp in ORTE as a convenience library).
73-
74-
if PROJECT_ORTE
75-
noinst_LTLIBRARIES += libopen-rte-lt.la
76-
endif
77-
libopen_rte_lt_la_SOURCES = $(libopen_rte_la_SOURCES)
78-
libopen_rte_lt_la_LIBADD = $(libopen_rte_la_LIBADD)
79-
libopen_rte_lt_la_DEPENDENCIES = $(libopen_rte_la_DEPENDENCIES)

orte/tools/wrappers/ortec++-wrapper-data.txt.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ compiler_flags_prefix=@ORTE_WRAPPER_EXTRA_CXXFLAGS_PREFIX@
1818
compiler_flags=@ORTE_WRAPPER_EXTRA_CXXFLAGS@
1919
linker_flags=@ORTE_WRAPPER_EXTRA_LDFLAGS@
2020
libs=-lopen-rte @ORTE_WRAPPER_EXTRA_LIBS@
21+
libs_static=-lopen-rte @ORTE_WRAPPER_EXTRA_LIBS@ -lopen-pal @OPAL_WRAPPER_EXTRA_LIBS@
22+
dyn_lib_file=libopen-rte.@OPAL_DYN_LIB_SUFFIX@
23+
static_lib_file=libopen-rte.a
2124
required_file=
2225
includedir=${includedir}
2326
libdir=${libdir}

orte/tools/wrappers/ortecc-wrapper-data.txt.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ compiler_flags_prefix=@ORTE_WRAPPER_EXTRA_CFLAGS_PREFIX@
1818
compiler_flags=@ORTE_WRAPPER_EXTRA_CFLAGS@
1919
linker_flags=@ORTE_WRAPPER_EXTRA_LDFLAGS@
2020
libs=-lopen-rte @ORTE_WRAPPER_EXTRA_LIBS@
21+
libs_static=-lopen-rte @ORTE_WRAPPER_EXTRA_LIBS@ -lopen-pal @OPAL_WRAPPER_EXTRA_LIBS@
22+
dyn_lib_file=libopen-rte.@OPAL_DYN_LIB_SUFFIX@
23+
static_lib_file=libopen-rte.a
2124
required_file=
2225
includedir=${includedir}
2326
libdir=${libdir}

0 commit comments

Comments
 (0)