Skip to content

Commit 851ace6

Browse files
authored
Merge pull request #10165 from bwbarrett/cleanup/introduce-oac_check_package
Fix static builds on main
2 parents adeb97d + 6ebef9a commit 851ace6

32 files changed

+2109
-947
lines changed

config/oac_check_package.m4

Lines changed: 695 additions & 0 deletions
Large diffs are not rendered by default.

config/ompi_setup_prrte.m4

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ dnl
3838
dnl A Makefile conditional OMPI_WANT_PRRTE will be defined based on the
3939
dnl results of the build.
4040
AC_DEFUN([OMPI_SETUP_PRRTE],[
41-
OPAL_VAR_SCOPE_PUSH([prrte_setup_internal_happy prrte_setup_external_happy prrte_setup_success_var])
41+
OPAL_VAR_SCOPE_PUSH([prrte_setup_internal_happy prrte_setup_external_happy])
4242
4343
opal_show_subtitle "Configuring PRRTE"
4444
@@ -117,7 +117,7 @@ dnl _OMPI_SETUP_PRRTE_INTERNAL([action-if-success], [action-if-not-success])
117117
dnl
118118
dnl Attempt to configure the built-in PRRTE.
119119
AC_DEFUN([_OMPI_SETUP_PRRTE_INTERNAL], [
120-
OPAL_VAR_SCOPE_PUSH([internal_prrte_args internal_prrte_extra_libs internal_prrte_happy deprecated_prefix_by_default print_prrte_warning internal_prrte_CPPFLAGS])
120+
OPAL_VAR_SCOPE_PUSH([internal_prrte_args internal_prrte_happy deprecated_prefix_by_default print_prrte_warning internal_prrte_CPPFLAGS opal_prrte_CPPFLAGS_save])
121121
122122
# This is really a PRTE option that should not be in Open MPI, but
123123
# there is not a great way to support the orterun/mpirun checks
@@ -163,18 +163,21 @@ AC_DEFUN([_OMPI_SETUP_PRRTE_INTERNAL], [
163163
164164
AS_IF([test "$opal_libevent_mode" = "internal"],
165165
[internal_prrte_args="$internal_prrte_args --with-libevent --disable-libevent-lib-checks"
166-
internal_prrte_args="$internal_prrte_args --with-libevent-extra-libs=\"$opal_libevent_LIBS\""
167-
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_libevent_CPPFLAGS"])
166+
internal_prrte_args="$internal_prrte_args --with-libevent-extra-libs=\"$opal_libevent_BUILD_LIBS\""
167+
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_libevent_BUILD_CPPFLAGS"])
168168
169169
AS_IF([test "$opal_hwloc_mode" = "internal"],
170170
[internal_prrte_args="$internal_prrte_args --disable-hwloc-lib-checks"
171-
internal_prrte_args="$internal_prrte_args --with-hwloc-extra-libs=\"$opal_hwloc_LIBS\""
172-
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_hwloc_CPPFLAGS"])
171+
internal_prrte_args="$internal_prrte_args --with-hwloc-extra-libs=\"$opal_hwloc_BUILD_LIBS\""
172+
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_hwloc_BUILD_CPPFLAGS"])
173173
174174
AS_IF([test "$opal_pmix_mode" = "internal"],
175175
[internal_prrte_args="$internal_prrte_args --disable-pmix-lib-checks"
176-
internal_prrte_args="$internal_prrte_args --with-pmix-extra-libs=\"$opal_pmix_LIBS\""
177-
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_pmix_CPPFLAGS"])
176+
internal_prrte_args="$internal_prrte_args --with-pmix-extra-libs=\"$opal_pmix_BUILD_LIBS\""
177+
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_pmix_BUILD_CPPFLAGS"])
178+
179+
opal_prrte_CPPFLAGS_save="${CPPFLAGS}"
180+
OPAL_FLAGS_APPEND_UNIQ([CPPFLAGS], [${opal_pmix_CPPFLAGS}])
178181
179182
AC_MSG_CHECKING([if PMIx version is 4.0.0 or greater])
180183
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pmix_version.h>]],
@@ -193,6 +196,8 @@ AC_DEFUN([_OMPI_SETUP_PRRTE_INTERNAL], [
193196
AC_MSG_WARN([--without-prrte option.])
194197
AC_MSG_ERROR([Cannot continue])])
195198
199+
CPPFLAGS="${opal_prrte_CPPFLAGS_save}"
200+
196201
AS_IF([test "$with_ft" != "no"],
197202
[internal_prrte_args="--enable-prte-ft $internal_prrte_args"],
198203
[])
@@ -249,23 +254,25 @@ AC_DEFUN([_OMPI_SETUP_PRRTE_EXTERNAL], [
249254
250255
opal_prrte_CPPFLAGS_save=$CPPFLAGS
251256
252-
_OPAL_CHECK_PACKAGE_HEADER([opal_prrte], [prte.h], [$with_prrte],
253-
[setup_prrte_external_happy=yes],
254-
[setup_prrte_external_happy=no])
257+
AS_IF([test -n "${with_prrte}" -a "${with_prrte}" != "yes" -a "${with_prrte}" != "no"],
258+
[OPAL_FLAGS_APPEND_UNIQ([CPPFLAGS], ["-I${with_prrte}/include"])])
255259
256-
CPPFLAGS="$opal_prrte_CPPFLAGS_save $opal_prrte_CPPFLAGS"
260+
AC_CHECK_HEADER([prte.h], [setup_prrte_external_happy=yes],
261+
[setup_prrte_external_happy=no])
257262
258-
AC_MSG_CHECKING([if external PRRTE version is 2.0.0 or greater])
259-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <prte_version.h>]],
260-
[[
263+
AS_IF([test "${setup_prrte_external_happy}" = "yes"],
264+
[AC_CACHE_CHECK([if external PRRTE version is 2.0.0 or greater],
265+
[ompi_setup_prrte_cv_version_happy],
266+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <prte_version.h>
267+
]], [[
261268
#if PRTE_NUMERIC_VERSION < 0x00020000
262269
#error "prrte API version is less than 2.0.0"
263270
#endif
264271
]])],
265-
[AC_MSG_RESULT([yes])
266-
setup_prrte_external_happy=yes],
267-
[AC_MSG_RESULT([no])
268-
setup_prrte_external_happy=no])
272+
[ompi_setup_prrte_cv_version_happy="yes"],
273+
[ompi_setup_prrte_cv_version_happy="no"])])
274+
AS_IF([test "${ompi_setup_prrte_cv_version_happy}" = "no"],
275+
[setup_prrte_external_happy="no"])])
269276
270277
CPPFLAGS="$opal_prrte_CPPFLAGS_save"
271278

config/opal_check_libnl.m4

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ dnl
33
dnl Copyright (c) 2015-2017 Research Organization for Information Science
44
dnl and Technology (RIST). All rights reserved.
55
dnl Copyright (c) 2017 Cisco Systems, Inc. All rights reserved.
6+
dnl Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
67
dnl $COPYRIGHT$
78
dnl
89
dnl Additional copyrights may follow
@@ -66,6 +67,8 @@ AC_DEFUN([OPAL_LIBNL_SANITY_INIT], [
6667
opal_libnl_location=$with_libnl
6768
;;
6869
esac
70+
71+
OAC_CHECK_PACKAGE_VERIFY_COMMANDS([[OPAL_LIBNL_CHECK_PACKAGE_CALLBACK]])
6972
])
7073

7174
dnl OPAL_LIBNL_SANITY_FAIL_MSG(lib)
@@ -79,6 +82,28 @@ AC_DEFUN([OPAL_LIBNL_SANITY_FAIL_MSG], [
7982
AC_MSG_WARN([Open MPI will therefore skip using lib$1.])
8083
])
8184

85+
dnl OPAL_LIBNL_CHECK_PACKAGE_CALLBACK(package name, prefix,
86+
dnl headers, function name,
87+
dnl action if happy, action if not happy)
88+
dnl
89+
dnl Callback from OAC_CHECK_PACKAGE to verify that there is
90+
dnl not a conflict. Note that CPPFLAGS, LDFLAGS, and LIBS
91+
dnl are setup to compile/link package.
92+
AC_DEFUN([OPAL_LIBNL_CHECK_PACKAGE_CALLBACK], [
93+
OPAL_VAR_SCOPE_PUSH([opal_libnl_sane])
94+
opal_libnl_sane=1
95+
case $host in
96+
*linux*)
97+
OPAL_LIBNL_SANITY_CHECK_LINUX([$1], [$4], [], [opal_libnl_sane])
98+
;;
99+
esac
100+
101+
AS_IF([test ${opal_libnl_sane} -eq 1],
102+
[$5], [$6])
103+
104+
OPAL_VAR_SCOPE_POP([opal_libnl_sane])
105+
])
106+
82107
dnl OPAL_LIBNL_SANITY_CHECK(lib, function, LIBS, libnl_check_ok)
83108
dnl
84109
dnl This macro is invoked from OPAL_CHECK_PACKAGE to make sure that
@@ -101,7 +126,7 @@ AC_DEFUN([OPAL_LIBNL_SANITY_CHECK], [
101126
opal_libnl_sane=1
102127
case $host in
103128
*linux*)
104-
OPAL_LIBNL_SANITY_CHECK_LINUX($1, $2, $3, opal_libnl_sane)
129+
OPAL_LIBNL_SANITY_CHECK_LINUX([$1], [$2], [-l$1 $3], [opal_libnl_sane])
105130
;;
106131
esac
107132

@@ -111,40 +136,46 @@ AC_DEFUN([OPAL_LIBNL_SANITY_CHECK], [
111136

112137
dnl
113138
dnl Simple helper for OPAL_LIBNL_SANITY_CHECK
114-
dnl $1: library name
139+
dnl $1: package name
115140
dnl $2: function
116141
dnl $3: LIBS
117142
dnl $4: output variable (1=ok, 0=not ok)
118143
dnl
119144
AC_DEFUN([OPAL_LIBNL_SANITY_CHECK_LINUX], [
120145
OPAL_VAR_SCOPE_PUSH([this_requires_v1 libnl_sane this_requires_v3 ldd_output result_msg])
121146

122-
AC_LANG_PUSH(C)
147+
AS_VAR_PUSHDEF([libnl_check_lib], [opal_libnl_sanity_check_cv_$1])
123148

124-
AC_MSG_CHECKING([if lib$1 requires libnl v1 or v3])
125-
cat > conftest_c.$ac_ext << EOF
149+
AC_CACHE_CHECK([if $1 requires libnl v1 or v3],
150+
[libnl_check_lib],
151+
[AC_LANG_PUSH([C])
152+
cat > conftest_c.$ac_ext << EOF
126153
extern void $2 (void);
127154
int main(int argc, char *argv[[]]) {
128155
$2 ();
129156
return 0;
130157
}
131158
EOF
132159

160+
result_msg=
161+
OPAL_LOG_COMMAND([$CC -o conftest $CFLAGS $CPPFLAGS conftest_c.$ac_ext $LDFLAGS $LIBS $3],
162+
[ldd_output=`ldd conftest`
163+
AS_IF([echo $ldd_output | grep -q libnl-3.so],
164+
[result_msg="v3"])
165+
AS_IF([echo $ldd_output | grep -q libnl.so],
166+
[OPAL_APPEND([result_msg], ["v1"])])
167+
AS_IF([test -z "${result_msg}"], [result_msg="none"])],
168+
[AC_MSG_WARN([Could not link a simple program with lib $1])])
169+
AC_LANG_POP([C])
170+
AS_VAR_SET([libnl_check_lib], [${result_msg}])
171+
rm -f conftest conftest_c.$ac_ext])
172+
AS_VAR_COPY([result_msg], [libnl_check_lib])
133173
this_requires_v1=0
134174
this_requires_v3=0
135-
result_msg=
136-
OPAL_LOG_COMMAND([$CC -o conftest $CFLAGS $CPPFLAGS conftest_c.$ac_ext $LDFLAGS -l$1 $LIBS $3],
137-
[ldd_output=`ldd conftest`
138-
AS_IF([echo $ldd_output | grep -q libnl-3.so],
139-
[this_requires_v3=1
140-
result_msg="v3"])
141-
AS_IF([echo $ldd_output | grep -q libnl.so],
142-
[this_requires_v1=1
143-
result_msg="v1 $result_msg"])
144-
AC_MSG_RESULT([$result_msg])
145-
],
146-
[AC_MSG_WARN([Could not link a simple program with lib $1])
147-
])
175+
AS_IF([echo "${result_msg}" | grep -q v1], [this_requires_v1=1])
176+
AS_IF([echo "${result_msg}" | grep -q v3], [this_requires_v3=1])
177+
178+
AS_VAR_POPDEF([libnl_check_lib])
148179

149180
# Assume that our configuration is sane; this may get reset below
150181
libnl_sane=1
@@ -156,7 +187,7 @@ EOF
156187

157188
# Does this library require both v1 and v3? If so, fail.
158189
AS_IF([test $this_requires_v1 -eq 1 && test $this_requires_v3 -eq 1],
159-
[AC_MSG_WARN([Unfortunately, lib$1 links to both libnl and libnl-3.])
190+
[AC_MSG_WARN([Unfortunately, $1 links to both libnl and libnl-3.])
160191
OPAL_LIBNL_SANITY_FAIL_MSG($1)
161192
libnl_sane=0])
162193

@@ -176,17 +207,14 @@ EOF
176207
# v1? If so, fail.
177208
AS_IF([test $libnl_sane -eq 1 && test $this_requires_v3 -eq 1],
178209
[AS_IF([test $opal_libnl_version -eq 1],
179-
[AC_MSG_WARN([libnl version conflict: $opal_libnlv1_libs requires libnl whereas lib$1 requires libnl-3])
210+
[AC_MSG_WARN([libnl version conflict: $opal_libnlv1_libs requires libnl whereas $1 requires libnl-3])
180211
OPAL_LIBNL_SANITY_FAIL_MSG($1)
181212
libnl_sane=0],
182213
[opal_libnlv3_libs="$opal_libnlv3_libs $1"
183214
OPAL_UNIQ([opal_libnlv3_libs])
184215
opal_libnl_version=3])
185216
])
186217

187-
AC_LANG_POP(C)
188-
rm -f conftest conftest_c.$ac_ext
189-
190218
$4=$libnl_sane
191219

192220
OPAL_VAR_SCOPE_POP([ldd_output libnl_sane this_requires_v1 this_requires_v3 result_msg])

config/opal_check_ofi.m4

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,19 +136,22 @@ AC_DEFUN([_OPAL_CHECK_OFI],[
136136
[$opal_check_fi_info_pci],
137137
[check if pci data is available in ofi])
138138

139-
AC_CHECK_DECLS([PMIX_PACKAGE_RANK],
140-
[],
141-
[],
142-
[#include <pmix.h>])
143-
144139
AC_CHECK_DECLS([FI_OPT_FI_HMEM_P2P],
145140
[], [],
146141
[#include <rdma/fi_endpoint.h>])
147142

148143
AC_CHECK_TYPES([struct fi_ops_mem_monitor], [], [],
149144
[#ifdef HAVE_RDMA_FI_EXT_H
150145
#include <rdma/fi_ext.h>
151-
#endif])])
146+
#endif
147+
])
148+
149+
OPAL_FLAGS_APPEND_UNIQ([CPPFLAGS], [${opal_pmix_CPPFLAGS}])
150+
151+
AC_CHECK_DECLS([PMIX_PACKAGE_RANK],
152+
[],
153+
[],
154+
[#include <pmix.h>])])
152155

153156
CPPFLAGS=$opal_check_ofi_save_CPPFLAGS
154157
LDFLAGS=$opal_check_ofi_save_LDFLAGS

config/opal_check_pc.m4

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)