From a67421b301ae5328fd46c866f6dd510a71862377 Mon Sep 17 00:00:00 2001 From: Ryan Sundberg Date: Thu, 9 Sep 2021 21:24:41 -0700 Subject: [PATCH] Rump component_simple.c: Add _IOCONF_NO_CFDRIVER_DECL option Some rump components (libpci_virtio, libvirtio_if_vioif, libvirtio_vioscsi) include their CFDRIVER_DECL(s) via their SRCS. When they link in component_simple to initialize their RUMP_COMPONENT, their CFDRIVER_DECLs are redefined in ioconf.c. This causes linker errors when trying to load these libraries. See: https://github.com/rumpkernel/rumprun/issues/129 Add a preprocessor directive _IO_CONF_NO_CFDRIVER_DECL which will disable redefining the CFDRIVER_DECLs in component_simple when defined. --- sys/rump/dev/lib/component_simple.c | 8 ++++++++ sys/rump/dev/lib/libpci_virtio/Makefile | 1 + sys/rump/dev/lib/libvirtio_if_vioif/Makefile | 3 ++- sys/rump/dev/lib/libvirtio_vioscsi/Makefile | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/rump/dev/lib/component_simple.c b/sys/rump/dev/lib/component_simple.c index b2ed7a88f93a3..d2683d1c53a2f 100644 --- a/sys/rump/dev/lib/component_simple.c +++ b/sys/rump/dev/lib/component_simple.c @@ -35,6 +35,14 @@ __KERNEL_RCSID(0, "$NetBSD: component_simple.c,v 1.3 2016/01/26 23:12:14 pooka E #include + +#ifdef _IOCONF_NO_CFDRIVER_DECL +/* + * XXX Don't allow ioconf.c to redefine struct cfdrivers. + */ +#undef CFDRIVER_DECL +#define CFDRIVER_DECL(name, class, attr) +#endif #include "ioconf.c" #define CONFIG_INIT_COMPONENT(a) config_init_component( \ diff --git a/sys/rump/dev/lib/libpci_virtio/Makefile b/sys/rump/dev/lib/libpci_virtio/Makefile index dc8c8d4350281..d767cc0118437 100644 --- a/sys/rump/dev/lib/libpci_virtio/Makefile +++ b/sys/rump/dev/lib/libpci_virtio/Makefile @@ -14,6 +14,7 @@ RUMP_COMPONENT=ioconf SRCS+= virtio.c CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern +CPPFLAGS+= -D_IOCONF_NO_CFDRIVER_DECL .include "${RUMPTOP}/Makefile.rump" .include diff --git a/sys/rump/dev/lib/libvirtio_if_vioif/Makefile b/sys/rump/dev/lib/libvirtio_if_vioif/Makefile index f8bb0f111d634..de602d3cf7ab9 100644 --- a/sys/rump/dev/lib/libvirtio_if_vioif/Makefile +++ b/sys/rump/dev/lib/libvirtio_if_vioif/Makefile @@ -13,7 +13,8 @@ RUMP_COMPONENT=ioconf SRCS+= if_vioif.c -CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern +CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern +CPPFLAGS+= -D_IOCONF_NO_CFDRIVER_DECL .include "${RUMPTOP}/Makefile.rump" .include diff --git a/sys/rump/dev/lib/libvirtio_vioscsi/Makefile b/sys/rump/dev/lib/libvirtio_vioscsi/Makefile index d91c40573085a..bb8aafe585a11 100644 --- a/sys/rump/dev/lib/libvirtio_vioscsi/Makefile +++ b/sys/rump/dev/lib/libvirtio_vioscsi/Makefile @@ -14,6 +14,7 @@ RUMP_COMPONENT=ioconf SRCS+= vioscsi.c CPPFLAGS+= -I${RUMPTOP}/librump/rumpkern +CPPFLAGS+= -D_IOCONF_NO_CFDRIVER_DECL .include "${RUMPTOP}/Makefile.rump" .include