Skip to content

Commit

Permalink
Merge pull request #10165 from bwbarrett/cleanup/introduce-oac_check_…
Browse files Browse the repository at this point in the history
…package

Fix static builds on main
  • Loading branch information
bwbarrett authored Apr 1, 2022
2 parents adeb97d + 6ebef9a commit 851ace6
Show file tree
Hide file tree
Showing 32 changed files with 2,109 additions and 947 deletions.
695 changes: 695 additions & 0 deletions config/oac_check_package.m4

Large diffs are not rendered by default.

45 changes: 26 additions & 19 deletions config/ompi_setup_prrte.m4
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dnl
dnl A Makefile conditional OMPI_WANT_PRRTE will be defined based on the
dnl results of the build.
AC_DEFUN([OMPI_SETUP_PRRTE],[
OPAL_VAR_SCOPE_PUSH([prrte_setup_internal_happy prrte_setup_external_happy prrte_setup_success_var])
OPAL_VAR_SCOPE_PUSH([prrte_setup_internal_happy prrte_setup_external_happy])
opal_show_subtitle "Configuring PRRTE"
Expand Down Expand Up @@ -117,7 +117,7 @@ dnl _OMPI_SETUP_PRRTE_INTERNAL([action-if-success], [action-if-not-success])
dnl
dnl Attempt to configure the built-in PRRTE.
AC_DEFUN([_OMPI_SETUP_PRRTE_INTERNAL], [
OPAL_VAR_SCOPE_PUSH([internal_prrte_args internal_prrte_extra_libs internal_prrte_happy deprecated_prefix_by_default print_prrte_warning internal_prrte_CPPFLAGS])
OPAL_VAR_SCOPE_PUSH([internal_prrte_args internal_prrte_happy deprecated_prefix_by_default print_prrte_warning internal_prrte_CPPFLAGS opal_prrte_CPPFLAGS_save])
# This is really a PRTE option that should not be in Open MPI, but
# there is not a great way to support the orterun/mpirun checks
Expand Down Expand Up @@ -163,18 +163,21 @@ AC_DEFUN([_OMPI_SETUP_PRRTE_INTERNAL], [
AS_IF([test "$opal_libevent_mode" = "internal"],
[internal_prrte_args="$internal_prrte_args --with-libevent --disable-libevent-lib-checks"
internal_prrte_args="$internal_prrte_args --with-libevent-extra-libs=\"$opal_libevent_LIBS\""
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_libevent_CPPFLAGS"])
internal_prrte_args="$internal_prrte_args --with-libevent-extra-libs=\"$opal_libevent_BUILD_LIBS\""
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_libevent_BUILD_CPPFLAGS"])
AS_IF([test "$opal_hwloc_mode" = "internal"],
[internal_prrte_args="$internal_prrte_args --disable-hwloc-lib-checks"
internal_prrte_args="$internal_prrte_args --with-hwloc-extra-libs=\"$opal_hwloc_LIBS\""
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_hwloc_CPPFLAGS"])
internal_prrte_args="$internal_prrte_args --with-hwloc-extra-libs=\"$opal_hwloc_BUILD_LIBS\""
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_hwloc_BUILD_CPPFLAGS"])
AS_IF([test "$opal_pmix_mode" = "internal"],
[internal_prrte_args="$internal_prrte_args --disable-pmix-lib-checks"
internal_prrte_args="$internal_prrte_args --with-pmix-extra-libs=\"$opal_pmix_LIBS\""
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_pmix_CPPFLAGS"])
internal_prrte_args="$internal_prrte_args --with-pmix-extra-libs=\"$opal_pmix_BUILD_LIBS\""
internal_prrte_CPPFLAGS="$internal_prrte_CPPFLAGS $opal_pmix_BUILD_CPPFLAGS"])
opal_prrte_CPPFLAGS_save="${CPPFLAGS}"
OPAL_FLAGS_APPEND_UNIQ([CPPFLAGS], [${opal_pmix_CPPFLAGS}])
AC_MSG_CHECKING([if PMIx version is 4.0.0 or greater])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <pmix_version.h>]],
Expand All @@ -193,6 +196,8 @@ AC_DEFUN([_OMPI_SETUP_PRRTE_INTERNAL], [
AC_MSG_WARN([--without-prrte option.])
AC_MSG_ERROR([Cannot continue])])
CPPFLAGS="${opal_prrte_CPPFLAGS_save}"
AS_IF([test "$with_ft" != "no"],
[internal_prrte_args="--enable-prte-ft $internal_prrte_args"],
[])
Expand Down Expand Up @@ -249,23 +254,25 @@ AC_DEFUN([_OMPI_SETUP_PRRTE_EXTERNAL], [
opal_prrte_CPPFLAGS_save=$CPPFLAGS
_OPAL_CHECK_PACKAGE_HEADER([opal_prrte], [prte.h], [$with_prrte],
[setup_prrte_external_happy=yes],
[setup_prrte_external_happy=no])
AS_IF([test -n "${with_prrte}" -a "${with_prrte}" != "yes" -a "${with_prrte}" != "no"],
[OPAL_FLAGS_APPEND_UNIQ([CPPFLAGS], ["-I${with_prrte}/include"])])
CPPFLAGS="$opal_prrte_CPPFLAGS_save $opal_prrte_CPPFLAGS"
AC_CHECK_HEADER([prte.h], [setup_prrte_external_happy=yes],
[setup_prrte_external_happy=no])
AC_MSG_CHECKING([if external PRRTE version is 2.0.0 or greater])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <prte_version.h>]],
[[
AS_IF([test "${setup_prrte_external_happy}" = "yes"],
[AC_CACHE_CHECK([if external PRRTE version is 2.0.0 or greater],
[ompi_setup_prrte_cv_version_happy],
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <prte_version.h>
]], [[
#if PRTE_NUMERIC_VERSION < 0x00020000
#error "prrte API version is less than 2.0.0"
#endif
]])],
[AC_MSG_RESULT([yes])
setup_prrte_external_happy=yes],
[AC_MSG_RESULT([no])
setup_prrte_external_happy=no])
[ompi_setup_prrte_cv_version_happy="yes"],
[ompi_setup_prrte_cv_version_happy="no"])])
AS_IF([test "${ompi_setup_prrte_cv_version_happy}" = "no"],
[setup_prrte_external_happy="no"])])
CPPFLAGS="$opal_prrte_CPPFLAGS_save"
Expand Down
74 changes: 51 additions & 23 deletions config/opal_check_libnl.m4
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dnl
dnl Copyright (c) 2015-2017 Research Organization for Information Science
dnl and Technology (RIST). All rights reserved.
dnl Copyright (c) 2017 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
Expand Down Expand Up @@ -66,6 +67,8 @@ AC_DEFUN([OPAL_LIBNL_SANITY_INIT], [
opal_libnl_location=$with_libnl
;;
esac

OAC_CHECK_PACKAGE_VERIFY_COMMANDS([[OPAL_LIBNL_CHECK_PACKAGE_CALLBACK]])
])

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

dnl OPAL_LIBNL_CHECK_PACKAGE_CALLBACK(package name, prefix,
dnl headers, function name,
dnl action if happy, action if not happy)
dnl
dnl Callback from OAC_CHECK_PACKAGE to verify that there is
dnl not a conflict. Note that CPPFLAGS, LDFLAGS, and LIBS
dnl are setup to compile/link package.
AC_DEFUN([OPAL_LIBNL_CHECK_PACKAGE_CALLBACK], [
OPAL_VAR_SCOPE_PUSH([opal_libnl_sane])
opal_libnl_sane=1
case $host in
*linux*)
OPAL_LIBNL_SANITY_CHECK_LINUX([$1], [$4], [], [opal_libnl_sane])
;;
esac

AS_IF([test ${opal_libnl_sane} -eq 1],
[$5], [$6])

OPAL_VAR_SCOPE_POP([opal_libnl_sane])
])

dnl OPAL_LIBNL_SANITY_CHECK(lib, function, LIBS, libnl_check_ok)
dnl
dnl This macro is invoked from OPAL_CHECK_PACKAGE to make sure that
Expand All @@ -101,7 +126,7 @@ AC_DEFUN([OPAL_LIBNL_SANITY_CHECK], [
opal_libnl_sane=1
case $host in
*linux*)
OPAL_LIBNL_SANITY_CHECK_LINUX($1, $2, $3, opal_libnl_sane)
OPAL_LIBNL_SANITY_CHECK_LINUX([$1], [$2], [-l$1 $3], [opal_libnl_sane])
;;
esac

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

dnl
dnl Simple helper for OPAL_LIBNL_SANITY_CHECK
dnl $1: library name
dnl $1: package name
dnl $2: function
dnl $3: LIBS
dnl $4: output variable (1=ok, 0=not ok)
dnl
AC_DEFUN([OPAL_LIBNL_SANITY_CHECK_LINUX], [
OPAL_VAR_SCOPE_PUSH([this_requires_v1 libnl_sane this_requires_v3 ldd_output result_msg])

AC_LANG_PUSH(C)
AS_VAR_PUSHDEF([libnl_check_lib], [opal_libnl_sanity_check_cv_$1])

AC_MSG_CHECKING([if lib$1 requires libnl v1 or v3])
cat > conftest_c.$ac_ext << EOF
AC_CACHE_CHECK([if $1 requires libnl v1 or v3],
[libnl_check_lib],
[AC_LANG_PUSH([C])
cat > conftest_c.$ac_ext << EOF
extern void $2 (void);
int main(int argc, char *argv[[]]) {
$2 ();
return 0;
}
EOF

result_msg=
OPAL_LOG_COMMAND([$CC -o conftest $CFLAGS $CPPFLAGS conftest_c.$ac_ext $LDFLAGS $LIBS $3],
[ldd_output=`ldd conftest`
AS_IF([echo $ldd_output | grep -q libnl-3.so],
[result_msg="v3"])
AS_IF([echo $ldd_output | grep -q libnl.so],
[OPAL_APPEND([result_msg], ["v1"])])
AS_IF([test -z "${result_msg}"], [result_msg="none"])],
[AC_MSG_WARN([Could not link a simple program with lib $1])])
AC_LANG_POP([C])
AS_VAR_SET([libnl_check_lib], [${result_msg}])
rm -f conftest conftest_c.$ac_ext])
AS_VAR_COPY([result_msg], [libnl_check_lib])
this_requires_v1=0
this_requires_v3=0
result_msg=
OPAL_LOG_COMMAND([$CC -o conftest $CFLAGS $CPPFLAGS conftest_c.$ac_ext $LDFLAGS -l$1 $LIBS $3],
[ldd_output=`ldd conftest`
AS_IF([echo $ldd_output | grep -q libnl-3.so],
[this_requires_v3=1
result_msg="v3"])
AS_IF([echo $ldd_output | grep -q libnl.so],
[this_requires_v1=1
result_msg="v1 $result_msg"])
AC_MSG_RESULT([$result_msg])
],
[AC_MSG_WARN([Could not link a simple program with lib $1])
])
AS_IF([echo "${result_msg}" | grep -q v1], [this_requires_v1=1])
AS_IF([echo "${result_msg}" | grep -q v3], [this_requires_v3=1])

AS_VAR_POPDEF([libnl_check_lib])

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

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

Expand All @@ -176,17 +207,14 @@ EOF
# v1? If so, fail.
AS_IF([test $libnl_sane -eq 1 && test $this_requires_v3 -eq 1],
[AS_IF([test $opal_libnl_version -eq 1],
[AC_MSG_WARN([libnl version conflict: $opal_libnlv1_libs requires libnl whereas lib$1 requires libnl-3])
[AC_MSG_WARN([libnl version conflict: $opal_libnlv1_libs requires libnl whereas $1 requires libnl-3])
OPAL_LIBNL_SANITY_FAIL_MSG($1)
libnl_sane=0],
[opal_libnlv3_libs="$opal_libnlv3_libs $1"
OPAL_UNIQ([opal_libnlv3_libs])
opal_libnl_version=3])
])

AC_LANG_POP(C)
rm -f conftest conftest_c.$ac_ext

$4=$libnl_sane

OPAL_VAR_SCOPE_POP([ldd_output libnl_sane this_requires_v1 this_requires_v3 result_msg])
Expand Down
15 changes: 9 additions & 6 deletions config/opal_check_ofi.m4
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,22 @@ AC_DEFUN([_OPAL_CHECK_OFI],[
[$opal_check_fi_info_pci],
[check if pci data is available in ofi])

AC_CHECK_DECLS([PMIX_PACKAGE_RANK],
[],
[],
[#include <pmix.h>])

AC_CHECK_DECLS([FI_OPT_FI_HMEM_P2P],
[], [],
[#include <rdma/fi_endpoint.h>])

AC_CHECK_TYPES([struct fi_ops_mem_monitor], [], [],
[#ifdef HAVE_RDMA_FI_EXT_H
#include <rdma/fi_ext.h>
#endif])])
#endif
])

OPAL_FLAGS_APPEND_UNIQ([CPPFLAGS], [${opal_pmix_CPPFLAGS}])

AC_CHECK_DECLS([PMIX_PACKAGE_RANK],
[],
[],
[#include <pmix.h>])])

CPPFLAGS=$opal_check_ofi_save_CPPFLAGS
LDFLAGS=$opal_check_ofi_save_LDFLAGS
Expand Down
72 changes: 0 additions & 72 deletions config/opal_check_pc.m4

This file was deleted.

Loading

0 comments on commit 851ace6

Please sign in to comment.