From de4bbacd1305d23a17486cf3f098a1f06302e456 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Wed, 9 May 2012 20:18:31 +0000 Subject: [PATCH] It turns out that we can't always include the hwloc OpenFabrics verbs helper file, even if we find that the system has . The reason is because there are some inline functions in that verbs helper 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. But 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). So instead, introduce a new #define: OPAL_HWLOC_WANT_VERBS_HELPER. If this macro is set to 1 before including opal/mca/hwloc/hwloc.h, then you'll also get the hwloc OpenFabrics verbs helper header file (*if* hwloc found -- otherwise, it'll #error). This commit was SVN r26417. --- ompi/mca/btl/openib/btl_openib_component.c | 6 ++++++ opal/mca/hwloc/hwloc132/hwloc132.h | 22 ++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ompi/mca/btl/openib/btl_openib_component.c b/ompi/mca/btl/openib/btl_openib_component.c index 4c3d228e87..a607aedd27 100644 --- a/ompi/mca/btl/openib/btl_openib_component.c +++ b/ompi/mca/btl/openib/btl_openib_component.c @@ -60,6 +60,12 @@ const char *ibv_get_sysfs_path(void); #include "opal/util/argv.h" #include "opal/memoryhooks/memory.h" #include "opal/mca/base/mca_base_param.h" +/* Define this before including hwloc.h so that we also get the hwloc + verbs helper header file, too. We have to do this level of + indirection because the hwloc subsystem is a component -- we don't + know its exact path. We have to rely on the framework header files + to find the right hwloc verbs helper file for us. */ +#define OPAL_HWLOC_WANT_VERBS_HELPER 1 #include "opal/mca/hwloc/hwloc.h" #include "opal/mca/hwloc/base/base.h" #include "opal/mca/installdirs/installdirs.h" diff --git a/opal/mca/hwloc/hwloc132/hwloc132.h b/opal/mca/hwloc/hwloc132/hwloc132.h index 2544a506d9..53b3123f40 100644 --- a/opal/mca/hwloc/hwloc132/hwloc132.h +++ b/opal/mca/hwloc/hwloc132/hwloc132.h @@ -19,10 +19,24 @@ BEGIN_C_DECLS #include "hwloc/include/hwloc.h" -/* If we have verbs.h, then include the hwloc openfabrics helpers - header file */ -#if defined(HAVE_INFINIBAND_VERBS_H) -#include "hwloc/include/hwloc/openfabrics-verbs.h" +/* 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 "hwloc/include/hwloc/openfabrics-verbs.h" +# else +# error Tried to include hwloc verbs helper file, but hwloc was compiled with no OpenFabrics support +# endif #endif END_C_DECLS