This is a bad idea.
I'm trying to remember the reason why, but we explicitly *removed* such -l
statements (e.g., removed "-lmpi" from the plugins). Hmm... Oh, right. Every
time I think I understand linkers, I find out that I don't. So last time we
had a Big Confusion Discussion About Linkers (BCDAL), I wrote it all up:
https://svn.open-mpi.org/trac/ompi/wiki/Linkers
The 4th column in these tables is labeled "OMPI DSO components depend on
libmpi.so?" (which is somewhat of a misnomer, because not all components are at
the MPI layer -- so consider it to mean "OMPI DSO components depend on some
OMPI library, such as libmpi.so?")
The problem cases are #9 and #12 in the first table: i.e., static linking.
Instead, we use lt_dladvise() to open hwloc plugins in the same scope as the
main application.
Of course, this has its own tradeoffs -- if hwloc itself, is opened as a plugin
in a private scope, then the plugins won't be able to find the symbols it needs
(i.e., cases #14, #15, #17, #18, #20, #21, #23, and #24 in the 2nd table).
Until POSIX effects hierarchical linker scopes (or at least something like
"please dlopen this plugin and put it in XYZ linker scope"), there's really no
good solution here. :-(
On Sep 5, 2012, at 6:03 AM, <[email protected]> wrote:
> Author: bgoglin (Brice Goglin)
> Date: 2012-09-05 06:03:52 EDT (Wed, 05 Sep 2012)
> New Revision: 4815
> URL: https://svn.open-mpi.org/trac/hwloc/changeset/4815
>
> Log:
> Pass -lhwloc to all plugins, at least Darwin wants it
> (plugins use some hwloc functions)
>
> Define a plugins_ldflags with all common stuff for plugins
> (this somehow reverts r4811)
>
> Text files modified:
> branches/components/src/Makefile.am | 13 +++++++------
>
> 1 files changed, 7 insertions(+), 6 deletions(-)
>
> Modified: branches/components/src/Makefile.am
> ==============================================================================
> --- branches/components/src/Makefile.am Wed Sep 5 06:03:36 2012
> (r4814)
> +++ branches/components/src/Makefile.am 2012-09-05 06:03:52 EDT (Wed,
> 05 Sep 2012) (r4815)
> @@ -21,6 +21,7 @@
>
> pluginsdir = $(libdir)/hwloc
> plugins_LTLIBRARIES =
> +plugins_ldflags = -module -avoid-version -lhwloc
> AM_CPPFLAGS += -DHWLOC_PLUGINS_DIR=\"$(pluginsdir)\"
>
> # Sources and ldflags
> @@ -40,7 +41,6 @@
> topology-xml.c \
> topology-xml-nolibxml.c
> ldflags =
> -common_ldflags =
>
> # Conditionally add to the sources and ldflags
>
> @@ -52,7 +52,7 @@
> xml_libxml_la_SOURCES = topology-xml-libxml.c
> xml_libxml_la_CPPFLAGS = $(AM_CPPFLAGS) -DHWLOC_BUILD_PLUGIN
> xml_libxml_la_CFLAGS = $(AM_CFLAGS) $(HWLOC_LIBXML2_CFLAGS)
> -xml_libxml_la_LDFLAGS = $(common_ldflags) -module -avoid-version
> $(HWLOC_LIBXML2_LIBS)
> +xml_libxml_la_LDFLAGS = $(plugins_ldflags) $(HWLOC_LIBXML2_LIBS)
> endif
> endif HWLOC_HAVE_LIBXML2
>
> @@ -64,7 +64,7 @@
> core_libpci_la_SOURCES = topology-libpci.c
> core_libpci_la_CPPFLAGS = $(AM_CPPFLAGS) -DHWLOC_BUILD_PLUGIN
> core_libpci_la_CFLAGS = $(AM_CFLAGS) $(HWLOC_PCI_CFLAGS)
> -core_libpci_la_LDFLAGS = $(common_ldflags) -module -avoid-version
> $(HWLOC_PCI_LIBS)
> +core_libpci_la_LDFLAGS = $(plugins_ldflags) $(HWLOC_PCI_LIBS)
> endif
> endif HWLOC_HAVE_LIBPCI
>
> @@ -105,7 +105,8 @@
> endif HWLOC_HAVE_FREEBSD
>
> if HWLOC_HAVE_GCC
> -common_ldflags += -no-undefined
> +ldflags += -no-undefined
> +plugins_ldflags += -no-undefined
> endif HWLOC_HAVE_GCC
>
> if HWLOC_HAVE_WINDOWS
> @@ -136,7 +137,7 @@
> # Installable library
>
> libhwloc_la_SOURCES = $(sources)
> -libhwloc_la_LDFLAGS = $(common_ldflags) $(ldflags) -version-info
> $(libhwloc_so_version) $(HWLOC_LIBS)
> +libhwloc_la_LDFLAGS = $(ldflags) -version-info $(libhwloc_so_version)
> $(HWLOC_LIBS)
>
> if HWLOC_HAVE_PLUGINS
> AM_CPPFLAGS += $(LTDLINCL)
> @@ -168,5 +169,5 @@
> check_LTLIBRARIES = core_fake.la
> core_fake_la_SOURCES = topology-fake.c
> core_fake_la_CPPFLAGS = $(AM_CPPFLAGS) -DHWLOC_BUILD_PLUGIN
> -core_fake_la_LDFLAGS = $(common_ldflags) -module -avoid-version -rpath
> /nowhere # force libtool to build a shared-library even it's check-only
> +core_fake_la_LDFLAGS = $(plugins_ldflags) -rpath /nowhere # force libtool to
> build a shared-library even it's check-only
> endif
> _______________________________________________
> hwloc-svn mailing list
> [email protected]
> http://www.open-mpi.org/mailman/listinfo.cgi/hwloc-svn
--
Jeff Squyres
[email protected]
For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/