Skip to contentSkip to conversation

contrib/plugins: add Darwin support

PATCH In review Paolo Bonzini 2 participants 2 messages Sep 7, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 contrib/plugins: add Darwin support

Under Darwin, using -shared makes it impossible to have undefined symbols and -bundle has to be used instead; so detect the OS and use different options.

Based-on: <[email protected]>

---
This replaces Philippe's patch to link with GLib, and also fixes errors like

"_qemu_plugin_get_hwaddr", referenced from:
_vcpu_mem in execlog.o

I guess this shows that we're kinda losing in not using Meson for the plugins, but as I said I appreciate the didactic value of using a standalone Makefile (with only a handful of lines in configure).

 contrib/plugins/Makefile | 4 ++++
 1 file changed, 4 insertions(+)
contrib/plugins/Makefile +4 -0
index db1bd04dfa6..c26fa08441e 100644
@@ -37,7 +37,11 @@ all: $(SONAMES)
 	$(CC) $(CFLAGS) -c -o $@ $<
 
 lib%.so: %.o
+ifeq ($(CONFIG_DARWIN),y)
+	$(CC) -bundle -Wl,-undefined,dynamic_lookup -o $@ $^ $(LDLIBS)
+else
 	$(CC) -shared -o $@ $^ $(LDLIBS)
+endif
 
 clean:
 	rm -f *.o *.so *.d
Signature · 1 line
2.41.0
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 13 lines · Paolo Bonzini

Under Darwin, using -shared makes it impossible to have undefined symbols and -bundle has to be used instead; so detect the OS and use different options.

Based-on: <[email protected]>

---
This replaces Philippe's patch to link with GLib, and also fixes errors like

"_qemu_plugin_get_hwaddr", referenced from:
_vcpu_mem in execlog.o

Quoted 7 lines

I guess this shows that we're kinda losing in not using Meson for the plugins, but as I said I appreciate the didactic value of using a standalone Makefile (with only a handful of lines in configure).

  contrib/plugins/Makefile | 4 ++++
  1 file changed, 4 insertions(+)