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 <daniel.verkamp@intel.com>
This commit is contained in:
Daniel Verkamp 2016-07-20 13:31:39 -07:00
parent c61efe3950
commit 08ac16c978

View File

@ -252,6 +252,7 @@ struct spdk_subsystem {
struct spdk_subsystem_depend { struct spdk_subsystem_depend {
const char *name; const char *name;
const char *depends_on; const char *depends_on;
struct spdk_subsystem *depends_on_subsystem;
TAILQ_ENTRY(spdk_subsystem_depend) tailq; 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 * \brief Register a new subsystem
*/ */
#define SPDK_SUBSYSTEM_REGISTER(_name, _init, _fini, _config) \ #define SPDK_SUBSYSTEM_REGISTER(_name, _init, _fini, _config) \
static struct spdk_subsystem __subsystem_ ## _name = { \ struct spdk_subsystem __spdk_subsystem_ ## _name = { \
.name = #_name, \ .name = #_name, \
.init = _init, \ .init = _init, \
.fini = _fini, \ .fini = _fini, \
@ -270,16 +271,18 @@ void spdk_add_subsystem_depend(struct spdk_subsystem_depend *depend);
}; \ }; \
__attribute__((constructor)) static void _name ## _register(void) \ __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. * \brief Declare that a subsystem depends on another subsystem.
*/ */
#define SPDK_SUBSYSTEM_DEPEND(_name, _depends_on) \ #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 = { \ static struct spdk_subsystem_depend __subsystem_ ## _name ## _depend_on ## _depends_on = { \
.name = #_name, \ .name = #_name, \
.depends_on = #_depends_on, \ .depends_on = #_depends_on, \
.depends_on_subsystem = &__spdk_subsystem_ ## _depends_on, \
}; \ }; \
__attribute__((constructor)) static void _name ## _depend_on ## _depends_on(void) \ __attribute__((constructor)) static void _name ## _depend_on ## _depends_on(void) \
{ \ { \