Skip to content

Commit 5d23e02

Browse files
committed
wrappers: Improve static library handling
Improve static application build handling in the wrapper compilers by tracking both LIBS (the libraries libmpi/libopen-pal depend on) and LIBS_STATIC (the libraries those libraries depend on), and improve the behavior of static/dynamic linking with the wrapper compilers, to make them similar to the pkg-config behaviors. See the overly verbose comment in opal_setup_wrappers.m4 for the intended behavior. Finally, start tracking pkg-config module dependencies, when possible. Signed-off-by: Brian Barrett <[email protected]>
1 parent d424a8c commit 5d23e02

20 files changed

+960
-503
lines changed

config/opal_set_lib_name.m4

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
44
# Copyright (c) 2016 IBM Corporation. All rights reserved.
55
# Copyright (c) 2020 Intel, Inc. All rights reserved.
6+
# Copyright (c) 2022 Amazon.com, Inc. or its affiliates.
7+
# All Rights reserved.
68
# $COPYRIGHT$
79
#
810
# Additional copyrights may follow
@@ -44,6 +46,8 @@ AC_DEFUN([OMPI_SET_LIB_NAME],[
4446
AS_IF([test "$with_libmpi_name" = "" || test "$with_libmpi_name" = "yes"],
4547
[with_libmpi_name="mpi"])
4648

47-
AC_MSG_RESULT([$with_libmpi_name])
48-
AC_SUBST(OMPI_LIBMPI_NAME, $with_libmpi_name)
49+
OMPI_LIBMPI_NAME=${with_libmpi_name}
50+
51+
AC_MSG_RESULT([$OMPI_LIBMPI_NAME])
52+
AC_SUBST(OMPI_LIBMPI_NAME)
4953
])dnl

config/opal_setup_wrappers.m4

Lines changed: 626 additions & 166 deletions
Large diffs are not rendered by default.

ompi/tools/ompi_info/param.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Copyright (c) 2014-2019 Research Organization for Information Science
1515
* and Technology (RIST). All rights reserved.
1616
* Copyright (c) 2015-2019 Intel, Inc. All rights reserved.
17-
* Copyright (c) 2018-2021 Amazon.com, Inc. or its affiliates. All Rights reserved.
17+
* Copyright (c) 2018-2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
1818
* Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
1919
* $COPYRIGHT$
2020
*
@@ -608,16 +608,16 @@ void ompi_info_do_config(bool want_all)
608608
opal_info_out("Build LDFLAGS", "option:build:ldflags", OMPI_BUILD_LDFLAGS);
609609
opal_info_out("Build LIBS", "option:build:libs", OMPI_BUILD_LIBS);
610610

611-
opal_info_out("Wrapper extra CFLAGS", "option:wrapper:extra_cflags",
612-
WRAPPER_EXTRA_CFLAGS);
613-
opal_info_out("Wrapper extra CXXFLAGS", "option:wrapper:extra_cxxflags",
614-
WRAPPER_EXTRA_CXXFLAGS);
615-
opal_info_out("Wrapper extra FCFLAGS", "option:wrapper:extra_fcflags",
616-
WRAPPER_EXTRA_FCFLAGS);
617-
opal_info_out("Wrapper extra LDFLAGS", "option:wrapper:extra_ldflags",
618-
WRAPPER_EXTRA_LDFLAGS);
619-
opal_info_out("Wrapper extra LIBS", "option:wrapper:extra_libs",
620-
WRAPPER_EXTRA_LIBS);
611+
opal_info_out("Wrapper CFLAGS", "option:wrapper:cflags",
612+
OMPI_WRAPPER_CFLAGS);
613+
opal_info_out("Wrapper CXXFLAGS", "option:wrapper:cxxflags",
614+
OMPI_WRAPPER_CXXFLAGS);
615+
opal_info_out("Wrapper FCFLAGS", "option:wrapper:fcflags",
616+
OMPI_WRAPPER_FCFLAGS);
617+
opal_info_out("Wrapper LDFLAGS", "option:wrapper:ldflags",
618+
OMPI_WRAPPER_LDFLAGS);
619+
opal_info_out("Wrapper LIBS", "option:wrapper:libs",
620+
OMPI_WRAPPER_LIBS);
621621
}
622622

623623
opal_info_out("Internal debug support", "option:debug", debug);

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ language=C++
1212
compiler_env=CXX
1313
compiler_flags_env=CXXFLAGS
1414
compiler=@CXX@
15-
preprocessor_flags=@OMPI_WRAPPER_EXTRA_CPPFLAGS@
16-
compiler_flags_prefix=@OMPI_WRAPPER_EXTRA_CXXFLAGS_PREFIX@
17-
compiler_flags=@OMPI_WRAPPER_EXTRA_CXXFLAGS@
18-
linker_flags=@OMPI_WRAPPER_EXTRA_LDFLAGS@
19-
# Note that per https://svn.open-mpi.org/trac/ompi/ticket/3422, we
20-
# intentionally only link in the MPI libraries (OPAL, etc. are
21-
# pulled in implicitly) because we intend MPI applications to only use
22-
# the MPI API.
23-
libs=@OMPI_WRAPPER_CXX_LIB@ -l@OMPI_LIBMPI_NAME@
24-
libs_static=@OMPI_WRAPPER_CXX_LIB@ -l@OMPI_LIBMPI_NAME@ -l@OPAL_LIB_NAME@ @OMPI_WRAPPER_EXTRA_LIBS@
15+
preprocessor_flags=@OMPI_WRAPPER_CPPFLAGS@
16+
compiler_flags_prefix=@OMPI_WRAPPER_CXXFLAGS_PREFIX@
17+
compiler_flags=@OMPI_WRAPPER_CXXFLAGS@
18+
linker_flags=@OMPI_WRAPPER_LDFLAGS@
19+
linker_flags_static=@OMPI_WRAPPER_LDFLAGS_STATIC@
20+
libs=@OMPI_WRAPPER_LIBS@
21+
libs_static=@OMPI_WRAPPER_LIBS_STATIC@
2522
dyn_lib_file=lib@OMPI_LIBMPI_NAME@.@OPAL_DYN_LIB_SUFFIX@
2623
static_lib_file=lib@[email protected]
2724
required_file=@OMPI_WRAPPER_CXX_REQUIRED_FILE@

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,13 @@ language=C
1212
compiler_env=CC
1313
compiler_flags_env=CFLAGS
1414
compiler=@WRAPPER_CC@
15-
preprocessor_flags=@OMPI_WRAPPER_EXTRA_CPPFLAGS@
16-
compiler_flags_prefix=@OMPI_WRAPPER_EXTRA_CFLAGS_PREFIX@
17-
compiler_flags=@OMPI_WRAPPER_EXTRA_CFLAGS@
18-
linker_flags=@OMPI_WRAPPER_EXTRA_LDFLAGS@
19-
# Note that per https://svn.open-mpi.org/trac/ompi/ticket/3422, we
20-
# intentionally only link in the MPI libraries (OPAL, etc. are
21-
# pulled in implicitly) because we intend MPI applications to only use
22-
# the MPI API.
23-
libs=-l@OMPI_LIBMPI_NAME@
24-
libs_static=-l@OMPI_LIBMPI_NAME@ -l@OPAL_LIB_NAME@ @OMPI_WRAPPER_EXTRA_LIBS@
15+
preprocessor_flags=@OMPI_WRAPPER_CPPFLAGS@
16+
compiler_flags_prefix=@OMPI_WRAPPER_CFLAGS_PREFIX@
17+
compiler_flags=@OMPI_WRAPPER_CFLAGS@
18+
linker_flags=@OMPI_WRAPPER_LDFLAGS@
19+
linker_flags_static=@OMPI_WRAPPER_LDFLAGS_STATIC@
20+
libs=@OMPI_WRAPPER_LIBS@
21+
libs_static=@OMPI_WRAPPER_LIBS_STATIC@
2522
dyn_lib_file=lib@OMPI_LIBMPI_NAME@.@OPAL_DYN_LIB_SUFFIX@
2623
static_lib_file=lib@[email protected]
2724
required_file=

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@ compiler_env=FC
1313
compiler_flags_env=FCFLAGS
1414
compiler=@FC@
1515
preprocessor_flags=
16-
compiler_flags_prefix=@OMPI_WRAPPER_EXTRA_FCFLAGS_PREFIX@
17-
compiler_flags=@OMPI_WRAPPER_EXTRA_FCFLAGS@
18-
linker_flags=@OMPI_WRAPPER_EXTRA_FC_LDFLAGS@
19-
# Note that per https://svn.open-mpi.org/trac/ompi/ticket/3422, we
20-
# intentionally only link in the MPI libraries (OPAL, etc. are
21-
# pulled in implicitly) because we intend MPI applications to only use
22-
# the MPI API.
23-
libs=@OMPI_FORTRAN_USEMPIF08_LIB@ @OMPI_FORTRAN_USEMPI_LIB@ @OMPI_FORTRAN_MPIFH_LINK@ -l@OMPI_LIBMPI_NAME@
24-
libs_static=@OMPI_FORTRAN_USEMPIF08_LIB@ @OMPI_FORTRAN_USEMPI_LIB@ @OMPI_FORTRAN_MPIFH_LINK@ -l@OMPI_LIBMPI_NAME@ -l@OPAL_LIB_NAME@ @OMPI_WRAPPER_EXTRA_LIBS@
16+
compiler_flags_prefix=@OMPI_WRAPPER_FCFLAGS_PREFIX@
17+
compiler_flags=@OMPI_WRAPPER_FCFLAGS@
18+
linker_flags=@OMPI_WRAPPER_FC_LDFLAGS@
19+
linker_flags_static=@OMPI_WRAPPER_FC_LDFLAGS_STATIC@
20+
libs=@OMPI_WRAPPER_FC_LIBS@
21+
libs_static=@OMPI_WRAPPER_FC_LIBS_STATIC@
2522
dyn_lib_file=lib@OMPI_LIBMPI_NAME@.@OPAL_DYN_LIB_SUFFIX@
2623
static_lib_file=lib@[email protected]
2724
required_file=@OMPI_WRAPPER_FORTRAN_REQUIRED_FILE@

ompi/tools/wrappers/ompi-c.pc.in

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ exec_prefix=@exec_prefix@
1111
includedir=@includedir@
1212
libdir=@libdir@
1313
pkgincludedir=@opalincludedir@
14-
#
15-
# Note that -l@OPAL_LIB_NAME@ and all the EXTRA_LIBS are only necessary when
16-
# static linking, so only list these in Libs.private.
17-
#
18-
Libs: -L${libdir} @OMPI_PKG_CONFIG_LDFLAGS@ -l@OMPI_LIBMPI_NAME@
19-
Libs.private: -l@OPAL_LIB_NAME@ @OMPI_WRAPPER_EXTRA_LIBS@
20-
#
21-
Cflags: -I${includedir} @OMPI_WRAPPER_EXTRA_CPPFLAGS@ @OMPI_WRAPPER_EXTRA_CFLAGS@
14+
15+
Libs: @OMPI_PC_LIBS@
16+
Libs.private: @OMPI_PC_LIBS_PRIVATE@
17+
Cflags: @OMPI_PC_CFLAGS@
18+
Requires: @OMPI_PC_MODULES@
19+
Requires.private: @OMPI_PC_MODULES_PRIVATE@

ompi/tools/wrappers/ompi-cxx.pc.in

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ exec_prefix=@exec_prefix@
1111
includedir=@includedir@
1212
libdir=@libdir@
1313
pkgincludedir=@opalincludedir@
14-
#
15-
# Note that @OPAL_LIB_NAME@ and all the EXTRA_LIBS are only necessary when
16-
# static linking so only list these in Libs.private.
17-
#
18-
Libs: -L${libdir} @OMPI_PKG_CONFIG_LDFLAGS@ @OMPI_WRAPPER_CXX_LIB@ -l@OMPI_LIBMPI_NAME@
19-
Libs.private: -l@OPAL_LIB_NAME@ @OMPI_WRAPPER_EXTRA_LIBS@
20-
#
21-
Cflags: -I${includedir} @OMPI_WRAPPER_EXTRA_CPPFLAGS@ @OMPI_WRAPPER_EXTRA_CXXFLAGS@
14+
15+
Libs: @OMPI_PC_LIBS@
16+
Libs.private: @OMPI_PC_LIBS_PRIVATE@
17+
Cflags: @OMPI_PC_CFLAGS@
18+
Requires: @OMPI_PC_MODULES@
19+
Requires.private: @OMPI_PC_MODULES_PRIVATE@

ompi/tools/wrappers/ompi-fort.pc.in

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ exec_prefix=@exec_prefix@
1111
includedir=@includedir@
1212
libdir=@libdir@
1313
pkgincludedir=@opalincludedir@
14-
#
15-
# Note that -l@OPAL_LIB_NAME@ and all the EXTRA_LIBS are only necessary when
16-
# static linking (they're pulled in by libopen-rte.so's implicit
17-
# dependencies), so only list these in Libs.private.
18-
#
19-
Libs: -L${libdir} @OMPI_PKG_CONFIG_LDFLAGS@ @OMPI_FORTRAN_USEMPIF08_LIB@ @OMPI_FORTRAN_USEMPI_LIB@ @OMPI_FORTRAN_MPIFH_LINK@ -l@OMPI_LIBMPI_NAME@
20-
Libs.private: -l@OPAL_LIB_NAME@ @OMPI_WRAPPER_EXTRA_LIBS@
21-
Cflags: -I${includedir} @OMPI_WRAPPER_EXTRA_CPPFLAGS@ @OMPI_WRAPPER_EXTRA_FCFLAGS@
14+
15+
Libs: @OMPI_PC_FC_LIBS@
16+
Libs.private: @OMPI_PC_FC_LIBS_PRIVATE@
17+
Cflags: @OMPI_PC_FC_CFLAGS@
18+
Requires: @OMPI_PC_MODULES@
19+
Requires.private: @OMPI_PC_MODULES_PRIVATE@

ompi/tools/wrappers/ompi.pc.in

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,9 @@ exec_prefix=@exec_prefix@
1111
includedir=@includedir@
1212
libdir=@libdir@
1313
pkgincludedir=@opalincludedir@
14-
#
15-
# Note that @OPAL_LIB_NAME@ and all the EXTRA_LIBS are only necessary when
16-
# static linking (they're pulled in by libopen-rte.so's implicit
17-
# dependencies), so only list these in Libs.private.
18-
#
19-
Libs: -L${libdir} @OMPI_PKG_CONFIG_LDFLAGS@ -l@OMPI_LIBMPI_NAME@
20-
Libs.private: -l@OPAL_LIB_NAME@ @OMPI_WRAPPER_EXTRA_LIBS@
21-
#
22-
Cflags: -I${includedir} @OMPI_WRAPPER_EXTRA_CPPFLAGS@ @OMPI_WRAPPER_EXTRA_CFLAGS@
14+
15+
Libs: @OMPI_PC_LIBS@
16+
Libs.private: @OMPI_PC_LIBS_PRIVATE@
17+
Cflags: @OMPI_PC_CFLAGS@
18+
Requires: @OMPI_PC_MODULES@
19+
Requires.private: @OMPI_PC_MODULES_PRIVATE@

0 commit comments

Comments
 (0)