Skip to content

Commit

Permalink
Cleanup a bit
Browse files Browse the repository at this point in the history
Check visibility and define PMISHIM_EXPORT accordingly.
Update pmi.h to deal with backwards compatibility by
carrying some definitions that were recently dropped.

Signed-off-by: Ralph Castain <[email protected]>
  • Loading branch information
rhc54 committed Nov 28, 2023
1 parent 26d5a8d commit 5d47f44
Show file tree
Hide file tree
Showing 13 changed files with 588 additions and 70 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ config/lt~obsolete.m4
config/missing
configure
libtool
src/include/pmishim_config.h.in
Makefile
config.status
config/depcomp
include/version.h
include/pmishim_version.h
src/.deps/
src/.libs/
src/Makefile
src/include/pmishim_config.h
src/include/pmishim_config.h.in
src/include/stamp-h1
src/include/version.h

3 changes: 2 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ EXTRA_DIST = \
README.md VERSION COPYING AUTHORS \
config/pmishim_get_version.sh

SUBDIRS = src
SUBDIRS = include src

4 changes: 2 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ release=0
# requirement is that it must be entirely printable ASCII characters
# and have no white space.

greek=rc1
greek=a1

# The date when this release was created

Expand All @@ -39,4 +39,4 @@ snapshot_version=${major}.${minor}.${release}${greek}-git
# 2. Version numbers are described in the Libtool current:revision:age
# format.

libpmishim_so_version=0:0:0
libpmishim_so_version=1:0:0
94 changes: 94 additions & 0 deletions config/pmishim_check_visibility.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 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-2007 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) 2006-2015 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2009-2011 Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2017 Intel, Inc. All rights reserved.
# Copyright (c) 2021-2023 Nanook Consulting. All rights reserved.
# Copyright (c) 2022 Amazon.com, Inc. or its affiliates. All Rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

# PMISHIM_CHECK_VISIBILITY
# --------------------------------------------------------
AC_DEFUN([PMISHIM_CHECK_VISIBILITY],[
AC_REQUIRE([AC_PROG_GREP])

# Check if the compiler has support for visibility, like some
# versions of gcc, icc Sun Studio cc.
AC_ARG_ENABLE(visibility,
AS_HELP_STRING([--enable-visibility],
[enable visibility feature of certain compilers/linkers (default: enabled)]))

WANT_VISIBILITY=0
pmishim_msg="whether to enable symbol visibility"

if test "$enable_visibility" = "no"; then
AC_MSG_CHECKING([$pmishim_msg])
AC_MSG_RESULT([no (disabled)])
else
CFLAGS_orig=$CFLAGS

pmishim_add=
case "$oac_cv_c_compiler_vendor" in
sun)
# Check using Sun Studio -xldscope=hidden flag
pmishim_add=-xldscope=hidden
CFLAGS="$pmishim_add -errwarn=%all"
;;

*)
# Check using -fvisibility=hidden
pmishim_add=-fvisibility=hidden
CFLAGS="$pmishim_add -Werror"
;;
esac

AC_MSG_CHECKING([if $CC supports $pmishim_add])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
__attribute__((visibility("default"))) int foo;
]],[[fprintf(stderr, "Hello, world\n");]])],
[AS_IF([test -s conftest.err],
[$GREP -iq visibility conftest.err
# If we find "visibility" in the stderr, then
# assume it doesn't work
AS_IF([test "$?" = "0"], [pmishim_add=])])
], [pmishim_add=])
AS_IF([test "$pmishim_add" = ""],
[AC_MSG_RESULT([no])],
[AC_MSG_RESULT([yes])])

CFLAGS=$CFLAGS_orig
PMISHIM_VISIBILITY_CFLAGS=$pmishim_add

if test "$pmishim_add" != "" ; then
WANT_VISIBILITY=1
CFLAGS="$CFLAGS $PMISHIM_VISIBILITY_CFLAGS"
AC_MSG_CHECKING([$pmishim_msg])
AC_MSG_RESULT([yes (via $pmishim_add)])
elif test "$enable_visibility" = "yes"; then
AC_MSG_ERROR([Symbol visibility support requested but compiler does not seem to support it. Aborting])
else
AC_MSG_CHECKING([$pmishim_msg])
AC_MSG_RESULT([no (unsupported)])
fi
unset pmishim_add
fi

AC_DEFINE_UNQUOTED([PMISHIM_HAVE_VISIBILITY], [$WANT_VISIBILITY],
[Whether C compiler supports symbol visibility or not])
])
17 changes: 12 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ AC_LANG([C])

AC_INIT([pmi-shim],[m4_normalize(esyscmd([config/pmishim_get_version.sh VERSION --tarball]))],
[https://github.com/openpmix/pmi-shim/issues],[pmishim])
AC_PREREQ([2.71])
AC_PREREQ([2.70])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(./config)

Expand Down Expand Up @@ -92,8 +92,8 @@ pmishim_show_subtitle "Checking versions"

# Get the version of PMI-SHIM that we are installing

PMISHIM_SAVE_VERSION([pmishim], [PMI-SHIM], [$srcdir/VERSION],
[include/version.h])
PMISHIM_SAVE_VERSION([PMISHIM], [PMI-SHIM], [$srcdir/VERSION],
[include/pmishim_version.h])

# Get shared library version numbers

Expand Down Expand Up @@ -152,7 +152,13 @@ AH_TOP([/* -*- c -*-
#ifndef PMISHIM_CONFIG_H
#define PMISHIM_CONFIG_H

#include "pmishim_config_top.h"
#undef PMISHIM_HAVE_VISIBILITY

#if PMISHIM_HAVE_VISIBILITY == 1
#define PMISHIM_EXPORT __attribute__((__visibility__("default")))
#else
#define PMISHIM_EXPORT
#endif

])
AH_BOTTOM([
Expand All @@ -163,7 +169,7 @@ AH_BOTTOM([
# Other basic setup stuff

PMISHIM_BASIC_SETUP

PMISHIM_CHECK_VISIBILITY

############################################################################
# Configuration options
Expand Down Expand Up @@ -292,6 +298,7 @@ AC_SUBST(CXXFLAGS)
AC_CONFIG_FILES([
Makefile
src/Makefile
include/Makefile
])

AC_MSG_CHECKING([final CPPFLAGS])
Expand Down
17 changes: 17 additions & 0 deletions include/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (c) 2023 Nanook Consulting All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#

# Install the PMI headers

include_HEADERS = \
pmi.h \
pmi2.h

nodist_include_HEADERS = \
pmishim_version.h
Loading

0 comments on commit 5d47f44

Please sign in to comment.