Skip to contentSkip to conversation

ui: add x_keymap.o to modules

PATCH In review Paolo Bonzini 3 participants 10 messages May 17, 2018 – May 18, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui: add x_keymap.o to modules

x_keymap.o is common to the SDL and GTK+ modules, and it causes the QEMU binary to link to the X11 libraries. Add it separately to the modules to keep the main QEMU binary smaller.

---
 ui/Makefile.objs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
ui/Makefile.objs +7 -4
index cc78434..00f6976 100644
@@ -15,10 +15,6 @@ common-obj-$(CONFIG_COCOA) += cocoa.o
 common-obj-$(CONFIG_VNC) += $(vnc-obj-y)
 common-obj-$(call lnot,$(CONFIG_VNC)) += vnc-stubs.o
 
-common-obj-$(CONFIG_X11) += x_keymap.o
-x_keymap.o-cflags := $(X11_CFLAGS)
-x_keymap.o-libs := $(X11_LIBS)
-
 # ui-sdl module
 common-obj-$(CONFIG_SDL) += sdl.mo
 ifeq ($(CONFIG_SDLABI),1.2)
@@ -46,6 +42,13 @@ gtk.mo-objs += gtk-gl-area.o
 endif
 endif
 
+ifeq ($(CONFIG_X11),y)
+sdl.mo-objs += x_keymap.o
+gtk.mo-objs += x_keymap.o
+x_keymap.o-cflags := $(X11_CFLAGS)
+x_keymap.o-libs := $(X11_LIBS)
+endif
+
 common-obj-$(CONFIG_CURSES) += curses.mo
 curses.mo-objs := curses.o
 curses.mo-cflags := $(CURSES_CFLAGS)
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 25 lines · Paolo Bonzini

x_keymap.o is common to the SDL and GTK+ modules, and it causes the QEMU binary to link to the X11 libraries. Add it separately to the modules to keep the main QEMU binary smaller.

---
 ui/Makefile.objs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
ui/Makefile.objs +0 -4
index cc78434..00f6976 100644
@@ -15,10 +15,6 @@ common-obj-$(CONFIG_COCOA) += cocoa.o
 common-obj-$(CONFIG_VNC) += $(vnc-obj-y)
 common-obj-$(call lnot,$(CONFIG_VNC)) += vnc-stubs.o
 
-common-obj-$(CONFIG_X11) += x_keymap.o
-x_keymap.o-cflags := $(X11_CFLAGS)
-x_keymap.o-libs := $(X11_LIBS)
-
 # ui-sdl module
 common-obj-$(CONFIG_SDL) += sdl.mo
 ifeq ($(CONFIG_SDLABI),1.2)

ui/Makefile.objs gtk.mo-objs += gtk-gl-area.o · line 47

Quoted 6 lines
ui/Makefile.objs +3 -0
@@ -46,6 +42,13 @@ gtk.mo-objs += gtk-gl-area.o
 endif
 endif
 
+ifeq ($(CONFIG_X11),y)
+sdl.mo-objs += x_keymap.o
+gtk.mo-objs += x_keymap.o

Would this cause symbol clash if both sdl & gtk modules are loaded at the same time, or have we used linker scripts to limit what symbols each module exposes ?

Quoted 11 lines
ui/Makefile.objs +4 -0
+x_keymap.o-cflags := $(X11_CFLAGS)
+x_keymap.o-libs := $(X11_LIBS)
+endif
+
 common-obj-$(CONFIG_CURSES) += curses.mo
 curses.mo-objs := curses.o
 curses.mo-cflags := $(CURSES_CFLAGS)
Signature · 1 line
1.8.3.1

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#2 lore raw
Quoted 7 lines · Daniel P. Berrangé

ui/Makefile.objs gtk.mo-objs += gtk-gl-area.o · line 47

Quoted 3 lines
ui/Makefile.objs +3 -0
+ifeq ($(CONFIG_X11),y)
+sdl.mo-objs += x_keymap.o
+gtk.mo-objs += x_keymap.o

Would this cause symbol clash if both sdl & gtk modules are loaded at the same time, or have we used linker scripts to limit what symbols each module exposes ?

We don't, but: 1) the file has only functions and no data; 2) in any case the symbols are the same, so it is not a real clash.

Adding linker scripts would be a nice improvement, but it is not necessary for this patch.

Another possibility would be to include x_keymap.c in the files that use it and make qemu_xkeymap_mapping_table static, but I think it would be the worst.

Paolo

#3 lore raw
Quoted 11 lines · Paolo Bonzini
Quoted 7 lines · Daniel P. Berrangé

ui/Makefile.objs gtk.mo-objs += gtk-gl-area.o · line 47

Quoted 3 lines
ui/Makefile.objs +3 -0
+ifeq ($(CONFIG_X11),y)
+sdl.mo-objs += x_keymap.o
+gtk.mo-objs += x_keymap.o

Would this cause symbol clash if both sdl & gtk modules are loaded at the same time, or have we used linker scripts to limit what symbols each module exposes ?

We don't, but: 1) the file has only functions and no data; 2) in any case the symbols are the same, so it is not a real clash.

Ok, as long as dlopen() doesn't whine its fine with me.

Quoted 2 lines

Adding linker scripts would be a nice improvement, but it is not necessary for this patch.

Agreed.

Quoted 3 lines

Another possibility would be to include x_keymap.c in the files that use it and make qemu_xkeymap_mapping_table static, but I think it would be the worst.

It isn't worth trying to be too clever since we're deleting SDL1 in the 2.14 dev cycle.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#4 lore raw
In reply to Daniel P. Berrangé

Hi,

Quoted 7 lines

ui/Makefile.objs gtk.mo-objs += gtk-gl-area.o · line 47

Quoted 3 lines
ui/Makefile.objs +3 -0
+ifeq ($(CONFIG_X11),y)
+sdl.mo-objs += x_keymap.o
+gtk.mo-objs += x_keymap.o

Would this cause symbol clash if both sdl & gtk modules are loaded at the same time, or have we used linker scripts to limit what symbols each module exposes ?

Related: can modules depend on modules, so we could make x_keymap a module of its own and have both gtk and sdl depend on it?

That would also be useful when trying to modularize spice.

cheers,
Gerd

#5 lore raw
Quoted 10 lines · Gerd Hoffmann

Hi,

Quoted 7 lines

ui/Makefile.objs gtk.mo-objs += gtk-gl-area.o · line 47

Quoted 3 lines
ui/Makefile.objs +3 -0
+ifeq ($(CONFIG_X11),y)
+sdl.mo-objs += x_keymap.o
+gtk.mo-objs += x_keymap.o

Would this cause symbol clash if both sdl & gtk modules are loaded at the same time, or have we used linker scripts to limit what symbols each module exposes ?

Quoted 4 lines

Related: can modules depend on modules, so we could make x_keymap a module of its own and have both gtk and sdl depend on it?

That would also be useful when trying to modularize spice.

Yes, you could create a xkeymap.so, and link to that from both sdl.so and gtk.so, so you'll only get one copy of xkeymap.so if both are loaded.

I don't think it is worth it for this particular case though, since we'll be deleting the SDL1 code when 2.14 dev cycle opens, leaving GTK as the only user of it. SDL2 already has abstracted keycodes.

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#6 lore raw
In reply to Gerd Hoffmann
Quoted 10 lines · Gerd Hoffmann

Hi,

Quoted 7 lines

ui/Makefile.objs gtk.mo-objs += gtk-gl-area.o · line 47

Quoted 3 lines
ui/Makefile.objs +3 -0
+ifeq ($(CONFIG_X11),y)
+sdl.mo-objs += x_keymap.o
+gtk.mo-objs += x_keymap.o

Would this cause symbol clash if both sdl & gtk modules are loaded at the same time, or have we used linker scripts to limit what symbols each module exposes ?

Quoted 4 lines

Related: can modules depend on modules, so we could make x_keymap a module of its own and have both gtk and sdl depend on it?

That would also be useful when trying to modularize spice.

How hard would it be to modularize the libspice-server side? The part of the library that is used by QXL rendering should have much fewer dependencies than the part that is used for keyboard, mouse, audio, vmchannel/agent, etc.

Then you could link libspice-server-core into QEMU and libspice-server into the modules. Unless both have been linked together, functions such as spice_server_add_client would fail, and so would adding most of the SPICE_INTERFACE_* interface kinds.

Thanks,

Paolo

#7 lore raw

Hi,

Quoted 9 lines
Quoted 4 lines

Related: can modules depend on modules, so we could make x_keymap a module of its own and have both gtk and sdl depend on it?

That would also be useful when trying to modularize spice.

How hard would it be to modularize the libspice-server side? The part of the library that is used by QXL rendering should have much fewer dependencies than the part that is used for keyboard, mouse, audio, vmchannel/agent, etc.

kbd, mouse, audio is needed on the client side and is not part of libspice-server anyway. So spice is much less of a burden compared to sdl/gtk which bring alot of ui toolkit deps.

cheers,
Gerd

#8 lore raw
Quoted 7 lines · Gerd Hoffmann

Hi,

Quoted 5 lines
Quoted 4 lines

Related: can modules depend on modules, so we could make x_keymap a module of its own and have both gtk and sdl depend on it?

That would also be useful when trying to modularize spice.

Quoted 7 lines
Quoted 4 lines

How hard would it be to modularize the libspice-server side? The part of the library that is used by QXL rendering should have much fewer dependencies than the part that is used for keyboard, mouse, audio, vmchannel/agent, etc.

kbd, mouse, audio is needed on the client side and is not part of libspice-server anyway.

Yes, I'm talking about separating the client side from the QXL rendering part.

Quoted 2 lines

So spice is much less of a burden compared
to sdl/gtk which bring alot of ui toolkit deps.

But SPICE does bring in 16 libraries, including both of NSS and OpenSSL...

Paolo

#9 lore raw
In reply to Paolo Bonzini
Quoted 3 lines · Paolo Bonzini

x_keymap.o is common to the SDL and GTK+ modules, and it causes the QEMU binary to link to the X11 libraries. Add it separately to the modules to keep the main QEMU binary smaller.

Added to ui patch queue.

thanks,
Gerd