From 08ac16c978c55b1d217e067fc192ed3526cedda4 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Wed, 20 Jul 2016 13:31:39 -0700 Subject: [PATCH] subsystem: add explicit symbol reference in DEPEND Make SPDK_SUBSYSTEM_REGISTER export a symbol that SPDK_SUBSYSTEM_DEPEND will reference as an extern. This makes sure that dependencies are included by the linker without needing -Wl,--whole-archive around the subsystem libraries. Change-Id: Id2e3c589d5a49bba1df6603a8e27dd2a7e7b44b7 Signed-off-by: Daniel Verkamp --- include/spdk/event.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/spdk/event.h b/include/spdk/event.h index 4b1f64c6d4..2e54333198 100644 --- a/include/spdk/event.h +++ b/include/spdk/event.h @@ -252,6 +252,7 @@ struct spdk_subsystem { struct spdk_subsystem_depend { const char *name; const char *depends_on; + struct spdk_subsystem *depends_on_subsystem; TAILQ_ENTRY(spdk_subsystem_depend) tailq; }; @@ -262,7 +263,7 @@ void spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend); * \brief Register a new subsystem */ #define SPDK_SUBSYSTEM_REGISTER(_name, _init, _fini, _config) \ - static struct spdk_subsystem __subsystem_ ## _name = { \ + struct spdk_subsystem __spdk_subsystem_ ## _name = { \ .name = #_name, \ .init = _init, \ .fini = _fini, \ @@ -270,16 +271,18 @@ void spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend); }; \ __attribute__((constructor)) static void _name ## _register(void) \ { \ - spdk_add_subsystem(&__subsystem_ ## _name); \ + spdk_add_subsystem(&__spdk_subsystem_ ## _name); \ } /** * \brief Declare that a subsystem depends on another subsystem. */ #define SPDK_SUBSYSTEM_DEPEND(_name, _depends_on) \ + extern struct spdk_subsystem __spdk_subsystem_ ## _depends_on; \ static struct spdk_subsystem_depend __subsystem_ ## _name ## _depend_on ## _depends_on = { \ .name = #_name, \ .depends_on = #_depends_on, \ + .depends_on_subsystem = &__spdk_subsystem_ ## _depends_on, \ }; \ __attribute__((constructor)) static void _name ## _depend_on ## _depends_on(void) \ { \