diff --git a/Makefile.am b/Makefile.am index bcf1850..19cf2b5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,8 +19,18 @@ ACLOCAL_AMFLAGS = -I ./config # dist", so we have to include config/distscript.sh. # EXTRA_DIST = \ - README.md VERSION COPYING AUTHORS \ - config/pmishim_get_version.sh + NEWS README.md VERSION autogen.sh \ + config/pmishim_get_version.sh + + +headers = +sources = +nodist_headers = +dist_pmishimdata_DATA = +nobase_pmishim_HEADERS = \ + src/include/pmishim_config.h \ + src/include/pmishim_config_bottom.h SUBDIRS = include src +nobase_pmishim_HEADERS += $(headers) diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..939395f --- /dev/null +++ b/NEWS @@ -0,0 +1,19 @@ +Copyright (c) 2023 Nanook Consulting. All rights reserved. +$COPYRIGHT$ + +Additional copyrights may follow + +$HEADER$ + +=========================================================================== + +This file contains the main features as well as overviews of specific +bug fixes (and other actions) for each version of the PMI shim since +version 1.0. + + +1.0.0 +------ +Initial public release of the PMI shim. Tested against OpenMPI's legacy +PMI-1 and PMI-2 components. Also tested using MPICH head of "main" branch +as of release date for this package. diff --git a/config/pmishim.m4 b/config/pmishim.m4 new file mode 100644 index 0000000..9b3a683 --- /dev/null +++ b/config/pmishim.m4 @@ -0,0 +1,303 @@ +dnl -*- shell-script -*- +dnl +dnl Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana +dnl University Research and Technology +dnl Corporation. All rights reserved. +dnl Copyright (c) 2004-2005 The University of Tennessee and The University +dnl of Tennessee Research Foundation. All rights +dnl reserved. +dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +dnl University of Stuttgart. All rights reserved. +dnl Copyright (c) 2004-2005 The Regents of the University of California. +dnl All rights reserved. +dnl Copyright (c) 2006-2022 Cisco Systems, Inc. All rights reserved +dnl Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. +dnl Copyright (c) 2009-2022 IBM Corporation. All rights reserved. +dnl Copyright (c) 2009 Los Alamos National Security, LLC. All rights +dnl reserved. +dnl Copyright (c) 2009-2011 Oak Ridge National Labs. All rights reserved. +dnl Copyright (c) 2011-2013 NVIDIA Corporation. All rights reserved. +dnl Copyright (c) 2013-2023 Intel, Inc. All rights reserved. +dnl Copyright (c) 2015-2019 Research Organization for Information Science +dnl and Technology (RIST). All rights reserved. +dnl Copyright (c) 2016 Mellanox Technologies, Inc. +dnl All rights reserved. +dnl +dnl Copyright (c) 2021-2023 Nanook Consulting. All rights reserved. +dnl Copyright (c) 2018-2022 Amazon.com, Inc. or its affiliates. +dnl All Rights reserved. +dnl Copyright (c) 2021 FUJITSU LIMITED. All rights reserved. +dnl $COPYRIGHT$ +dnl +dnl Additional copyrights may follow +dnl +dnl $HEADER$ +dnl + +AC_DEFUN([PMISHIM_SETUP_CORE],[ + + AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) + AC_REQUIRE([AC_CANONICAL_TARGET]) + + # AM_PROG_CC_C_O AC_REQUIREs AC_PROG_CC, so we have to be a little + # careful about ordering here, and AC_REQUIRE these things so that + # they get stamped out in the right order. + AC_REQUIRE([_PMISHIM_START_SETUP_CC]) + AC_REQUIRE([_PMISHIM_PROG_CC]) + AC_REQUIRE([AM_PROG_CC_C_O]) + + # Get pmishim's absolute top builddir (which may not be the same as + # the real $top_builddir) + PMISHIM_startdir=`pwd` + PMISHIM_top_builddir=`pwd` + AC_SUBST(PMISHIM_top_builddir) + + # Get pmishim's absolute top srcdir (which may not be the same as the + # real $top_srcdir. First, go back to the startdir in case the + # $srcdir is relative. + + cd "$PMISHIM_startdir" + cd "$srcdir" + PMISHIM_top_srcdir="`pwd`" + AC_SUBST(PMISHIM_top_srcdir) + + # Go back to where we started + cd "$PMISHIM_startdir" + + AC_MSG_NOTICE([pmishim builddir: $PMISHIM_top_builddir]) + AC_MSG_NOTICE([pmishim srcdir: $PMISHIM_top_srcdir]) + if test "$PMISHIM_top_builddir" != "$PMISHIM_top_srcdir"; then + AC_MSG_NOTICE([Detected VPATH build]) + fi + + # Get the version of pmishim that we are installing + AC_MSG_CHECKING([for pmishim version]) + PMISHIM_VERSION="`$PMISHIM_top_srcdir/config/pmishim_get_version.sh $PMISHIM_top_srcdir/VERSION`" + if test "$?" != "0"; then + AC_MSG_ERROR([Cannot continue]) + fi + AC_MSG_RESULT([$PMISHIM_VERSION]) + AC_SUBST(PMISHIM_VERSION) + AC_DEFINE_UNQUOTED([PMISHIM_VERSION], ["$PMISHIM_VERSION"], + [The library version is always available, contrary to VERSION]) + + PMISHIM_PROXY_BUGREPORT_STRING="https://github.com/openpmishim/openpmishim" + AC_SUBST(PMISHIM_PROXY_BUGREPORT_STRING) + AC_DEFINE_UNQUOTED([PMISHIM_PROXY_BUGREPORT_STRING], ["$PMISHIM_PROXY_BUGREPORT_STRING"], + [Where to report bugs]) + + PMISHIM_RELEASE_DATE="`$PMISHIM_top_srcdir/config/pmishim_get_version.sh $PMISHIM_top_srcdir/VERSION --release-date`" + AC_SUBST(PMISHIM_RELEASE_DATE) + + # Save the breakdown the version information + PMISHIM_MAJOR_VERSION="`$PMISHIM_top_srcdir/config/pmishim_get_version.sh $PMISHIM_top_srcdir/VERSION --major`" + if test "$?" != "0"; then + AC_MSG_ERROR([Cannot continue]) + fi + AC_SUBST(PMISHIM_MAJOR_VERSION) + AC_DEFINE_UNQUOTED([PMISHIM_MAJOR_VERSION], [$PMISHIM_MAJOR_VERSION], + [The library major version is always available, contrary to VERSION]) + + PMISHIM_MINOR_VERSION="`$PMISHIM_top_srcdir/config/pmishim_get_version.sh $PMISHIM_top_srcdir/VERSION --minor`" + if test "$?" != "0"; then + AC_MSG_ERROR([Cannot continue]) + fi + AC_SUBST(PMISHIM_MINOR_VERSION) + AC_DEFINE_UNQUOTED([PMISHIM_MINOR_VERSION], [$PMISHIM_MINOR_VERSION], + [The library minor version is always available, contrary to VERSION]) + + PMISHIM_RELEASE_VERSION="`$PMISHIM_top_srcdir/config/pmishim_get_version.sh $PMISHIM_top_srcdir/VERSION --release`" + if test "$?" != "0"; then + AC_MSG_ERROR([Cannot continue]) + fi + AC_SUBST(PMISHIM_RELEASE_VERSION) + AC_DEFINE_UNQUOTED([PMISHIM_RELEASE_VERSION], [$PMISHIM_RELEASE_VERSION], + [The library release version is always available, contrary to VERSION]) + + pmishimmajor=${PMISHIM_MAJOR_VERSION}L + pmishimminor=${PMISHIM_MINOR_VERSION}L + pmishimrelease=${PMISHIM_RELEASE_VERSION}L + pmishimnumeric=$(printf 0x%4.4x%2.2x%2.2x $PMISHIM_MAJOR_VERSION $PMISHIM_MINOR_VERSION $PMISHIM_RELEASE_VERSION) + AC_SUBST(pmishimmajor) + AC_SUBST(pmishimminor) + AC_SUBST(pmishimrelease) + AC_SUBST(pmishimnumeric) + + PMISHIM_GREEK_VERSION="`$PMISHIM_top_srcdir/config/pmishim_get_version.sh $PMISHIM_top_srcdir/VERSION --greek`" + if test "$?" != "0"; then + AC_MSG_ERROR([Cannot continue]) + fi + AC_SUBST(PMISHIM_GREEK_VERSION) + + PMISHIM_REPO_REV="`$PMISHIM_top_srcdir/config/pmishim_get_version.sh $PMISHIM_top_srcdir/VERSION --repo-rev`" + if test "$?" != "0"; then + AC_MSG_ERROR([Cannot continue]) + fi + AC_SUBST(PMISHIM_REPO_REV) + AC_DEFINE_UNQUOTED([PMISHIM_REPO_REV], ["$PMISHIM_REPO_REV"], + [The OpenPMIshim Git Revision]) + + PMISHIM_RELEASE_DATE="`$PMISHIM_top_srcdir/config/pmishim_get_version.sh $PMISHIM_top_srcdir/VERSION --release-date`" + if test "$?" != "0"; then + AC_MSG_ERROR([Cannot continue]) + fi + AC_SUBST(PMISHIM_RELEASE_DATE) + + # Debug mode? + AC_MSG_CHECKING([if want pmishim maintainer support]) + pmishim_debug= + AS_IF([test "$pmishim_debug" = "" && test "$enable_debug" = "yes"], + [pmishim_debug=1 + pmishim_debug_msg="enabled"]) + AS_IF([test "$pmishim_debug" = ""], + [pmishim_debug=0 + pmishim_debug_msg="disabled"]) + # Grr; we use #ifndef for PMISHIM_DEBUG! :-( + AH_TEMPLATE(PMISHIM_ENABLE_DEBUG, [Whether we are in debugging mode or not]) + AS_IF([test "$pmishim_debug" = "1"], [AC_DEFINE([PMISHIM_ENABLE_DEBUG])]) + AC_MSG_RESULT([$pmishim_debug_msg]) + + # + # Package/brand string + # + AC_MSG_CHECKING([if want package/brand string]) + AC_ARG_WITH([pmishim-package-string], + [AS_HELP_STRING([--with-pmishim-package-string=STRING], + [Use a branding string throughout PMIshim])]) + if test "$with_pmishim_package_string" = "" || test "$with_pmishim_package_string" = "no"; then + with_package_string="PMIshim $PMISHIM_CONFIGURE_USER@$PMISHIM_CONFIGURE_HOST Distribution" + fi + AC_DEFINE_UNQUOTED([PMISHIM_PACKAGE_STRING], ["$with_package_string"], + [package/branding string for PMIshim]) + AC_MSG_RESULT([$with_package_string]) + + pmishimdir='${installdir}' + pmishimdatadir='${datadir}' + pmishimlibdir='${libdir}' + pmishimincludedir='${includedir}' + AC_SUBST(pmishimdir) + AC_SUBST(pmishimdatadir) + AC_SUBST(pmishimlibdir) + AC_SUBST(pmishimincludedir) + + # A hint to tell us if we are working with a build from Git or a tarball. + # Helpful when preparing diagnostic output. + if test -e $PMISHIM_TOP_SRCDIR/.git; then + AC_DEFINE_UNQUOTED([PMISHIM_GIT_REPO_BUILD], ["1"], + [If built from a git repo]) + pmishim_git_repo_build=yes + fi + + # do we want dlopen support ? + AC_MSG_CHECKING([if want dlopen support]) + AC_ARG_ENABLE([dlopen], + [AS_HELP_STRING([--enable-dlopen], + [Whether build should attempt to use dlopen (or + similar) to dynamically load components. + (default: enabled)])]) + AS_IF([test "$enable_dlopen" = "unknown"], + [AC_MSG_WARN([enable_dlopen variable has been overwritten by configure]) + AC_MSG_WARN([This is an internal error that should be reported to PMIshim developers]) + AC_MSG_ERROR([Cannot continue])]) + AS_IF([test "$enable_dlopen" = "no"], + [PMISHIM_ENABLE_DLOPEN_SUPPORT=0 + AC_MSG_RESULT([no])], + [PMISHIM_ENABLE_DLOPEN_SUPPORT=1 + AC_MSG_RESULT([yes])]) + AC_DEFINE_UNQUOTED(PMISHIM_ENABLE_DLOPEN_SUPPORT, $PMISHIM_ENABLE_DLOPEN_SUPPORT, + [Whether we want to enable dlopen support]) + +# +# +# Developer picky compiler options +# + +AC_MSG_CHECKING([if want developer-level compiler pickyness]) +AC_ARG_ENABLE(devel-check, + AS_HELP_STRING([--enable-devel-check], + [enable developer-level compiler pickyness when building PMIshim (default: disabled)])) +if test "$enable_devel_check" = "yes"; then + AC_MSG_RESULT([yes]) + WANT_PICKY_COMPILER=1 +elif test "$enable_devel_check" = "no"; then + AC_MSG_RESULT([no]) + WANT_PICKY_COMPILER=0 + CFLAGS="$CFLAGS -Wno-unused-parameter" +elif test "$pmishim_git_repo_build" = "yes" && test "$pmishim_debug" = "1"; then + AC_MSG_RESULT([yes]) + WANT_PICKY_COMPILER=1 +else + AC_MSG_RESULT([no]) + WANT_PICKY_COMPILER=0 + CFLAGS="$CFLAGS -Wno-unused-parameter" +fi + +AC_DEFINE_UNQUOTED(PMISHIM_PICKY_COMPILERS, $WANT_PICKY_COMPILER, + [Whether or not we are using picky compiler settings]) + +# +# Developer debugging +# + +AC_MSG_CHECKING([if want developer-level debugging code]) +AC_ARG_ENABLE(debug, + AS_HELP_STRING([--enable-debug], + [enable developer-level debugging code (not for general PMIshim users!) (default: disabled)])) +if test "$enable_debug" = "yes"; then + AC_MSG_RESULT([yes]) + WANT_DEBUG=1 +else + AC_MSG_RESULT([no]) + WANT_DEBUG=0 +fi + +if test "$WANT_DEBUG" = "0"; then + CFLAGS="-DNDEBUG $CFLAGS" +fi + +AC_DEFINE_UNQUOTED(PMISHIM_ENABLE_DEBUG, $WANT_DEBUG, + [Whether we want developer-level debugging code or not]) + +AC_ARG_ENABLE(debug-symbols, + AS_HELP_STRING([--disable-debug-symbols], + [Disable adding compiler flags to enable debugging symbols if --enable-debug is specified. For non-debugging builds, this flag has no effect.])) + +# +# +# Ident string +# +AC_MSG_CHECKING([if want ident string]) +AC_ARG_WITH([ident-string], + [AS_HELP_STRING([--with-ident-string=STRING], + [Embed an ident string into PMIshim object files])]) +if test "$with_ident_string" = "" || test "$with_ident_string" = "no"; then + with_ident_string="%VERSION%" +fi +# This is complicated, because $PMISHIM_VERSION may have spaces in it. +# So put the whole sed expr in single quotes -- i.e., directly +# substitute %VERSION% for (not expanded) $PMISHIM_VERSION. +with_ident_string="`echo $with_ident_string | sed -e 's/%VERSION%/$PMISHIM_VERSION/'`" + +# Now eval an echo of that so that the "$PMISHIM_VERSION" token is +# replaced with its value. Enclose the whole thing in "" so that it +# ends up as 1 token. +with_ident_string="`eval echo $with_ident_string`" + +AC_DEFINE_UNQUOTED([PMISHIM_IDENT_STRING], ["$with_ident_string"], + [ident string for PMISHIM]) +AC_MSG_RESULT([$with_ident_string]) + +# see if they want to disable non-RTLD_GLOBAL dlopen +AC_MSG_CHECKING([if want to support dlopen of non-global namespaces]) +AC_ARG_ENABLE([nonglobal-dlopen], + AS_HELP_STRING([--enable-nonglobal-dlopen], + [enable non-global dlopen (default: enabled)])) +if test "$enable_nonglobal_dlopen" = "no"; then + AC_MSG_RESULT([no]) + pmishim_need_libpmishim=0 +else + AC_MSG_RESULT([yes]) + pmishim_need_libpmishim=1 +fi + +])dnl diff --git a/config/pmishim_setup_cc.m4 b/config/pmishim_setup_cc.m4 new file mode 100644 index 0000000..023d9bc --- /dev/null +++ b/config/pmishim_setup_cc.m4 @@ -0,0 +1,438 @@ +dnl -*- shell-script -*- +dnl +dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +dnl University Research and Technology +dnl Corporation. All rights reserved. +dnl Copyright (c) 2004-2006 The University of Tennessee and The University +dnl of Tennessee Research Foundation. All rights +dnl reserved. +dnl Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, +dnl University of Stuttgart. All rights reserved. +dnl Copyright (c) 2004-2006 The Regents of the University of California. +dnl All rights reserved. +dnl Copyright (c) 2007-2009 Sun Microsystems, Inc. All rights reserved. +dnl Copyright (c) 2008-2015 Cisco Systems, Inc. All rights reserved. +dnl Copyright (c) 2012-2017 Los Alamos National Security, LLC. All rights +dnl reserved. +dnl Copyright (c) 2015-2019 Research Organization for Information Science +dnl and Technology (RIST). All rights reserved. +dnl Copyright (c) 2018-2020 Intel, Inc. All rights reserved. +dnl Copyright (c) 2020-2023 Triad National Security, LLC. All rights +dnl reserved. +dnl Copyright (c) 2021 IBM Corporation. All rights reserved. +dnl +dnl Copyright (c) 2021-2023 Nanook Consulting. All rights reserved. +dnl Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved. +dnl $COPYRIGHT$ +dnl +dnl Additional copyrights may follow +dnl +dnl $HEADER$ +dnl + +AC_DEFUN([PMISHIM_CC_HELPER],[ + PMISHIM_VAR_SCOPE_PUSH([pmishim_cc_helper_result]) + AC_MSG_CHECKING([$1]) + + AC_LINK_IFELSE([AC_LANG_PROGRAM([$3],[$4])], + [$2=1 + pmishim_cc_helper_result=yes], + [$2=0 + pmishim_cc_helper_result=no]) + + AC_MSG_RESULT([$pmishim_cc_helper_result]) + PMISHIM_VAR_SCOPE_POP +]) + + +AC_DEFUN([PMISHIM_PROG_CC_C11_HELPER],[ + PMISHIM_VAR_SCOPE_PUSH([pmishim_prog_cc_c11_helper_CFLAGS_save]) + + pmishim_prog_cc_c11_helper_CFLAGS_save=$CFLAGS + CFLAGS="$CFLAGS $1" + + PMISHIM_CC_HELPER([if $CC $1 supports C11 _Thread_local], [pmishim_prog_cc_c11_helper__Thread_local_available], + [],[[static _Thread_local int foo = 1;++foo;]]) + + PMISHIM_CC_HELPER([if $CC $1 supports C11 atomic variables], [pmishim_prog_cc_c11_helper_atomic_var_available], + [[#include ]], [[static atomic_long foo = 1;++foo;]]) + + PMISHIM_CC_HELPER([if $CC $1 supports C11 _Atomic keyword], [pmishim_prog_cc_c11_helper__Atomic_available], + [[#include ]],[[static _Atomic long foo = 1;++foo;]]) + + PMISHIM_CC_HELPER([if $CC $1 supports C11 _c11_atomic functions], [pmishim_prog_cc_c11_atomic_function], + [[#include ]],[[atomic_int acnt = 0; __c11_atomic_fetch_add(&acnt, 1, memory_order_relaxed);]]) + if test $pmishim_prog_cc_c11_atomic_function -eq 1; then + AC_DEFINE_UNQUOTED([PMISHIM_HAVE_CLANG_BUILTIN_ATOMIC_C11_FUNC], [$pmishim_prog_cc_c11_atomic_function], [Whether we have Clang __c11 atomic functions]) + fi; + + PMISHIM_CC_HELPER([if $CC $1 supports C11 _Generic keyword], [pmishim_prog_cc_c11_helper__Generic_available], + [[#define FOO(x) (_Generic (x, int: 1))]], [[static int x, y; y = FOO(x);]]) + + PMISHIM_CC_HELPER([if $CC $1 supports C11 _Static_assert], [pmishim_prog_cc_c11_helper__static_assert_available], + [[#include ]],[[_Static_assert(sizeof(int64_t) == 8, "WTH");]]) + + PMISHIM_CC_HELPER([if $CC $1 supports C11 atomic_fetch_xor_explicit], [pmishim_prog_cc_c11_helper_atomic_fetch_xor_explicit_available], + [[#include +#include ]],[[_Atomic uint32_t a; uint32_t b; atomic_fetch_xor_explicit(&a, b, memory_order_relaxed);]]) + + + AS_IF([test $pmishim_prog_cc_c11_helper__Thread_local_available -eq 1 && test $pmishim_prog_cc_c11_helper_atomic_var_available -eq 1 && test $pmishim_prog_cc_c11_helper_atomic_fetch_xor_explicit_available -eq 1], + [$2], + [$3]) + + CFLAGS=$pmishim_prog_cc_c11_helper_CFLAGS_save + + PMISHIM_VAR_SCOPE_POP +]) + +AC_DEFUN([PMISHIM_PROG_CC_C11],[ + PMISHIM_VAR_SCOPE_PUSH([pmishim_prog_cc_c11_flags]) + if test -z "$pmishim_cv_c11_supported" ; then + pmishim_cv_c11_supported=no + pmishim_cv_c11_flag_required=yes + + AC_MSG_CHECKING([if $CC requires a flag for C11]) + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#if __STDC_VERSION__ < 201112L +#error "Without any CLI flags, this compiler does not support C11" +#endif + ]],[])], + [pmishim_cv_c11_flag_required=no]) + + AC_MSG_RESULT([$pmishim_cv_c11_flag_required]) + + if test "x$pmishim_cv_c11_flag_required" = "xno" ; then + AC_MSG_NOTICE([verifying $CC supports C11 without a flag]) + PMISHIM_PROG_CC_C11_HELPER([], [], [pmishim_cv_c11_flag_required=yes]) + fi + + if test "x$pmishim_cv_c11_flag_required" = "xyes" ; then + pmishim_prog_cc_c11_flags="-std=gnu11 -std=c11 -c11" + + AC_MSG_NOTICE([checking if $CC supports C11 with a flag]) + pmishim_cv_c11_flag= + for flag in $(echo $pmishim_prog_cc_c11_flags | tr ' ' '\n') ; do + PMISHIM_PROG_CC_C11_HELPER([$flag],[pmishim_cv_c11_flag=$flag],[]) + if test "x$pmishim_cv_c11_flag" != "x" ; then + PMISHIM_APPEND_UNIQ([CFLAGS], ["$pmishim_cv_c11_flag"]) + AC_MSG_NOTICE([using $flag to enable C11 support]) + pmishim_cv_c11_supported=yes + break + fi + done + else + AC_MSG_NOTICE([no flag required for C11 support]) + pmishim_cv_c11_supported=yes + fi + fi + + PMISHIM_VAR_SCOPE_POP +]) + + +# PMISHIM_CHECK_CC_IQUOTE() +# ---------------------- +# Check if the compiler supports the -iquote option. This options +# removes the specified directory from the search path when using +# #include <>. This check works around an issue caused by C++20 +# which added a header. This conflicts with the +# VERSION file at the base of our source directory on case- +# insensitive filesystems. +AC_DEFUN([PMISHIM_CHECK_CC_IQUOTE],[ + PMISHIM_VAR_SCOPE_PUSH([pmishim_check_cc_iquote_CFLAGS_save]) + pmishim_check_cc_iquote_CFLAGS_save=${CFLAGS} + CFLAGS="${CFLAGS} -iquote ." + AC_MSG_CHECKING([for $CC option to add a directory only to the search path for the quote form of include]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[])], + [pmishim_cc_iquote="-iquote"], + [pmishim_cc_iquote="-I"]) + CFLAGS=${pmishim_check_cc_iquote_CFLAGS_save} + PMISHIM_VAR_SCOPE_POP + AC_MSG_RESULT([$pmishim_cc_iquote]) +]) + + +# PMISHIM_SETUP_CC() +# --------------- +# Do everything required to setup the C compiler. Safe to AC_REQUIRE +# this macro. +AC_DEFUN([PMISHIM_SETUP_CC],[ + # AM_PROG_CC_C_O AC_REQUIREs AC_PROG_CC, so we have to be a little + # careful about ordering here, and AC_REQUIRE these things so that + # they get stamped out in the right order. + + AC_REQUIRE([_PMISHIM_START_SETUP_CC]) + AC_REQUIRE([_PMISHIM_PROG_CC]) + AC_REQUIRE([AM_PROG_CC_C_O]) + + PMISHIM_VAR_SCOPE_PUSH([pmishim_prog_cc_c11_helper__Thread_local_available pmishim_prog_cc_c11_helper_atomic_var_available pmishim_prog_cc_c11_helper__Atomic_available pmishim_prog_cc_c11_helper__static_assert_available pmishim_prog_cc_c11_helper__Generic_available pmishim_prog_cc__thread_available pmishim_prog_cc_c11_helper_atomic_fetch_xor_explicit_available pmishim_prog_cc_c11_atomic_function]) + + # AC_PROG_CC_C99 changes CC (instead of CFLAGS) so save CC (without c99 + # flags) for use in our wrappers. + WRAPPER_CC="$CC" + AC_SUBST([WRAPPER_CC]) + + PMISHIM_PROG_CC_C11 + PMISHIM_CHECK_CC_IQUOTE + + if test $pmishim_cv_c11_supported = no ; then + # It is not currently an error if C11 support is not available. Uncomment the + # following lines and update the warning when we require a C11 compiler. + # AC_MSG_WARNING([Open MPI requires a C11 (or newer) compiler]) + # AC_MSG_ERROR([Aborting.]) + # From Open MPI 1.7 on we require a C99 compliant compiler + # with autoconf 2.70 AC_PROG_CC makes AC_PROG_CC_C99 obsolete + m4_version_prereq([2.70], + [], + [AC_PROG_CC_C99]) + # The C99 result of AC_PROG_CC is stored in ac_cv_prog_cc_c99 + if test "x$ac_cv_prog_cc_c99" = xno ; then + AC_MSG_WARN([Open MPI requires a C99 (or newer) compiler. C11 is recommended.]) + AC_MSG_ERROR([Aborting.]) + fi + + # Get the correct result for C11 support flags now that the compiler flags have + # changed + PMISHIM_PROG_CC_C11_HELPER([],[],[]) + fi + + # Check if compiler support __thread + PMISHIM_CC_HELPER([if $CC $1 supports __thread], [pmishim_prog_cc__thread_available], + [],[[static __thread int foo = 1;++foo;]]) + + + PMISHIM_CC_HELPER([if $CC $1 supports C11 _Thread_local], [pmishim_prog_cc_c11_helper__Thread_local_available], + [],[[static _Thread_local int foo = 1;++foo;]]) + + dnl At this time, PMIshim only needs thread local and the atomic convenience types for C11 support. These + dnl will likely be required in the future. + AC_DEFINE_UNQUOTED([PMISHIM_C_HAVE__THREAD_LOCAL], [$pmishim_prog_cc_c11_helper__Thread_local_available], + [Whether C compiler supports __Thread_local]) + + AC_DEFINE_UNQUOTED([PMISHIM_C_HAVE_ATOMIC_CONV_VAR], [$pmishim_prog_cc_c11_helper_atomic_var_available], + [Whether C compiler supports atomic convenience variables in stdatomic.h]) + + AC_DEFINE_UNQUOTED([PMISHIM_C_HAVE__ATOMIC], [$pmishim_prog_cc_c11_helper__Atomic_available], + [Whether C compiler supports __Atomic keyword]) + + AC_DEFINE_UNQUOTED([PMISHIM_C_HAVE__GENERIC], [$pmishim_prog_cc_c11_helper__Generic_available], + [Whether C compiler supports __Generic keyword]) + + AC_DEFINE_UNQUOTED([PMISHIM_C_HAVE__STATIC_ASSERT], [$pmishim_prog_cc_c11_helper__static_assert_available], + [Whether C compiler supports _Static_assert keyword]) + + AC_DEFINE_UNQUOTED([PMISHIM_C_HAVE___THREAD], [$pmishim_prog_cc__thread_available], + [Whether C compiler supports __thread]) + + OAC_C_COMPILER_VENDOR() + + # GNU C and autotools are inconsistent about whether this is + # defined so let's make it true everywhere for now... However, IBM + # XL compilers on PPC Linux behave really badly when compiled with + # _GNU_SOURCE defined, so don't define it in that situation. + # + # Don't use AC_GNU_SOURCE because it requires that no compiler + # tests are done before setting it, and we need to at least do + # enough tests to figure out if we're using XL or not. + AS_IF([test "$oac_cv_c_compiler_vendor" != "ibm"], + [AH_VERBATIM([_GNU_SOURCE], + [/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif]) + AC_DEFINE([_GNU_SOURCE])]) + + # Do we want code coverage + if test "$WANT_COVERAGE" = "1"; then + # For compilers > gcc-4.x, use --coverage for + # compiling and linking to circumvent trouble with + # libgcov. + LDFLAGS_orig="$LDFLAGS" + PMISHIM_APPEND_UNIQ([LDFLAGS], ["$--coverage"]) + PMISHIM_COVERAGE_FLAGS= + + _PMISHIM_CHECK_SPECIFIC_CFLAGS(--coverage, coverage) + if test "$pmishim_cv_cc_coverage" = "1" ; then + PMISHIM_COVERAGE_FLAGS="--coverage" + CLEANFILES="*.gcno ${CLEANFILES}" + CONFIG_CLEAN_FILES="*.gcda *.gcov ${CONFIG_CLEAN_FILES}" + AC_MSG_WARN([$PMISHIM_COVERAGE_FLAGS has been added to CFLAGS (--enable-coverage)]) + else + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-ftest-coverage, ftest_coverage) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-fprofile-arcs, fprofile_arcs) + if test "$pmishim_cv_cc_ftest_coverage" = "0" || test "pmishim_cv_cc_fprofile_arcs" = "0" ; then + AC_MSG_WARN([Code coverage functionality is not currently available with $CC]) + AC_MSG_ERROR([Configure: Cannot continue]) + fi + CLEANFILES="*.bb *.bbg ${CLEANFILES}" + PMISHIM_COVERAGE_FLAGS="-ftest-coverage -fprofile-arcs" + fi + WANT_DEBUG=1 + fi + + # Do we want debugging? + if test "$WANT_DEBUG" = "1" && test "$enable_debug_symbols" != "no" ; then + PMISHIM_APPEND_UNIQ([CFLAGS], ["-g"]) + + AC_MSG_WARN([-g has been added to CFLAGS (--enable-debug)]) + fi + + # These flags are generally gcc-specific; even the + # gcc-impersonating compilers won't accept them. + PMISHIM_CFLAGS_BEFORE_PICKY="$CFLAGS" + + # Note: Some versions of clang (at least >= 3.5 -- perhaps + # older versions, too?) and xlc with -g (v16.1, perhaps older) + # will *warn* about -finline-functions, but still allow it. + # This is very annoying, so check for that warning, too. + # The clang warning looks like this: + # clang: warning: optimization flag '-finline-functions' is not supported + # clang: warning: argument unused during compilation: '-finline-functions' + # the xlc warning looks like this: + # warning: "-qinline" is not compatible with "-g". "-qnoinline" is being set. + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-finline-functions, finline_functions) + + # Try to enable restrict keyword + RESTRICT_CFLAGS= + case "$oac_cv_c_compiler_vendor" in + intel) + RESTRICT_CFLAGS="-restrict" + ;; + sgi) + RESTRICT_CFLAGS="-LANG:restrict=ON" + ;; + esac + if test ! -z "$RESTRICT_CFLAGS" ; then + _PMISHIM_CHECK_SPECIFIC_CFLAGS($RESTRICT_CFLAGS, restrict) + fi + + AC_MSG_RESULT(CFLAGS result: $CFLAGS) + + # see if the C compiler supports __builtin_expect + AC_CACHE_CHECK([if $CC supports __builtin_expect], + [pmishim_cv_cc_supports___builtin_expect], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], + [[void *ptr = (void*) 0; + if (__builtin_expect (ptr != (void*) 0, 1)) return 0; + ]])], + [pmishim_cv_cc_supports___builtin_expect="yes"], + [pmishim_cv_cc_supports___builtin_expect="no"])]) + if test "$pmishim_cv_cc_supports___builtin_expect" = "yes" ; then + have_cc_builtin_expect=1 + else + have_cc_builtin_expect=0 + fi + AC_DEFINE_UNQUOTED([PMISHIM_C_HAVE_BUILTIN_EXPECT], [$have_cc_builtin_expect], + [Whether C compiler supports __builtin_expect]) + + # see if the C compiler supports __builtin_prefetch + AC_CACHE_CHECK([if $CC supports __builtin_prefetch], + [pmishim_cv_cc_supports___builtin_prefetch], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([ + [int ptr; + __builtin_prefetch(&ptr,0,0);]], + [pmishim_cv_cc_supports___builtin_prefetch="yes"], + [pmishim_cv_cc_supports___builtin_prefetch="no"])])]) + if test "$pmishim_cv_cc_supports___builtin_prefetch" = "yes" ; then + have_cc_builtin_prefetch=1 + else + have_cc_builtin_prefetch=0 + fi + AC_DEFINE_UNQUOTED([PMISHIM_C_HAVE_BUILTIN_PREFETCH], [$have_cc_builtin_prefetch], + [Whether C compiler supports __builtin_prefetch]) + + # see if the C compiler supports __builtin_clz + AC_CACHE_CHECK([if $CC supports __builtin_clz], + [pmishim_cv_cc_supports___builtin_clz], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([ + [int value = 0xffff; /* we know we have 16 bits set */ + if ((8*sizeof(int)-16) != __builtin_clz(value)) return 0;]], + [pmishim_cv_cc_supports___builtin_clz="yes"], + [pmishim_cv_cc_supports___builtin_clz="no"])])]) + if test "$pmishim_cv_cc_supports___builtin_clz" = "yes" ; then + have_cc_builtin_clz=1 + else + have_cc_builtin_clz=0 + fi + AC_DEFINE_UNQUOTED([PMISHIM_C_HAVE_BUILTIN_CLZ], [$have_cc_builtin_clz], + [Whether C compiler supports __builtin_clz]) + + # Preload the optflags for the case where the user didn't specify + # any. If we're using GNU compilers, use -O3 (since it GNU + # doesn't require all compilation units to be compiled with the + # same level of optimization -- selecting a high level of + # optimization is not prohibitive). If we're using anything else, + # be conservative and just use -O. + # + if test "$WANT_DEBUG" = "1"; then + OPTFLAGS= + else + if test "$GCC" = yes; then + OPTFLAGS="-O3" + else + OPTFLAGS="-O" + fi + fi + + PMISHIM_ENSURE_CONTAINS_OPTFLAGS("$PMISHIM_CFLAGS_BEFORE_PICKY") + PMISHIM_CFLAGS_BEFORE_PICKY="$co_result" + + AC_MSG_CHECKING([for C optimization flags]) + PMISHIM_ENSURE_CONTAINS_OPTFLAGS(["$CFLAGS"]) + AC_MSG_RESULT([$co_result]) + CFLAGS="$co_result" + PMISHIM_VAR_SCOPE_POP +]) + + +AC_DEFUN([_PMISHIM_START_SETUP_CC],[ + pmishim_show_subtitle "C compiler and preprocessor" + + # $%@#!@#% AIX!! This has to be called before anything invokes the C + # compiler. + dnl AC_AIX +]) + + +AC_DEFUN([_PMISHIM_PROG_CC],[ + # + # Check for the compiler + # + PMISHIM_VAR_SCOPE_PUSH([pmishim_cflags_save dummy pmishim_cc_arvgv0]) + pmishim_cflags_save="$CFLAGS" + AC_PROG_CC + BASECC="`basename $CC`" + CFLAGS="$pmishim_cflags_save" + AC_DEFINE_UNQUOTED(PMISHIM_CC, "$CC", [OMPI underlying C compiler]) + set dummy $CC + pmishim_cc_argv0=[$]2 + PMISHIM_WHICH([$pmishim_cc_argv0], [PMISHIM_CC_ABSOLUTE]) + AC_SUBST(PMISHIM_CC_ABSOLUTE) + PMISHIM_VAR_SCOPE_POP +]) + +AC_DEFUN([PMISHIM_SETUP_PICKY_COMPILERS],[ + if test $WANT_PICKY_COMPILER -eq 1 && test "$oac_cv_c_compiler_vendor" != "portland group"; then + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-Wundef, Wundef) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-Wno-long-long, Wno_long_long, int main() { long long x; }) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-Wsign-compare, Wsign_compare) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-Wmissing-prototypes, Wmissing_prototypes) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-Wstrict-prototypes, Wstrict_prototypes) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-Wcomment, Wcomment) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-Wshadow, Wshadow) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-Werror-implicit-function-declaration, Werror_implicit_function_declaration) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-Wno-long-double, Wno_long_double, int main() { long double x; }) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-fno-strict-aliasing, fno_strict_aliasing, int main () { int x; }) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-pedantic, pedantic) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-Wall, Wall) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-Wextra, Wextra) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-Werror, Werror) + if test $WANT_MEMORY_SANITIZERS -eq 1 && test "$oac_cv_c_compiler_vendor" != "portland group"; then + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-fsanitize=address, fsanaddress) + _PMISHIM_CHECK_SPECIFIC_CFLAGS(-fsanitize=undefined, fsanundefined) + fi + fi + +]) diff --git a/config/pmishim_setup_pmix.m4 b/config/pmishim_setup_pmix.m4 index 31a7bce..8d883b9 100644 --- a/config/pmishim_setup_pmix.m4 +++ b/config/pmishim_setup_pmix.m4 @@ -89,11 +89,11 @@ AC_DEFUN([PMISHIM_CHECK_PMIX],[ AC_MSG_ERROR([Cannot continue])])])]) AS_IF([test "$pmix_ext_install_dir" != "/usr"], - [pmix_CPPFLAGS="-I$pmix_ext_install_dir/include" - pmix_LDFLAGS="-L$pmix_ext_install_libdir"], - [pmix_CPPFLAGS="" - pmix_LDFLAGS=""]) - pmix_LIBS=-lpmix + [pmishim_CPPFLAGS="-I$pmix_ext_install_dir/include" + pmishim_LDFLAGS="-L$pmix_ext_install_libdir"], + [pmishim_CPPFLAGS="" + pmishim_LDFLAGS=""]) + pmishim_LIBS=-lpmix fi diff --git a/configure.ac b/configure.ac index df755a9..796418e 100644 --- a/configure.ac +++ b/configure.ac @@ -50,15 +50,43 @@ AC_LANG([C]) # version AC_INIT([pmi-shim],[m4_normalize(esyscmd([config/pmishim_get_version.sh VERSION --tarball]))], - [https://github.com/openpmix/pmi-shim/issues],[pmishim]) + [https://github.com/openpmishim/pmi-shim/issues],[pmishim]) AC_PREREQ([2.70]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_MACRO_DIR(./config) -# -# Start it up -# +AC_PROG_SED + +# autotools expects to perform tests without interference +# from user-provided CFLAGS, particularly -Werror flags. +# Search for them here and cache any we find +PMISHIM_CFLAGS_cache= +PMISHIM_CFLAGS_pass= +for val in $CFLAGS; do + if echo "$val" | grep -q -e "-W"; then + PMISHIM_CFLAGS_cache="$PMISHIM_CFLAGS_cache $val"; + else + PMISHIM_CFLAGS_pass="$PMISHIM_CFLAGS_pass $val"; + fi +done +CFLAGS=$PMISHIM_CFLAGS_pass + +PMISHIM_TOP_BUILDDIR="`pwd`" +AC_SUBST(PMISHIM_TOP_BUILDDIR) +top_buildir=`pwd` +cd "$srcdir" +PMISHIM_TOP_SRCDIR="`pwd`" +top_srcdir=$PMISHIM_TOP_SRCDIR +AC_SUBST(PMISHIM_TOP_SRCDIR) +cd "$PMISHIM_TOP_BUILDDIR" + +AC_MSG_NOTICE([builddir: $PMISHIM_TOP_BUILDDIR]) +AC_MSG_NOTICE([srcdir: $PMISHIM_TOP_SRCDIR]) +if test "$PMISHIM_TOP_BUILDDIR" != "$PMISHIM_TOP_SRCDIR"; then + AC_MSG_NOTICE([Detected VPATH build]) +fi +# setup configure options (e.g., show_title and friends) PMISHIM_CONFIGURE_SETUP pmishim_show_title "Configuring PMI-SHIM" @@ -66,9 +94,6 @@ pmishim_show_title "Configuring PMI-SHIM" # # Setup some things that must be done before AM-INIT-AUTOMAKE # - -pmishim_show_subtitle "Startup tests" - AC_CANONICAL_HOST AC_CANONICAL_TARGET AC_DEFINE_UNQUOTED(PMISHIM_ARCH, "$target", [PMI-SHIM architecture string]) @@ -84,6 +109,41 @@ AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects no-define 1.13.4 tar-ustar]) # (even though they're supposed to be identical). Shrug. AM_SILENT_RULES([yes]) +# set the language +AC_LANG([C]) +# find NM +AC_PROG_GREP +LT_PATH_NM + +# AC_USE_SYSTEM_EXTENSIONS will modify CFLAGS if nothing was in there +# beforehand. We don't want that. So if there was nothing in +# CFLAGS, put nothing back in there. +PMISHIM_VAR_SCOPE_PUSH([CFLAGS_save]) +CFLAGS_save=$CFLAGS +AC_USE_SYSTEM_EXTENSIONS +AS_IF([test -z "$CFLAGS_save"], [CFLAGS=]) +PMISHIM_VAR_SCOPE_POP + +# Sanity checks +AC_DEFUN([PMISHIM_CHECK_DIR_FOR_SPACES],[ + dir="$1" + article="$2" + label="$3" + + AC_MSG_CHECKING([directory of $label]) + AC_MSG_RESULT([$dir]) + AS_IF([test -n "`echo $dir | grep ' '`"], + [AC_MSG_WARN([This version of OpenPMIshim does not support $article $label]) + AC_MSG_WARN([with a path that contains spaces]) + AC_MSG_ERROR([Cannot continue.])]) +]) + +PMISHIM_VAR_SCOPE_PUSH(pmishim_checkdir) +pmishim_checkdir=`pwd` +PMISHIM_CHECK_DIR_FOR_SPACES([$pmishim_checkdir], [a], [build tree]) +PMISHIM_CHECK_DIR_FOR_SPACES([$prefix], [a], [prefix]) +PMISHIM_CHECK_DIR_FOR_SPACES([$srcdir], [a], [source tree]) +PMISHIM_VAR_SCOPE_POP # Make configure depend on the VERSION file, since it's used in AC_INIT AC_SUBST([CONFIGURE_DEPENDENCIES], ['$(top_srcdir)/VERSION']) @@ -121,19 +181,6 @@ AC_CONFIG_HEADERS([src/include/pmishim_config.h]) pmishim_show_subtitle "Initialization, setup" -PMISHIM_TOP_BUILDDIR="`pwd`" -AC_SUBST(PMISHIM_TOP_BUILDDIR) -cd "$srcdir" -PMISHIM_TOP_SRCDIR="`pwd`" -AC_SUBST(PMISHIM_TOP_SRCDIR) -cd "$PMISHIM_TOP_BUILDDIR" - -AC_MSG_NOTICE([builddir: $PMISHIM_TOP_BUILDDIR]) -AC_MSG_NOTICE([srcdir: $PMISHIM_TOP_SRCDIR]) -if test "$PMISHIM_TOP_BUILDDIR" != "$PMISHIM_TOP_SRCDIR"; then - AC_MSG_NOTICE([Detected VPATH build]) -fi - # Setup the top of the src/include/pmishim_config.h file AH_TOP([/* -*- c -*- @@ -162,7 +209,7 @@ AH_TOP([/* -*- c -*- ]) AH_BOTTOM([ -#include "pmishim_config_bottom.h" +#include "src/include/pmishim_config_bottom.h" #endif /* PMISHIM_CONFIG_H */ ]) @@ -170,74 +217,11 @@ AH_BOTTOM([ PMISHIM_BASIC_SETUP PMISHIM_CHECK_VISIBILITY +PMISHIM_SETUP_CORE -############################################################################ -# Configuration options -############################################################################ - -# -# Is this a developer copy? -# - -if test -d .git; then - PMISHIM_DEVEL=1 -else - PMISHIM_DEVEL=0 -fi - -# -# Developer picky compiler options -# - -AC_MSG_CHECKING([if want developer-level compiler pickyness]) -AC_ARG_ENABLE(picky, - AS_HELP_STRING([--enable-picky],[enable developer-level compiler pickyness when building PMI Shim (default: disabled, unless a .git directory is found in the build tree)])) -if test "$enable_picky" = "yes"; then - AC_MSG_RESULT([yes]) - WANT_PICKY_COMPILER=1 -else - AC_MSG_RESULT([no]) - WANT_PICKY_COMPILER=0 -fi -#################### Developer default override #################### -if test "$WANT_PICKY_COMPILER" = "0" && test -z "$enable_picky" && test "$PMISHIM_DEVEL" = 1; then - WANT_PICKY_COMPILER=1 - echo "--> developer override: enable picky compiler by default" -fi -#################### Developer default override #################### - -# -# Developer debugging -# -AC_MSG_CHECKING([if want developer-level debugging code]) -AC_ARG_ENABLE(debug, - AS_HELP_STRING([--enable-debug],[enable developer-level debugging code (not for general users!) (default: disabled)])) -if test "$enable_debug" = "yes" || test "$PMISHIM_DEVEL" = "1"; then - AC_MSG_RESULT([yes]) - WANT_DEBUG=1 -else - AC_MSG_RESULT([no]) - WANT_DEBUG=0 -fi - - -if test "$WANT_DEBUG" = "0"; then - CFLAGS="-DNDEBUG $CFLAGS" - CXXFLAGS="-DNDEBUG $CXXFLAGS" -else - CFLAGS="-DDEBUG -g $CFLAGS" - CXXFLAGS="-DDEBUG -g $CXXFLAGS" -fi -AC_DEFINE_UNQUOTED(PMISHIM_ENABLE_DEBUG, $WANT_DEBUG, - [Whether we want developer-level debugging code or not]) - -AC_ARG_ENABLE(debug-symbols, - AS_HELP_STRING([--disable-debug-symbols],[Disable adding compiler flags to enable debugging symbols if --enable-debug is specified. For non-debugging builds, this flag has no effect.])) - - +pmishim_show_title "Checking for PMIx" PMISHIM_CHECK_PMIX - ############################################################################ # Libtool: part one # (before C compiler setup) @@ -247,6 +231,8 @@ PMISHIM_CHECK_PMIX # Part one of libtool magic. Default to: enable shared, disable static. # +pmishim_show_title "Setup libtool" + AC_ENABLE_SHARED([]) #AC_ENABLE_STATIC([]) #AC_DISABLE_STATIC([]) @@ -257,7 +243,7 @@ LT_LANG([C]) # final compiler config ############################################################################ -pmishim_show_subtitle "Compiler flags" +pmishim_show_title "Compiler flags" # # This is needed for VPATH builds, so that it will -I the appropriate @@ -282,9 +268,9 @@ if test "$PMISHIM_TOP_BUILDDIR" != "$PMISHIM_TOP_SRCDIR"; then else CPP_INCLUDES='-I$(top_srcdir) -I$(top_srcdir)/src/include'" $CPPFLAGS" fi -CPPFLAGS="$CPP_INCLUDES $CPPFLAGS $pmix_CPPFLAGS" -LDFLAGS="$LDFLAGS $pmix_LDFLAGS" -LIBS="$LIBS $pmix_LIBS" +CPPFLAGS="$CPP_INCLUDES $CPPFLAGS $pmishim_CPPFLAGS" +LDFLAGS="$LDFLAGS $pmishim_LDFLAGS" +LIBS="$LIBS $pmishim_LIBS" # # Delayed the substitution of CFLAGS and CXXFLAGS until now because @@ -317,4 +303,5 @@ AC_MSG_RESULT([$LIBS]) pmishim_show_title "Configuration complete" AC_OUTPUT +PMISHIM_SUMMARY_PRINT diff --git a/contrib/make_dist_tarball b/contrib/make_dist_tarball new file mode 100755 index 0000000..80159e9 --- /dev/null +++ b/contrib/make_dist_tarball @@ -0,0 +1,415 @@ +#!/bin/sh +# +# Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2008-2018 Cisco Systems, Inc. All rights reserved +# Copyright (c) 2015-2019 Intel, Inc. All rights reserved. +# Copyright (c) 2019 Amazon.com, Inc. or its affiliates. All Rights +# reserved. +# Copyright (c) 2023 Nanook Consulting. All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# +# Version of auto tools that we want +# + +M4_TARGET_VERSION=1.4.17 +AM_TARGET_VERSION=1.15 +AC_TARGET_VERSION=2.69 +LT_TARGET_VERSION=2.4.6 + +# +# When running "make distcheck", use these parallelization flags. Can +# significantly decrease the time required for "make distcheck" because +# that target includes multiple builds of the entire code base. +# + +DISTCHECK_MAKE_FLAGS=-j4 + +######################################################################### + +# +# Check command line flags +# + +# Default to requiring *exact* versions if we're making distribution +# tarballs; but higher-than-expected versions are ok for +# non-distribution tarballs. +dirty_ok=0 +gnu_version_ignore=0 +mac=0 +dist_target=distcheck +distcheck_flags="AM_MAKEFLAGS=$DISTCHECK_MAKE_FLAGS" +if test "`basename $0`" = "make_tarball"; then + dist_target=dist + distcheck_flags= + highok=1 + dirty_ok=1 +else + highok=0 +fi + +greekonly=0 +autogen_args= +config_args= +distdir=".." +for i in "$@"; do + case $i in + -greekonly) greekonly=1 ;; + --greekonly) greekonly=1 ;; + -highok) highok=1 ;; + --highok) highok=1 ;; + -autogen-args=*) autogen_args="${i#*=}"; shift ;; + --autogen-args=*) autogen_args="${i#*=}"; shift ;; + -config-args=*) config_args="${i#*=}"; shift ;; + --config-args=*) config_args="${i#*=}"; shift ;; + -distdir=*) distdir="${i#*=}"; shift ;; + --distdir=*) distdir="${i#*=}"; shift ;; + --dirtyok) dirty_ok=1 ;; + --verok) gnu_version_ignore=1 ;; + -verok) gnu_version_ignore=1 ;; + --macosx) mac=1 ;; + -macosx) mac=1 ;; + *) + cat <) + --distdir Move the tarball(s) to this directory when done + --dirtyok Ok if the source tree is dirty + --verok Ignore result of autotools version checking + --macosx Executing on Mac OSX, so do not check libtool version +EOF + exit 1 + ;; + esac + shift +done + +export DISTCHECK_CONFIGURE_FLAGS=$config_args + +# +# First things first -- check that the auto versions that we have are +# the ones that we want. +# + +check_gnu_version() { + prog="$1" + target="$2" + + ver="`$prog --version | head -n 1 | sed -e's/([^)]*)//g' -e's/[^0-9 .][^ ]* / /g' -e's/ //g'`" + echo $prog version is $ver + + ver_major=`echo $ver | cut -d. -f1` + ver_minor=`echo $ver | cut -d. -f2` + ver_release=`echo $ver | cut -d. -f3` + if test "$ver_release" = ""; then + ver_release=0 + fi + + target_major=`echo $target | cut -d. -f1` + target_minor=`echo $target | cut -d. -f2` + target_release=`echo $target | cut -d. -f3` + if test "$target_release" = ""; then + target_release=0 + fi + + # Gah -- Libtool released version 2.2.6b, the "b" of which totally + # screws up the -lt and -gt comparisons, below. So strip out any + # trailing letters in the target_release and ver_release variables + # -- if they don't match, we'll just get a "they don't match + # somehow" kind of message (because I'm not going to code up a + # complex/clever alphanumeric lower/higher comparison thingy). + # Sigh. + ver_release=`echo $ver_release | sed 's/[A-Za-z]//g'` + target_release=`echo $target_release | sed 's/[A-Za-z]//g'` + + result=same + if test "$ver" != "$target"; then + if test "$ver_major" -lt "$target_major"; then + result=low + elif test "$ver_major" = "$target_major" -a "$ver_minor" -lt "$target_minor"; then + result=low + elif test "$ver_major" = "$target_major" -a "$ver_minor" = "$target_minor" -a "$ver_release" -lt "$target_release"; then + result=low + elif test "$ver_major" -gt "$target_major"; then + result=high + elif test "$ver_major" = "$target_major" -a "$ver_minor" -gt "$target_minor"; then + result=high + elif test "$ver_major" = "$target_major" -a "$ver_minor" = "$target_minor" -a "$ver_release" = "$target_release"; then + result=same + elif test "$ver_major" = "$target_major" -a "$ver_minor" = "$target_minor" -a "$ver_release" -gt "$target_release"; then + result=high + elif test "$ver_major" = "$target_major" -a "$ver_minor" = "$target_minor" -a "$ver_release" -lt "$target_release"; then + result=low + else + result=unknown + fi + fi + + if test "$result" = "low"; then + cat <&1 && touch success) | tee auto.out + if test ! -f success; then + echo "Autogen failed. Aborting" + exit 1 + fi + + # + # Configure + # + echo "*** Running configure..." + rm -f success + (./configure $config_args 2>&1 && touch success) | tee config.out + if test ! -f success; then + echo "Configure failed. Aborting" + exit 1 + fi + + # + # + # make tarball + # + echo "*** Running make $dist_target..." + save_LD=$LD_LIBRARY_PATH + LD_LIBRARY_PATH= + rm -f success + (eval make $distcheck_flags $dist_target 2>&1 && touch success) | tee dist.out + if test ! -f success; then + echo "Make $dist_target failed. Aborting" + exit 1 + fi + rm -f success + LD_LIBRARY_PATH=$save_LD + + # + # move + # + echo "*** Moving tarballs..." + mv pmishim-* $distdir + + echo "*** All done" +} + +######################################################################### +# main +######################################################################### + +start=`date` +echo "*** Start time: $start" + +echo "*** Checking tools versions..." +check_gnu_version m4 $M4_TARGET_VERSION +check_gnu_version automake $AM_TARGET_VERSION +check_gnu_version autoconf $AC_TARGET_VERSION +if test $mac -eq 0; then + check_gnu_version libtool $LT_TARGET_VERSION +fi +# +# Verify that we're in a top PMISHIM dir +# +echo "*** Checking to ensure in top-level PMI shim directory..." +if test -f VERSION -a -f configure.ac -a -f config/pmishim_summary.m4 ; then + happy=1 +else + echo "Do not appear to be in the PMI shim top directory. Abort!" + exit 1 +fi + +echo "*** Removing old VERSION file..." +rm -f VERSION +echo "*** Restoring pristine VERSION file..." +git checkout VERSION +echo "*** Getting git version number..." +repo_rev=git`git log -1 --oneline | head -1 | cut -d' ' -f1` +echo " Repo rev number: $repo_rev" + +# Sanity checks +if test "$repo_rev" = ""; then + echo "Somehow the repo rev number is empty. Abort!" + exit 1 +elif test "`echo $repo_rev | grep ' '`" != ""; then + echo "Somehow the repo rev number has a space in it -- bad!" + exit 1 +fi + +# Ensure we have a clean repo +if test $dirty_ok -eq 0; then + echo "*** Checking if source tree is dirty..." + dirty=0 + if test "`git status | grep 'Changes not staged for commit'`" != ""; then + dirty=1 + fi + + if test $dirty -eq 1; then + echo " Source tree is dirty. Cannot continue." + exit 1 + fi +fi + +# +# Ditch repo rev from all version numbers +# +echo "*** Removing git version numbers from VERSION..." +version_files=VERSION +release_date=`date '+%b %d, %Y'` +echo " Release date: $release_date" +for file in $version_files; do + echo " - $file" + sed -e 's/^want_repo_rev=.*/want_repo_rev=0/' \ + -e 's/^repo_rev=.*/'repo_rev=$repo_rev/ \ + -e "s/^date=.*/date=\"$release_date\"/" \ + $file > $file.new + cp -f $file.new $file + rm $file.new +done + +# +# Make 2 tarballs: +# +# - one with the greek +# - one without the greek +# +# unless the user specifically said --greekonly, then only make the +# greek tarball. Making both tarballs at once allows us to guarantee +# to have two tarballs -- one greek and one not -- that have exactly +# the same GIT r number (as opposed to, for example, running this +# script to make a greek tarball, then running it again to make a +# non-greek tarball -- there is a race condition that someone could +# commit in the meantime and change the GIT r number in the 2nd +# tarball) +# + +# First, make greek tarball + +echo "*** Making greek tarball" +make_tarball + +# Now if ! --greekonly, make the non-greek tarball + +if test "$greekonly" = "0"; then + echo "*** REMOVING ALL GREEK FROM VERSION NUMBERS!!" + for file in $version_files; do + echo " - $file" + sed -e 's/^greek=.*/greek=/' $file > $file.new + cp -f $file.new $file + rm $file.new + done + echo "Making non-greek tarball" + make_tarball +fi + +# Put the VERSION file back the way it was +git checkout VERSION + +echo " " +echo "*** Start time: $start" +echo "*** Finish time: `date`" diff --git a/contrib/make_tarball b/contrib/make_tarball new file mode 120000 index 0000000..7a8e264 --- /dev/null +++ b/contrib/make_tarball @@ -0,0 +1 @@ +contrib/make_dist_tarball \ No newline at end of file diff --git a/src/pmi2.c b/src/pmi2.c index 6e4ce3b..55c4966 100644 --- a/src/pmi2.c +++ b/src/pmi2.c @@ -55,7 +55,6 @@ PMISHIM_EXPORT int PMI2_Init(int *spawned, int *size, int *rank, int *appnum) pmix_proc_t proc = myproc; proc.rank = PMIX_RANK_WILDCARD; -fprintf(stderr, "PMI2_INIT\n"); if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc, NULL, 0))) { /* if we didn't see a PMIx server (e.g., missing envar), * then allow us to run as a singleton */ @@ -573,7 +572,7 @@ PMISHIM_EXPORT int PMI2_Info_GetJobAttr(const char name[], char value[], int val /* PMI-2 expects resource manager to set * process mapping in ANL notation. */ - if (!strcmp(name, ANL_MAPPING)) { + if (0 == strcmp(name, ANL_MAPPING)) { /* we are looking in the job-data. If there is nothing there * we don't want to look in rank's data, thus set rank to widcard */ proc = myproc;