Skip to content

Commit

Permalink
Make checking min versions consistent
Browse files Browse the repository at this point in the history
We have three dependent libraries we care about, and
minimum version requirements on all of them. Let's
connect them all to the min values in the VERSION file
and "standardize" the check configure code to make it
easier to understand and maintain.

Also, since we require a min HWLOC version of 1.11, there
is no longer a need to check for at least 1.8 so we know
we have hwloc_topology_dup.

Signed-off-by: Ralph Castain <rhc@pmix.org>
(cherry picked from commit 511e333)
  • Loading branch information
rhc54 committed Oct 4, 2023
1 parent 940ea49 commit 1995563
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 87 deletions.
57 changes: 57 additions & 0 deletions autogen.pl
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,61 @@ sub patch_autotools_output {
unlink("configure.patched");
}

sub export_version {
my ($name,$version) = @_;
$version =~ s/[^a-zA-Z0-9,.]//g;
my @version_splits = split(/\./,$version);
my $hex = sprintf("0x%04x%02x%02x", $version_splits[0], $version_splits[1], $version_splits[2]);
$m4 .= "m4_define([PRTE_${name}_MIN_VERSION], [$version])\n";
$m4 .= "m4_define([PRTE_${name}_NUMERIC_MIN_VERSION], [$hex])\n";
}

sub get_and_define_min_versions() {

open(IN, "VERSION") || my_die "Can't open VERSION";
while (<IN>) {
my $line = $_;
my @fields = split(/=/,$line);
if ($fields[0] eq "automake_min_version") {
if ($fields[1] ne "\n") {
$prte_automake_version = $fields[1];
}
}
elsif($fields[0] eq "autoconf_min_version") {
if ($fields[1] ne "\n") {
$prte_autoconf_version = $fields[1];
}
}
elsif($fields[0] eq "libtool_min_version") {
if ($fields[1] ne "\n") {
$prte_libtool_version = $fields[1];
}
}
elsif($fields[0] eq "pmix_min_version") {
if ($fields[1] ne "\n") {
export_version("PMIX", $fields[1]);
}
}
elsif($fields[0] eq "hwloc_min_version") {
if ($fields[1] ne "\n") {
export_version("HWLOC", $fields[1]);
}
}
elsif($fields[0] eq "event_min_version") {
if ($fields[1] ne "\n") {
export_version("EVENT", $fields[1]);
}
}
elsif($fields[0] eq "flex_min_version") {
if ($fields[1] ne "\n") {
export_version("FLEX", $fields[1]);
}
}
}
close(IN);
}


##############################################################################

sub in_tarball {
Expand Down Expand Up @@ -911,6 +966,8 @@ sub replace_config_sub_guess {
$step. Checking tool versions\n\n";

get_and_define_min_versions();

# Check the autotools revision levels
&find_and_check("autoconf", $prte_autoconf_search, $prte_autoconf_version);
&find_and_check("libtool", $prte_libtoolize_search, $prte_libtool_version);
Expand Down
89 changes: 27 additions & 62 deletions config/prte_setup_hwloc.m4
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ AC_DEFUN([PRTE_SETUP_HWLOC],[
prte_check_hwloc_save_CPPFLAGS="$CPPFLAGS"
prte_check_hwloc_save_LDFLAGS="$LDFLAGS"
prte_check_hwloc_save_LIBS="$LIBS"
prte_have_topology_dup=0

if test "$with_hwloc" = "no"; then
AC_MSG_WARN([PRRTE requires HWLOC topology library support.])
Expand Down Expand Up @@ -64,74 +63,40 @@ AC_DEFUN([PRTE_SETUP_HWLOC],[
AC_MSG_ERROR([Cannot continue.])
fi

# update global flags to test for HWLOC version
PRTE_FLAGS_PREPEND_UNIQ([CPPFLAGS], [$prte_hwloc_CPPFLAGS])
PRTE_FLAGS_PREPEND_UNIQ([LDFLAGS], [$prte_hwloc_LDFLAGS])
PRTE_FLAGS_PREPEND_UNIQ([LIBS], [$prte_hwloc_LIBS])

AC_MSG_CHECKING([if hwloc version is 1.5 or greater])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([#include <hwloc.h>],
[[
#if HWLOC_API_VERSION < 0x00010500
#error "hwloc version is less than 0x00010500"
#endif
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([Cannot continue])])

AC_MSG_CHECKING([if hwloc version is 1.8 or greater])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([#include <hwloc.h>],
[[
#if HWLOC_API_VERSION < 0x00010800
#error "hwloc version is less than 0x00010800"
#endif
]])],
[AC_MSG_RESULT([yes])
prte_have_topology_dup=1],
[AC_MSG_RESULT([no])])

AC_MSG_CHECKING([if hwloc version is at least 2.0])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([#include <hwloc.h>],
[[
#if HWLOC_VERSION_MAJOR < 2
#error "hwloc version is less than 2.0"
#endif
]])],
[AC_MSG_RESULT([yes])
prte_version_high=1],
[AC_MSG_RESULT([no])
prte_version_high=0])
# NOTE: We have already read PRRTE's VERSION file, so we can use
# those values
prte_hwloc_min_num_version=PRTE_HWLOC_NUMERIC_MIN_VERSION
prte_hwloc_min_version=PRTE_HWLOC_MIN_VERSION
AC_MSG_CHECKING([version at or above v$prte_hwloc_min_version])
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
#include <hwloc.h>
#if (HWLOC_API_VERSION < $prte_hwloc_min_num_version)
#error "not version $prte_hwloc_min_num_version or above"
#endif
], [])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT(no)
AC_MSG_WARN([PRRTE requires HWLOC v$prte_hwloc_min_version or above.])
AC_MSG_ERROR([Please select a supported version and configure again])])

AC_MSG_CHECKING([if hwloc version is greater than 2.x])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([#include <hwloc.h>],
[[
#if HWLOC_VERSION_MAJOR > 2
#error "hwloc version is greater than 2.x"
#endif
]])],
[AC_MSG_RESULT([no])],
[AC_MSG_RESULT([yes])
AC_MSG_WARN([This PRRTE version does not support HWLOC])
AC_MSG_WARN([versions 3.x or higher. Please direct us])
AC_MSG_WARN([to an HWLOC version in the 1.11-2.x range.])
AC_MSG_ERROR([Cannot continue])])

CPPFLAGS=$prte_check_hwloc_save_CPPFLAGS
LDFLAGS=$prte_check_hwloc_save_LDFLAGS
LIBS=$prte_check_hwloc_save_LIBS
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
#include <hwloc.h>
#if (HWLOC_VERSION_MAJOR > 2)
#error "hwloc version is greater than 2.x"
#endif
], [])],
[AC_MSG_RESULT([no])],
[AC_MSG_RESULT([yes])
AC_MSG_WARN([This PRRTE version does not support HWLOC])
AC_MSG_WARN([versions 3.x or higher. Please direct us])
AC_MSG_WARN([to an HWLOC version in the $prte_hwloc_min_version-2.x range.])
AC_MSG_ERROR([Cannot continue])])

PRTE_FLAGS_APPEND_UNIQ([PRTE_FINAL_CPPFLAGS], [$prte_hwloc_CPPFLAGS])
PRTE_FLAGS_APPEND_UNIQ([PRTE_FINAL_LDFLAGS], [$prte_hwloc_LDFLAGS])
PRTE_FLAGS_APPEND_UNIQ([PRTE_FINAL_LIBS], [$prte_hwloc_LIBS])

AC_DEFINE_UNQUOTED([PRTE_HAVE_HWLOC_TOPOLOGY_DUP], [$prte_have_topology_dup],
[Whether or not hwloc_topology_dup is available])

PRTE_SUMMARY_ADD([Required Packages], [HWLOC], [], [$prte_hwloc_SUMMARY])

PRTE_VAR_SCOPE_POP
Expand Down
34 changes: 19 additions & 15 deletions config/prte_setup_libevent.m4
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Copyright (c) 2017-2019 Research Organization for Information Science
# and Technology (RIST). All rights reserved.
# Copyright (c) 2020 IBM Corporation. All rights reserved.
# Copyright (c) 2021-2022 Nanook Consulting. All rights reserved.
# Copyright (c) 2021-2023 Nanook Consulting. All rights reserved.
# Copyright (c) 2021-2022 Amazon.com, Inc. or its affiliates.
# All Rights reserved.
# $COPYRIGHT$
Expand Down Expand Up @@ -134,20 +134,24 @@ AC_DEFUN([PRTE_LIBEVENT_CONFIG],[
fi

if test $prte_libevent_support -eq 1; then
# Pin the "oldest supported" version to 2.0.21
AC_MSG_CHECKING([if libevent version is 2.0.21 or greater])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <event2/event.h>]],
[[
#if defined(_EVENT_NUMERIC_VERSION) && _EVENT_NUMERIC_VERSION < 0x02001500
#error "libevent API version is less than 0x02001500"
#elif defined(EVENT__NUMERIC_VERSION) && EVENT__NUMERIC_VERSION < 0x02001500
#error "libevent API version is less than 0x02001500"
#endif
]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_WARN([libevent version is too old (2.0.21 or later required)])
prte_libevent_support=0])
prte_event_min_num_version=PRTE_EVENT_NUMERIC_MIN_VERSION
prte_event_min_version=PRTE_EVENT_MIN_VERSION
AC_MSG_CHECKING([version at or above v$prte_event_min_version])
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
#include <event2/event.h>
#if defined(_EVENT_NUMERIC_VERSION) && _EVENT_NUMERIC_VERSION < $prte_event_min_num_version
#error "libevent API version is less than $prte_event_min_version"
#elif defined(EVENT__NUMERIC_VERSION) && EVENT__NUMERIC_VERSION < $prte_event_min_num_version
#error "libevent API version is less than $prte_event_min_version"
#endif
], [])],
[prte_libevent_cv_version_check=yes
AC_MSG_RESULT([yes])],
[prte_libevent_cv_version_check=no
AC_MSG_RESULT([no])])
AS_IF([test "${prte_libevent_cv_version_check}" = "no"],
[AC_MSG_WARN([libevent version is too old ($prte_event_min_version or later required)])
prte_libevent_support=0])
fi

# restore global flags
Expand Down
16 changes: 6 additions & 10 deletions config/prte_setup_pmix.m4
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,18 @@ AC_DEFUN([PRTE_CHECK_PMIX],[
# the actual release series
# NOTE: We have already read PRRTE's VERSION file, so we can use
# $pmix_min_version.
AC_MSG_CHECKING([version at or above v$pmix_min_version])
# Convert a.b.c to hex for comparison to the PMIX_NUMERIC_VERSION
# C macro
pmix_min_major=`echo $pmix_min_version | cut -d. -f1`
pmix_min_minor=`echo $pmix_min_version | cut -d. -f2`
pmix_min_release=`echo $pmix_min_version | cut -d. -f3`
pmix_min_version_hex=`printf "0x%02x%02x%02x" $pmix_min_major $pmix_min_minor $pmix_min_release`
prte_pmix_min_num_version=PRTE_PMIX_NUMERIC_MIN_VERSION
prte_pmix_min_version=PRTE_PMIX_MIN_VERSION
AC_MSG_CHECKING([version at or above v$prte_pmix_min_version])
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
#include <pmix_version.h>
#if (PMIX_NUMERIC_VERSION < $pmix_min_version_hex)
#error "not version $pmix_min_version or above"
#if (PMIX_NUMERIC_VERSION < $prte_pmix_min_num_version)
#error "not version $prte_pmix_min_num_version or above"
#endif
], [])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT(no)
AC_MSG_WARN([PRRTE requires PMIx v$pmix_min_version or above.])
AC_MSG_WARN([PRRTE requires PMIx v$prte_pmix_min_num_version or above.])
AC_MSG_ERROR([Please select a supported version and configure again])])
AC_CHECK_HEADER([src/util/pmix_argv.h], [],
Expand Down

0 comments on commit 1995563

Please sign in to comment.