diff --git a/opal/mca/hwloc/external/configure.m4 b/opal/mca/hwloc/external/configure.m4 index b150bc4328..4944d83bf1 100644 --- a/opal/mca/hwloc/external/configure.m4 +++ b/opal/mca/hwloc/external/configure.m4 @@ -111,11 +111,29 @@ AC_DEFUN([MCA_opal_hwloc_external_CONFIG],[ # Must set this variable so that the framework m4 knows # what file to include in opal/mca/hwloc/hwloc.h - opal_hwloc_external_include="$opal_hwloc_dir/include/hwloc.h" + opal_hwloc_external_include="opal/mca/hwloc/external/external.h" opal_hwloc_external_ADD_CPPFLAGS=$opal_hwloc_external_CPPFLAGS opal_hwloc_external_ADD_LDFLAGS=$opal_hwloc_external_LDFLAGS opal_hwloc_external_ADD_LIBS=$opal_hwloc_external_LIBS + # We have to do some extra indirection to get the + # OPAL_HWLOC_WANT_VERBS_HELPER to work. First, the + # opal_hwloc_external_include file (set above), points to a + # file here in this component. That file will include the + # actual external hwloc.h file (via the + # MCA_hwloc_external_header define). And if + # OPAL_HWLOC_WANT_VERBS_HELPER is set, that file will + # include the external hwloc/openfabrics-verbs.h file (via + # the MCA_hwloc_external_openfabrics_helper define). + AC_DEFINE_UNQUOTED(MCA_hwloc_external_header, + ["$opal_hwloc_dir/include/hwloc.h"], + [Location of external hwloc header]) + AC_DEFINE_UNQUOTED(MCA_hwloc_external_openfabrics_header, + ["$opal_hwloc_dir/include/hwloc/openfabrics-verbs.h"], + [Location of external hwloc header]) + + AC_CHECK_HEADERS([infiniband/verbs.h]) + # These flags need to get passed to the wrapper compilers # (this is unnecessary for the internal/embedded hwloc) opal_hwloc_external_ADD_WRAPPER_EXTRA_LDFLAGS="$WRAPPER_EXTRA_LDFLAGS $opal_hwloc_external_LDFLAGS" diff --git a/opal/mca/hwloc/external/external.h b/opal/mca/hwloc/external/external.h new file mode 100644 index 0000000000..bc693b22a9 --- /dev/null +++ b/opal/mca/hwloc/external/external.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. + * + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + * When this component is used, this file is included in the rest of + * the OPAL/ORTE/OMPI code base via opal/mca/event/event.h. As such, + * this header represents the public interface to this static component. + */ + +#ifndef MCA_OPAL_HWLOC_EXTERNAL_H +#define MCA_OPAL_HWLOC_EXTERNAL_H + +BEGIN_C_DECLS + +#include MCA_hwloc_external_header + +/* If the including file requested it, also include the hwloc verbs + helper file. We can't just always include this file (even if we + know we have ) because there are some inline + functions in that file that invoke ibv_* functions. Some linkers + (e.g., Solaris Studio Compilers) will instantiate those static + inline functions even if we don't use them, and therefore we need + to be able to resolve the ibv_* symbols at link time. + + Since -libverbs is only specified in places where we use other + ibv_* functions (e.g., the OpenFabrics-based BTLs), that means that + linking random executables can/will fail (e.g., orterun). + */ +#if defined(OPAL_HWLOC_WANT_VERBS_HELPER) && OPAL_HWLOC_WANT_VERBS_HELPER +# if defined(HAVE_INFINIBAND_VERBS_H) +# include MCA_hwloc_external_openfabrics_header +# else +# error Tried to include hwloc verbs helper file, but hwloc was compiled with no OpenFabrics support +# endif +#endif + +END_C_DECLS + +#endif /* MCA_OPAL_HWLOC_EXTERNAL_H */