Commit 08ac16c9 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

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: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent c61efe39
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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)	\
	{											\