Skip to contentSkip to conversation

Automatically convert configure options to meson build options

RFC PATCH In review Paolo Bonzini 10 participants 32 messages Jan 7, 2021 – Jan 23, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Automatically convert configure options to meson build options

This is v2 of a concept that was first posted last September. In the meanwhile more options have been added to Meson, so the effect of the change can hopefully be evaluated more accurately. At least, the amount of lines removed in the configure script is larger than the size of the script itself!

Regarding the code itself, the main change is that the script has been rewritten from Python to Perl. The reasons for this are detailed in the commit message.

For the parsing of an option to be completely automatic, there must be no mentions of the corresponding variable in configure. Patches 1 to 6 clean up some of the stragglers to enable more automatic conversions. The only remaining options to be split between configure and Meson are capstone, git, slirp, default_devices, cfi and xen.

Paolo

Paolo Bonzini (8):
build-system: clean up TCG/TCI configury
cocoa: do not enable coreaudio automatically
gtk: remove CONFIG_GTK_GL
configure: move X11 detection to Meson
configure: move GTK+ detection to Meson
configure: move Cocoa incompatibility checks to Meson
configure: quote command line arguments in config.status
configure: automatically parse command line for meson -D options

 Makefile                                |  11 +
 configure                               | 459 ++-------------
 disas/meson.build                       |   2 -
 docs/devel/build-system.rst             |  49 +-
 meson-buildoptions.json                 | 717 ++++++++++++++++++++++++
 meson.build                             | 100 ++--
 meson_options.txt                       |  13 +-
 scripts/configure-parse-buildoptions.pl | 205 +++++++
 ui/gtk.c                                |  16 +-
 ui/meson.build                          |   9 +-
 10 files changed, 1073 insertions(+), 508 deletions(-)
 create mode 100644 meson-buildoptions.json
 create mode 100755 scripts/configure-parse-buildoptions.pl
Signature · 1 line
2.29.2
#1 lore raw

PATCH v2 1/8 build-system: clean up TCG/TCI configury

Make CONFIG_TCG_INTERPRETER a Meson option, and enable TCI (though with a warning) if the host CPU is unsupported, making it more similar to other --enable-* options.

Remove TCG-specific include paths from !CONFIG_TCG builds.

---
 configure         | 11 +++--------
 disas/meson.build |  2 --
 meson.build       | 50 ++++++++++++++++++++++++-----------------------
 meson_options.txt |  2 ++
 4 files changed, 31 insertions(+), 34 deletions(-)
configure +3 -8
index 8e0de14aa6..81801a6fe0 100755
@@ -355,7 +355,7 @@ sanitizers="no"
 tsan="no"
 fortify_source="$default_feature"
 strip_opt="yes"
-tcg_interpreter="no"
+tcg_interpreter="auto"
 bigendian="no"
 mingw32="no"
 gcov="no"
@@ -1117,9 +1117,9 @@ for opt do
   ;;
   --enable-whpx) whpx="enabled"
   ;;
-  --disable-tcg-interpreter) tcg_interpreter="no"
+  --disable-tcg-interpreter) tcg_interpreter="disabled"
   ;;
-  --enable-tcg-interpreter) tcg_interpreter="yes"
+  --enable-tcg-interpreter) tcg_interpreter="enabled"
   ;;
   --disable-cap-ng)  cap_ng="disabled"
   ;;
@@ -5911,11 +5911,6 @@ fi
 if test "$optreset" = "yes" ; then
   echo "HAVE_OPTRESET=y" >> $config_host_mak
 fi
-if test "$tcg" = "enabled"; then
-  if test "$tcg_interpreter" = "yes" ; then
-    echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
-  fi
-fi
 if test "$fdatasync" = "yes" ; then
   echo "CONFIG_FDATASYNC=y" >> $config_host_mak
 fi
disas/meson.build +0 -2
index 09a852742e..da341a511e 100644
@@ -22,5 +22,3 @@ common_ss.add(when: 'CONFIG_SH4_DIS', if_true: files('sh4.c'))
 common_ss.add(when: 'CONFIG_SPARC_DIS', if_true: files('sparc.c'))
 common_ss.add(when: 'CONFIG_XTENSA_DIS', if_true: files('xtensa.c'))
 common_ss.add(when: capstone, if_true: files('capstone.c'))
-
-specific_ss.add(when: 'CONFIG_TCG_INTERPRETER', if_true: files('tci.c'))
meson.build +26 -24

79 lines not on this page · raw message

meson_options.txt +2 -0
index 7948a8255c..41f9c2cf6c 100644
@@ -37,6 +37,8 @@ option('xen_pci_passthrough', type: 'feature', value: 'auto',
        description: 'Xen PCI passthrough support')
 option('tcg', type: 'feature', value: 'auto',
        description: 'TCG support')
+option('tcg_interpreter', type: 'feature', value: 'auto',
+       description: 'TCG bytecode interpreter (TCI)')
 option('cfi', type: 'boolean', value: 'false',
        description: 'Control-Flow Integrity (CFI)')
 option('cfi_debug', type: 'boolean', value: 'false',
Signature · 1 line
2.29.2
#2 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

Quoted 4 lines · Paolo Bonzini

Make CONFIG_TCG_INTERPRETER a Meson option, and enable TCI (though with a warning) if the host CPU is unsupported, making it more similar to other --enable-* options.

The current behaviour is kind of deliberate. Using the TCG interpreter is a terrible idea and think it's better if we don't let users end up using it without realising that they have. (Personally I would vote to deprecate-and-delete TCI, and also to just have configure error out on unknown host CPU architectures.)

thanks
-- PMM

#3 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

Quoted 11 lines · Peter Maydell
Quoted 4 lines · Paolo Bonzini

Make CONFIG_TCG_INTERPRETER a Meson option, and enable TCI (though with a warning) if the host CPU is unsupported, making it more similar to other --enable-* options.

The current behaviour is kind of deliberate. Using the TCG interpreter is a terrible idea and think it's better if we don't let users end up using it without realising that they have. (Personally I would vote to deprecate-and-delete TCI, and also to just have configure error out on unknown host CPU architectures.)

Fair enough, I can change this back of course. The missing targets are parisc, ia64 and sh4 I guess.

Paolo

#4 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

Quoted 7 lines · Paolo Bonzini
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Paolo Bonzini

Make CONFIG_TCG_INTERPRETER a Meson option, and enable TCI (though with a warning) if the host CPU is unsupported, making it more similar to other --enable-* options.

Quoted 8 lines
Quoted 5 lines

The current behaviour is kind of deliberate. Using the TCG interpreter is a terrible idea and think it's better if we don't let users end up using it without realising that they have. (Personally I would vote to deprecate-and-delete TCI, and also to just have configure error out on unknown host CPU architectures.)

Fair enough, I can change this back of course. The missing targets are parisc, ia64 and sh4 I guess.

ia64 is a dead host architecture and doesn't exist in any OS distro that we target anymore, so I don't think we need to consider it.

Likewise parisc/hppa doesn't seem exist in Debian since Squeeze, so I think we can rule that out too.

Only sh4 still seems to be supported in Debian. I expect the primary need there is for sh4 guest support rather than sh4 host support.

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 :|
#5 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

Cc'ing TCI, SH4 and PA contacts FWIW.

Quoted 29 lines · Daniel P. Berrangé
Quoted 7 lines · Paolo Bonzini
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Paolo Bonzini

Make CONFIG_TCG_INTERPRETER a Meson option, and enable TCI (though with a warning) if the host CPU is unsupported, making it more similar to other --enable-* options.

Quoted 8 lines
Quoted 5 lines

The current behaviour is kind of deliberate. Using the TCG interpreter is a terrible idea and think it's better if we don't let users end up using it without realising that they have. (Personally I would vote to deprecate-and-delete TCI, and also to just have configure error out on unknown host CPU architectures.)

Fair enough, I can change this back of course. The missing targets are parisc, ia64 and sh4 I guess.

ia64 is a dead host architecture and doesn't exist in any OS distro that we target anymore, so I don't think we need to consider it.

Likewise parisc/hppa doesn't seem exist in Debian since Squeeze, so I think we can rule that out too.

Only sh4 still seems to be supported in Debian. I expect the primary need there is for sh4 guest support rather than sh4 host support.

Regards,
Daniel

#6 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

Quoted 22 lines · Philippe Mathieu-Daudé

Cc'ing TCI, SH4 and PA contacts FWIW.

Quoted 19 lines · Daniel P. Berrangé
Quoted 7 lines · Paolo Bonzini
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Paolo Bonzini

Make CONFIG_TCG_INTERPRETER a Meson option, and enable TCI (though with a warning) if the host CPU is unsupported, making it more similar to other --enable-* options.

Quoted 8 lines
Quoted 5 lines

The current behaviour is kind of deliberate. Using the TCG interpreter is a terrible idea and think it's better if we don't let users end up using it without realising that they have. (Personally I would vote to deprecate-and-delete TCI, and also to just have configure error out on unknown host CPU architectures.)

Fair enough, I can change this back of course. The missing targets are parisc, ia64 and sh4 I guess.

ia64 is a dead host architecture and doesn't exist in any OS distro that we target anymore, so I don't think we need to consider it.

I have no opinion about ia64.

Quoted 2 lines
Quoted 2 lines

Likewise parisc/hppa doesn't seem exist in Debian since Squeeze, so I think we can rule that out too.

Can we please keep parisc/hppa.
It's not an official platform any longer, but quite active in the "unstable" debian-ports repository:
https://buildd.debian.org/status/architecture.php?a=hppa&suite=sid

Quoted 2 lines
Quoted 2 lines

Only sh4 still seems to be supported in Debian. I expect the primary need there is for sh4 guest support rather than sh4 host support.

Same as for hppa/parisc, sh4 is in debian-ports too.

Helge

#7 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

Quoted 34 lines · Helge Deller
Quoted 22 lines · Philippe Mathieu-Daudé

Cc'ing TCI, SH4 and PA contacts FWIW.

Quoted 19 lines · Daniel P. Berrangé
Quoted 7 lines · Paolo Bonzini
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Paolo Bonzini

Make CONFIG_TCG_INTERPRETER a Meson option, and enable TCI (though with a warning) if the host CPU is unsupported, making it more similar to other --enable-* options.

Quoted 8 lines
Quoted 5 lines

The current behaviour is kind of deliberate. Using the TCG interpreter is a terrible idea and think it's better if we don't let users end up using it without realising that they have. (Personally I would vote to deprecate-and-delete TCI, and also to just have configure error out on unknown host CPU architectures.)

Fair enough, I can change this back of course. The missing targets are parisc, ia64 and sh4 I guess.

ia64 is a dead host architecture and doesn't exist in any OS distro that we target anymore, so I don't think we need to consider it.

I have no opinion about ia64.

Quoted 2 lines
Quoted 2 lines

Likewise parisc/hppa doesn't seem exist in Debian since Squeeze, so I think we can rule that out too.

Can we please keep parisc/hppa.
It's not an official platform any longer, but quite active in the "unstable" debian-ports repository:
https://buildd.debian.org/status/architecture.php?a=hppa&suite=sid

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

Only sh4 still seems to be supported in Debian. I expect the primary need there is for sh4 guest support rather than sh4 host support.

Same as for hppa/parisc, sh4 is in debian-ports too.

So that at least shows that we need *guest target* support hppa/sha4.

The question still remains whether anyone is actually likely to be running/using QEMU on a sh4/hppa *host*, to emulate a different guest arch ? This is what that TCG interpreter provides for. eg would anyone really want to emulate aarch64 guest when runing on a hppa host ?

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 :|
#8 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

Quoted 5 lines · Daniel P. Berrangé

The question still remains whether anyone is actually likely to be running/using QEMU on a sh4/hppa *host*, to emulate a different guest arch ? This is what that TCG interpreter provides for. eg would anyone really want to emulate aarch64 guest when runing on a hppa host ?

If anybody does, they should provide and help us maintain an hppa backend for tcg (and resources so we can CI it). TCI is going to be so slow as to be useless -- you might be able to tick a box saying "we built QEMU for this port" but I find it hard to believe anybody would actually use the result.

thanks
-- PMM

#9 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

Quoted 9 lines · Peter Maydell
Quoted 5 lines · Daniel P. Berrangé

The question still remains whether anyone is actually likely to be running/using QEMU on a sh4/hppa *host*, to emulate a different guest arch ? This is what that TCG interpreter provides for. eg would anyone really want to emulate aarch64 guest when runing on a hppa host ?

If anybody does, they should provide and help us maintain an hppa backend for tcg (and resources so we can CI it).

My time is currently too limited to actually work on such a backend, but out of couriosity, what hardware resources would be needed? Is a login to a machine sufficient?

Quoted 4 lines

TCI is going to be so slow as to be useless -- you might be able to tick a box saying "we built QEMU for this port" but I find it hard to believe anybody would actually use the result.

True. As I said in the other mail, it would be useful for small tools/builds only.

Helge

#10 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

In reply to Daniel P. Berrangé
Quoted 35 lines · Daniel P. Berrangé
Quoted 34 lines · Helge Deller
Quoted 22 lines · Philippe Mathieu-Daudé

Cc'ing TCI, SH4 and PA contacts FWIW.

Quoted 19 lines · Daniel P. Berrangé
Quoted 7 lines · Paolo Bonzini
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Paolo Bonzini

Make CONFIG_TCG_INTERPRETER a Meson option, and enable TCI (though with a warning) if the host CPU is unsupported, making it more similar to other --enable-* options.

Quoted 8 lines
Quoted 5 lines

The current behaviour is kind of deliberate. Using the TCG interpreter is a terrible idea and think it's better if we don't let users end up using it without realising that they have. (Personally I would vote to deprecate-and-delete TCI, and also to just have configure error out on unknown host CPU architectures.)

Fair enough, I can change this back of course. The missing targets are parisc, ia64 and sh4 I guess.

ia64 is a dead host architecture and doesn't exist in any OS distro that we target anymore, so I don't think we need to consider it.

I have no opinion about ia64.

Quoted 2 lines
Quoted 2 lines

Likewise parisc/hppa doesn't seem exist in Debian since Squeeze, so I think we can rule that out too.

Can we please keep parisc/hppa.
It's not an official platform any longer, but quite active in the "unstable" debian-ports repository:
https://buildd.debian.org/status/architecture.php?a=hppa&suite=sid

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

Only sh4 still seems to be supported in Debian. I expect the primary need there is for sh4 guest support rather than sh4 host support.

Same as for hppa/parisc, sh4 is in debian-ports too.

So that at least shows that we need *guest target* support hppa/sha4.

Yes.

Quoted 3 lines

The question still remains whether anyone is actually likely to be running/using QEMU on a sh4/hppa *host*, to emulate a different guest arch ?

Agreed, it's not very useful because of speed and amount of possible users, but ....(please read below)

Quoted 2 lines

This is what that TCG interpreter provides for. eg would anyone really want to emulate aarch64 guest when runing on a hppa host ?

In debian many packages directly and indirectly depend on the qemu source package, because it provides - beside the emulator - various userspace tools which are necessary natively, like e.g. qemu-img. In the past building those tools failed on hppa because the configure script detected that neither native TCG nor TCG interpreter support was possible. As such the configuration aborted and no tools were built.
So, the change should still make it possible to enable building the userspace tools.

On the other side, sometimes even a slow TCG-interpreter enabled qemu for other arches can be useful. It's not about speed, but about the *possibility* to emulate small pieces of different code, e.g. cross-compilers, bios-tools and such. It's not used often, but it can be handy.
That said, if it doesn't hurt I think we should not disable something which can be useful (this applies to all architectures).

Helge

#11 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

Quoted 8 lines · Helge Deller

In debian many packages directly and indirectly depend on the qemu source package, because it provides - beside the emulator - various userspace tools which are necessary natively, like e.g. qemu-img. In the past building those tools failed on hppa because the configure script detected that neither native TCG nor TCG interpreter support was possible. As such the configuration aborted and no tools were built.
So, the change should still make it possible to enable building the userspace tools.

You could still build those, with --disable-system --disable-user. Or we could rig the configure/meson scripts to do that automatically if no accelerator is supported.

Paolo

#12 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

Quoted 11 lines · Paolo Bonzini
Quoted 8 lines · Helge Deller

In debian many packages directly and indirectly depend on the qemu source package, because it provides - beside the emulator - various userspace tools which are necessary natively, like e.g. qemu-img. In the past building those tools failed on hppa because the configure script detected that neither native TCG nor TCG interpreter support was possible. As such the configuration aborted and no tools were built.
So, the change should still make it possible to enable building the userspace tools.

You could still build those, with --disable-system --disable-user.

Yes, since the tools are independend of the emulation, it should be possible to build those independend if system/user is enabled or disabled.

Quoted 2 lines

Or we could rig the configure/meson scripts to do that automatically if no accelerator is supported.

That would be the expected behaviour.

Helge

#13 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

In reply to Helge Deller

Hello!

Quoted 6 lines · Helge Deller
Quoted 2 lines

This is what that TCG interpreter provides for. eg would anyone really want to emulate aarch64 guest when runing on a hppa host ?

In debian many packages directly and indirectly depend on the qemu source package, because it provides - beside the emulator - various userspace tools which are necessary natively, like e.g. qemu-img.

I agree, that this a problem and it would be great if QEMU could be fixed that it builds on all targets, not necessarily with all features available.

Currently, it looks like this:

Quoted 1 line

https://buildd.debian.org/status/package.php?p=qemu&suite=sid

Note: The build failure on sparc64 is a bug in the device-tree-compiler package which has not been fixed in Debian yet, see:

Quoted 7 lines

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=977031

In the past building those tools failed on hppa because the configure script detected that neither native TCG nor TCG interpreter support was possible. As such the configuration aborted and no tools were built.
So, the change should still make it possible to enable building the userspace tools.

I agree.

Quoted 5 lines

On the other side, sometimes even a slow TCG-interpreter enabled qemu for other arches can be useful. It's not about speed, but about the *possibility* to emulate small pieces of different code, e.g. cross-compilers, bios-tools and such. It's not used often, but it can be handy.

I also agree here.

Quoted 2 lines

That said, if it doesn't hurt I think we should not disable something which can be useful (this applies to all architectures).

True.

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#14 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

In reply to Helge Deller
Quoted 6 lines · Helge Deller
Quoted 2 lines
Quoted 2 lines

ia64 is a dead host architecture and doesn't exist in any OS distro that we target anymore, so I don't think we need to consider it.

I have no opinion about ia64.

Quoted 2 lines
Quoted 2 lines

Likewise parisc/hppa doesn't seem exist in Debian since Squeeze, so I think we can rule that out too.

Quoted 8 lines

Can we please keep parisc/hppa.
It's not an official platform any longer, but quite active in the "unstable" debian-ports repository:
https://buildd.debian.org/status/architecture.php?a=hppa&suite=sid

Quoted 2 lines
Quoted 2 lines

Only sh4 still seems to be supported in Debian. I expect the primary need there is for sh4 guest support rather than sh4 host support.

Same as for hppa/parisc, sh4 is in debian-ports too.

The status of the platforms in debian-ports is here:
https://www.ports.debian.org/archive
https://buildd.debian.org/status/architecture.php?a=hppa&suite=sid

There is some effort to maintain all the platforms in debian-ports.  The hppa platform is also still in gentoo, and one or two bsd distros.

Regards,
Dave

Signature · 1 line
John David Anglin  [email protected]
#15 lore raw

Re: [PATCH 1/8] build-system: clean up TCG/TCI configury

In reply to Philippe Mathieu-Daudé

Hello!

Quoted 5 lines · Philippe Mathieu-Daudé
Quoted 5 lines

ia64 is a dead host architecture and doesn't exist in any OS distro that we target anymore, so I don't think we need to consider it.

Likewise parisc/hppa doesn't seem exist in Debian since Squeeze, so I think we can rule that out too.

Both hppa and ia64 are maintained as unofficial ports in Debian:

Quoted 4 lines

https://cdimage.debian.org/cdimage/ports/snapshots/2021-01-03/

Quoted 2 lines

Only sh4 still seems to be supported in Debian. I expect the primary need there is for sh4 guest support rather than sh4 host support.

Same applies to sh4:

Quoted 1 line

https://cdimage.debian.org/cdimage/ports/debian-installer/2021-01-03/sh4/

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#16 lore raw

PATCH v2 2/8 cocoa: do not enable coreaudio automatically

In reply to Paolo Bonzini

Remove the automagic connection between --enable-cocoa and enabling coreaudio in audio_drv_list. It can be overridden anyway just by placing --enable-cocoa before --audio-drv-list.

---
 configure | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
configure +1 -3
index 81801a6fe0..2dd772a60c 100755
@@ -1149,9 +1149,7 @@ for opt do
   ;;
   --disable-cocoa) cocoa="disabled"
   ;;
-  --enable-cocoa)
-      cocoa="enabled" ;
-      audio_drv_list="coreaudio $(echo $audio_drv_list | sed s,coreaudio,,g)"
+  --enable-cocoa) cocoa="enabled"
   ;;
   --disable-system) softmmu="no"
   ;;
Signature · 1 line
2.29.2
#17 lore raw

PATCH v2 3/8 gtk: remove CONFIG_GTK_GL

In reply to Paolo Bonzini

CONFIG_GTK_GL is defined if OpenGL is present and GTK+ is 3.16 or newer. Since GTK+ 3.22 is the minimum supported version, just use CONFIG_OPENGL instead.

---
 configure      |  7 -------
 meson.build    |  1 -
 ui/gtk.c       | 16 ++++++++--------
 ui/meson.build |  3 +--
 4 files changed, 9 insertions(+), 18 deletions(-)
configure +0 -7
index 2dd772a60c..c6d09b225e 100755
@@ -415,7 +415,6 @@ cfi_debug="false"
 seccomp="auto"
 glusterfs="auto"
 gtk="$default_feature"
-gtk_gl="no"
 tls_priority="NORMAL"
 gnutls="$default_feature"
 nettle="$default_feature"
@@ -3626,9 +3625,6 @@ if test "$opengl" != "no" ; then
     opengl_cflags="$($pkg_config --cflags $opengl_pkgs)"
     opengl_libs="$($pkg_config --libs $opengl_pkgs)"
     opengl=yes
-    if test "$gtk" = "yes" && $pkg_config --exists "$gtkpackage >= 3.16"; then
-        gtk_gl="yes"
-    fi
   else
     if test "$opengl" = "yes" ; then
       feature_not_found "opengl" "Please install opengl (mesa) devel pkgs: $opengl_pkgs"
@@ -5781,9 +5777,6 @@ if test "$gtk" = "yes" ; then
   echo "CONFIG_GTK=y" >> $config_host_mak
   echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
   echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
-  if test "$gtk_gl" = "yes" ; then
-    echo "CONFIG_GTK_GL=y" >> $config_host_mak
-  fi
 fi
 if test "$gio" = "yes" ; then
     echo "CONFIG_GIO=y" >> $config_host_mak
meson.build +0 -1
index 36f1d02190..a729a30d2f 100644
@@ -2337,7 +2337,6 @@ summary_info += {'SDL support':       sdl.found()}
 summary_info += {'SDL image support': sdl_image.found()}
 # TODO: add back version
 summary_info += {'GTK support':       config_host.has_key('CONFIG_GTK')}
-summary_info += {'GTK GL support':    config_host.has_key('CONFIG_GTK_GL')}
 summary_info += {'pixman':            pixman.found()}
 # TODO: add back version
 summary_info += {'VTE support':       config_host.has_key('CONFIG_VTE')}
ui/gtk.c +8 -8
index a752aa22be..e8474456df 100644
@@ -396,7 +396,7 @@ static void gd_update_full_redraw(VirtualConsole *vc)
     int ww, wh;
     ww = gdk_window_get_width(gtk_widget_get_window(area));
     wh = gdk_window_get_height(gtk_widget_get_window(area));
-#if defined(CONFIG_GTK_GL)
+#if defined(CONFIG_OPENGL)
     if (vc->gfx.gls && gtk_use_gl_area) {
         gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area));
         return;
@@ -625,7 +625,7 @@ static const DisplayChangeListenerOps dcl_ops = {
 
 /** DisplayState Callbacks (opengl version) **/
 
-#if defined(CONFIG_GTK_GL)
+#if defined(CONFIG_OPENGL)
 
 static const DisplayChangeListenerOps dcl_gl_area_ops = {
     .dpy_name             = "gtk-egl",
@@ -644,7 +644,7 @@ static const DisplayChangeListenerOps dcl_gl_area_ops = {
     .dpy_gl_update           = gd_gl_area_scanout_flush,
 };
 
-#endif /* CONFIG_GTK_GL */
+#endif /* CONFIG_OPENGL */
 
 static const DisplayChangeListenerOps dcl_egl_ops = {
     .dpy_name             = "gtk-egl",
@@ -725,7 +725,7 @@ static void gd_set_ui_info(VirtualConsole *vc, gint width, gint height)
     dpy_set_ui_info(vc->gfx.dcl.con, &info);
 }
 
-#if defined(CONFIG_GTK_GL)
+#if defined(CONFIG_OPENGL)
 
 static gboolean gd_render_event(GtkGLArea *area, GdkGLContext *context,
                                 void *opaque)
@@ -1865,7 +1865,7 @@ static void gd_connect_vc_gfx_signals(VirtualConsole *vc)
 {
     g_signal_connect(vc->gfx.drawing_area, "draw",
                      G_CALLBACK(gd_draw_event), vc);
-#if defined(CONFIG_GTK_GL)
+#if defined(CONFIG_OPENGL)
     if (gtk_use_gl_area) {
         /* wire up GtkGlArea events */
         g_signal_connect(vc->gfx.drawing_area, "render",
@@ -1992,12 +1992,12 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
 
 #if defined(CONFIG_OPENGL)
     if (display_opengl) {
-#if defined(CONFIG_GTK_GL)
+#if defined(CONFIG_OPENGL)
         if (gtk_use_gl_area) {
             vc->gfx.drawing_area = gtk_gl_area_new();
             vc->gfx.dcl.ops = &dcl_gl_area_ops;
         } else
-#endif /* CONFIG_GTK_GL */
+#endif /* CONFIG_OPENGL */
         {
             vc->gfx.drawing_area = gtk_drawing_area_new();
             /*
@@ -2314,7 +2314,7 @@ static void early_gtk_display_init(DisplayOptions *opts)
     assert(opts->type == DISPLAY_TYPE_GTK);
     if (opts->has_gl && opts->gl != DISPLAYGL_MODE_OFF) {
 #if defined(CONFIG_OPENGL)
-#if defined(CONFIG_GTK_GL) && defined(GDK_WINDOWING_WAYLAND)
+#if defined(GDK_WINDOWING_WAYLAND)
         if (GDK_IS_WAYLAND_DISPLAY(gdk_display_get_default())) {
             gtk_use_gl_area = true;
             gtk_gl_area_init();
ui/meson.build +1 -2
index 013258a01c..d805448c4e 100644
@@ -63,8 +63,7 @@ if config_host.has_key('CONFIG_GTK')
   gtk_ss = ss.source_set()
   gtk_ss.add(gtk, vte, pixman, files('gtk.c'))
   gtk_ss.add(when: [x11, 'CONFIG_X11'], if_true: files('x_keymap.c'))
-  gtk_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('gtk-egl.c'))
-  gtk_ss.add(when: [opengl, 'CONFIG_GTK_GL'], if_true: files('gtk-gl-area.c'))
+  gtk_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('gtk-egl.c', 'gtk-gl-area.c'))
   ui_modules += {'gtk' : gtk_ss}
 endif
 
Signature · 1 line
2.29.2
#19 lore raw

PATCH v2 4/8 configure: move X11 detection to Meson

In reply to Paolo Bonzini

For now move the logic verbatim. GTK+ actually has a hard requirement on X11 if gtk+x11 is present, but we will sort that out later.

---
 configure      | 14 ++------------
 meson.build    |  9 +++++----
 ui/meson.build |  4 ++--
 3 files changed, 9 insertions(+), 18 deletions(-)
configure +2 -12
index c6d09b225e..e9d76c2c13 100755
@@ -2759,14 +2759,6 @@ EOF
   fi
 fi
 
-##########################################
-# X11 probe
-if $pkg_config --exists "x11"; then
-    have_x11=yes
-    x11_cflags=$($pkg_config --cflags x11)
-    x11_libs=$($pkg_config --libs x11)
-fi
-
 ##########################################
 # GTK probe
 
@@ -5681,10 +5673,8 @@ fi
 if test "$module_upgrades" = "yes"; then
   echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
 fi
-if test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
-  echo "CONFIG_X11=y" >> $config_host_mak
-  echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
-  echo "X11_LIBS=$x11_libs" >> $config_host_mak
+if test "$need_x11" = "yes"; then
+  echo "CONFIG_NEED_X11=y" >> $config_host_mak
 fi
 if test "$pipe2" = "yes" ; then
   echo "CONFIG_PIPE2=y" >> $config_host_mak
meson.build +5 -4
index a729a30d2f..fdd4312c71 100644
@@ -783,9 +783,9 @@ if 'CONFIG_VTE' in config_host
                            link_args: config_host['VTE_LIBS'].split())
 endif
 x11 = not_found
-if 'CONFIG_X11' in config_host
-  x11 = declare_dependency(compile_args: config_host['X11_CFLAGS'].split(),
-                           link_args: config_host['X11_LIBS'].split())
+if config_host.has_key('CONFIG_NEED_X11')
+  x11 = dependency('x11', method: 'pkg-config', required: false,
+                   static: enable_static)
 endif
 vnc = not_found
 png = not_found
@@ -1081,6 +1081,7 @@ config_host_data.set('CONFIG_STATX', has_statx)
 config_host_data.set('CONFIG_ZSTD', zstd.found())
 config_host_data.set('CONFIG_FUSE', fuse.found())
 config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found())
+config_host_data.set('CONFIG_X11', x11.found())
 config_host_data.set('CONFIG_CFI', get_option('cfi'))
 config_host_data.set('QEMU_VERSION', '"@0@"'.format(meson.project_version()))
 config_host_data.set('QEMU_VERSION_MAJOR', meson.project_version().split('.')[0])
@@ -1167,7 +1168,7 @@ host_kconfig = \
   ('CONFIG_SPICE' in config_host ? ['CONFIG_SPICE=y'] : []) + \
   ('CONFIG_IVSHMEM' in config_host ? ['CONFIG_IVSHMEM=y'] : []) + \
   ('CONFIG_OPENGL' in config_host ? ['CONFIG_OPENGL=y'] : []) + \
-  ('CONFIG_X11' in config_host ? ['CONFIG_X11=y'] : []) + \
+  (x11.found() ? ['CONFIG_X11=y'] : []) + \
   ('CONFIG_VHOST_USER' in config_host ? ['CONFIG_VHOST_USER=y'] : []) + \
   ('CONFIG_VHOST_VDPA' in config_host ? ['CONFIG_VHOST_VDPA=y'] : []) + \
   ('CONFIG_VHOST_KERNEL' in config_host ? ['CONFIG_VHOST_KERNEL=y'] : []) + \
ui/meson.build +2 -2
index d805448c4e..afbdd78e97 100644
@@ -62,7 +62,7 @@ if config_host.has_key('CONFIG_GTK')
 
   gtk_ss = ss.source_set()
   gtk_ss.add(gtk, vte, pixman, files('gtk.c'))
-  gtk_ss.add(when: [x11, 'CONFIG_X11'], if_true: files('x_keymap.c'))
+  gtk_ss.add(when: x11, if_true: files('x_keymap.c'))
   gtk_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('gtk-egl.c', 'gtk-gl-area.c'))
   ui_modules += {'gtk' : gtk_ss}
 endif
@@ -77,7 +77,7 @@ if sdl.found()
     'sdl2.c',
   ))
   sdl_ss.add(when: [opengl, 'CONFIG_OPENGL'], if_true: files('sdl2-gl.c'))
-  sdl_ss.add(when: [x11, 'CONFIG_X11'], if_true: files('x_keymap.c'))
+  sdl_ss.add(when: x11, if_true: files('x_keymap.c'))
   ui_modules += {'sdl' : sdl_ss}
 endif
 
Signature · 1 line
2.29.2
#20 lore raw

PATCH v2 5/8 configure: move GTK+ detection to Meson

In reply to Paolo Bonzini

This also allows removing CONFIG_NEED_X11, all the ingredients can be computed easily in meson.build.

---
 configure         | 55 ++++++-----------------------------------------
 meson.build       | 29 ++++++++++++++++++-------
 meson_options.txt |  2 ++
 ui/meson.build    |  2 +-
 4 files changed, 30 insertions(+), 58 deletions(-)
configure +6 -49
index e9d76c2c13..652cff7ba6 100755
@@ -414,7 +414,7 @@ cfi="false"
 cfi_debug="false"
 seccomp="auto"
 glusterfs="auto"
-gtk="$default_feature"
+gtk="auto"
 tls_priority="NORMAL"
 gnutls="$default_feature"
 nettle="$default_feature"
@@ -1377,9 +1377,9 @@ for opt do
   --enable-uuid|--disable-uuid)
       echo "$0: $opt is obsolete, UUID support is always built" >&2
   ;;
-  --disable-gtk) gtk="no"
+  --disable-gtk) gtk="disabled"
   ;;
-  --enable-gtk) gtk="yes"
+  --enable-gtk) gtk="enabled"
   ;;
   --tls-priority=*) tls_priority="$optarg"
   ;;
@@ -2329,10 +2329,10 @@ if test "$cocoa" = "enabled"; then
     if test "$sdl" = "enabled"; then
         error_exit "Cocoa and SDL UIs cannot both be enabled at once"
     fi
-    if test "$gtk" = "yes"; then
+    if test "$gtk" = "enabled"; then
         error_exit "Cocoa and GTK UIs cannot both be enabled at once"
     fi
-    gtk=no
+    gtk=disabled
     sdl=disabled
 fi
 
@@ -2759,31 +2759,6 @@ EOF
   fi
 fi
 
-##########################################
-# GTK probe
-
-if test "$gtk" != "no"; then
-    gtkpackage="gtk+-3.0"
-    gtkx11package="gtk+-x11-3.0"
-    gtkversion="3.22.0"
-    if $pkg_config --exists "$gtkpackage >= $gtkversion"; then
-        gtk_cflags=$($pkg_config --cflags $gtkpackage)
-        gtk_libs=$($pkg_config --libs $gtkpackage)
-        gtk_version=$($pkg_config --modversion $gtkpackage)
-        if $pkg_config --exists "$gtkx11package >= $gtkversion"; then
-            need_x11=yes
-            gtk_cflags="$gtk_cflags $x11_cflags"
-            gtk_libs="$gtk_libs $x11_libs"
-        fi
-        gtk="yes"
-    elif test "$gtk" = "yes"; then
-        feature_not_found "gtk" "Install gtk3-devel"
-    else
-        gtk="no"
-    fi
-fi
-
-
 ##########################################
 # GNUTLS probe
 
@@ -3640,16 +3615,6 @@ EOF
   fi
 fi
 
-if test "$opengl" = "yes" && test "$have_x11" = "yes"; then
-  for target in $target_list; do
-    case $target in
-      lm32-softmmu) # milkymist-tmu2 requires X11 and OpenGL
-        need_x11=yes
-      ;;
-    esac
-  done
-fi
-
 ##########################################
 # libxml2 probe
 if test "$libxml2" != "no" ; then
@@ -5673,9 +5638,6 @@ fi
 if test "$module_upgrades" = "yes"; then
   echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
 fi
-if test "$need_x11" = "yes"; then
-  echo "CONFIG_NEED_X11=y" >> $config_host_mak
-fi
 if test "$pipe2" = "yes" ; then
   echo "CONFIG_PIPE2=y" >> $config_host_mak
 fi
@@ -5763,11 +5725,6 @@ fi
 if test "$bswap_h" = "yes" ; then
   echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
 fi
-if test "$gtk" = "yes" ; then
-  echo "CONFIG_GTK=y" >> $config_host_mak
-  echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
-  echo "GTK_LIBS=$gtk_libs" >> $config_host_mak
-fi
 if test "$gio" = "yes" ; then
     echo "CONFIG_GIO=y" >> $config_host_mak
     echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
@@ -6491,7 +6448,7 @@ NINJA=$ninja $meson setup \
         -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
         -Dkvm=$kvm -Dhax=$hax -Dwhpx=$whpx -Dhvf=$hvf \
         -Dxen=$xen -Dxen_pci_passthrough=$xen_pci_passthrough -Dtcg=$tcg \
-        -Dcocoa=$cocoa -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
+        -Dcocoa=$cocoa -Dgtk=$gtk -Dmpath=$mpath -Dsdl=$sdl -Dsdl_image=$sdl_image \
         -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
         -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
         -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
meson.build +21 -8
index fdd4312c71..a3a0958b4d 100644
@@ -772,19 +772,31 @@ if 'CONFIG_OPENGL' in config_host
   opengl = declare_dependency(compile_args: config_host['OPENGL_CFLAGS'].split(),
                               link_args: config_host['OPENGL_LIBS'].split())
 endif
+
 gtk = not_found
-if 'CONFIG_GTK' in config_host
-  gtk = declare_dependency(compile_args: config_host['GTK_CFLAGS'].split(),
-                              link_args: config_host['GTK_LIBS'].split())
+gtkx11 = not_found
+if not get_option('gtk').auto() or have_system
+  gtk = dependency('gtk+-3.0', version: '>=3.22.0',
+                   method: 'pkg-config',
+                   required: get_option('gtk'),
+                   static: enable_static)
+  if gtk.found()
+    gtkx11 = dependency('gtk+-x11-3.0', version: '>=3.22.0',
+                        method: 'pkg-config',
+                        required: false,
+                        static: enable_static)
+    gtk = declare_dependency(dependencies: [gtk, gtkx11])
+  endif
 endif
+
 vte = not_found
 if 'CONFIG_VTE' in config_host
   vte = declare_dependency(compile_args: config_host['VTE_CFLAGS'].split(),
                            link_args: config_host['VTE_LIBS'].split())
 endif
 x11 = not_found
-if config_host.has_key('CONFIG_NEED_X11')
-  x11 = dependency('x11', method: 'pkg-config', required: false,
+if gtkx11.found() or 'lm32-softmmu' in target_dirs
+  x11 = dependency('x11', method: 'pkg-config', required: gtkx11.found(),
                    static: enable_static)
 endif
 vnc = not_found
@@ -1058,6 +1070,7 @@ if glusterfs.found()
   config_host_data.set('CONFIG_GLUSTERFS_FTRUNCATE_HAS_STAT', glusterfs_ftruncate_has_stat)
   config_host_data.set('CONFIG_GLUSTERFS_IOCB_HAS_STAT', glusterfs_iocb_has_stat)
 endif
+config_host_data.set('CONFIG_GTK', gtk.found())
 config_host_data.set('CONFIG_LIBATTR', have_old_libattr)
 config_host_data.set('CONFIG_LIBCAP_NG', libcap_ng.found())
 config_host_data.set('CONFIG_LIBISCSI', libiscsi.found())
@@ -2229,7 +2242,7 @@ subdir('tools')
 subdir('pc-bios')
 subdir('docs')
 subdir('tests')
-if 'CONFIG_GTK' in config_host
+if gtk.found()
   subdir('po')
 endif
 
@@ -2246,7 +2259,7 @@ if host_machine.system() == 'windows'
   if build_docs
     nsis_cmd += '-DCONFIG_DOCUMENTATION=y'
   endif
-  if 'CONFIG_GTK' in config_host
+  if gtk.found()
     nsis_cmd += '-DCONFIG_GTK=y'
   endif
 
@@ -2337,7 +2350,7 @@ endif
 summary_info += {'SDL support':       sdl.found()}
 summary_info += {'SDL image support': sdl_image.found()}
 # TODO: add back version
-summary_info += {'GTK support':       config_host.has_key('CONFIG_GTK')}
+summary_info += {'GTK support':       gtk.found()}
 summary_info += {'pixman':            pixman.found()}
 # TODO: add back version
 summary_info += {'VTE support':       config_host.has_key('CONFIG_VTE')}
meson_options.txt +2 -0
index 41f9c2cf6c..b9b106675f 100644
@@ -76,6 +76,8 @@ option('lzo', type : 'feature', value : 'auto',
        description: 'lzo compression support')
 option('rbd', type : 'feature', value : 'auto',
        description: 'Ceph block device driver')
+option('gtk', type : 'feature', value : 'auto',
+       description: 'GTK+ user interface')
 option('sdl', type : 'feature', value : 'auto',
        description: 'SDL user interface')
 option('sdl_image', type : 'feature', value : 'auto',
ui/meson.build +1 -1
index afbdd78e97..407e291ebe 100644
@@ -57,7 +57,7 @@ if config_host.has_key('CONFIG_OPENGL_DMABUF')
   ui_modules += {'egl-headless' : egl_headless_ss}
 endif
 
-if config_host.has_key('CONFIG_GTK')
+if gtk.found()
   softmmu_ss.add(when: 'CONFIG_WIN32', if_true: files('win32-kbd-hook.c'))
 
   gtk_ss = ss.source_set()
Signature · 1 line
2.29.2
#21 lore raw

PATCH v2 6/8 configure: move Cocoa incompatibility checks to Meson

In reply to Paolo Bonzini

The cocoa UI code currently assumes it is always the active UI and does not interact well with other UI frontend code. Move the relevant checks to Meson now that all other frontends have become Meson options. This way, SDL/GTK+/Cocoa can be parsed entirely by scripts/configure-parse-buildoptions.pl.

---
 configure   | 15 ---------------
 meson.build | 17 ++++++++++-------
 2 files changed, 10 insertions(+), 22 deletions(-)
configure +0 -15
index 652cff7ba6..d573058b16 100755
@@ -772,7 +772,6 @@ Darwin)
     QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
     QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
   fi
-  cocoa="enabled"
   audio_drv_list="coreaudio try-sdl"
   audio_possible_drivers="coreaudio sdl"
   QEMU_LDFLAGS="-framework CoreFoundation -framework IOKit $QEMU_LDFLAGS"
@@ -2322,20 +2321,6 @@ if test -z "$want_tools"; then
 fi
 
 ##########################################
-# cocoa implies not SDL or GTK
-# (the cocoa UI code currently assumes it is always the active UI
-# and doesn't interact well with other UI frontend code)
-if test "$cocoa" = "enabled"; then
-    if test "$sdl" = "enabled"; then
-        error_exit "Cocoa and SDL UIs cannot both be enabled at once"
-    fi
-    if test "$gtk" = "enabled"; then
-        error_exit "Cocoa and GTK UIs cannot both be enabled at once"
-    fi
-    gtk=disabled
-    sdl=disabled
-fi
-
 # Some versions of Mac OS X incorrectly define SIZE_MAX
 cat > $TMPC << EOF
 #include <stdint.h>
meson.build +10 -7
index a3a0958b4d..5a8efd2316 100644
@@ -148,7 +148,6 @@ version_res = []
 coref = []
 iokit = []
 emulator_link_args = []
-cocoa = not_found
 hvf = not_found
 if targetos == 'windows'
   socket = cc.find_library('ws2_32')
@@ -161,7 +160,6 @@ if targetos == 'windows'
 elif targetos == 'darwin'
   coref = dependency('appleframeworks', modules: 'CoreFoundation')
   iokit = dependency('appleframeworks', modules: 'IOKit')
-  cocoa = dependency('appleframeworks', modules: 'Cocoa', required: get_option('cocoa'))
 elif targetos == 'sunos'
   socket = [cc.find_library('socket'),
             cc.find_library('nsl'),
@@ -252,9 +250,6 @@ if not have_xen_pci_passthrough and get_option('xen_pci_passthrough').enabled()
     error('Xen PCI passthrough requested but Xen not enabled')
   endif
 endif
-if not cocoa.found() and get_option('cocoa').enabled()
-  error('Cocoa not available on this platform')
-endif
 
 ################
 # Dependencies #
@@ -358,6 +353,14 @@ if not get_option('attr').disabled()
   endif
 endif
 
+cocoa = dependency('appleframeworks', modules: 'Cocoa', required: get_option('cocoa'))
+if cocoa.found() and get_option('sdl').enabled()
+  error('Cocoa and SDL cannot be enabled at the same time')
+endif
+if cocoa.found() and get_option('gtk').enabled()
+  error('Cocoa and GTK+ cannot be enabled at the same time')
+endif
+
 seccomp = not_found
 if not get_option('seccomp').auto() or have_system or have_tools
   seccomp = dependency('libseccomp', version: '>=2.3.0',
@@ -643,7 +646,7 @@ if not get_option('brlapi').auto() or have_system
 endif
 
 sdl = not_found
-if have_system
+if not get_option('sdl').auto() or (have_system and not cocoa.found())
   sdl = dependency('sdl2', required: get_option('sdl'), static: enable_static)
   sdl_image = not_found
 endif
@@ -775,7 +778,7 @@ endif
 
 gtk = not_found
 gtkx11 = not_found
-if not get_option('gtk').auto() or have_system
+if not get_option('gtk').auto() or (have_system and not cocoa.found())
   gtk = dependency('gtk+-3.0', version: '>=3.22.0',
                    method: 'pkg-config',
                    required: get_option('gtk'),
Signature · 1 line
2.29.2
#22 lore raw

PATCH v2 7/8 configure: quote command line arguments in config.status

In reply to Paolo Bonzini

Make config.status generation a bit more robust. (The quote_sh function will also be reused to parse configure's command line arguments in an external script driven by Meson build option introspection).

---
 configure | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
configure +5 -1
index d573058b16..41866cc38e 100755
@@ -89,6 +89,10 @@ printf " '%s'" "$0" "$@" >> config.log
 echo >> config.log
 echo "#" >> config.log
 
+quote_sh() {
+    printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
+}
+
 print_error() {
     (echo
     echo "ERROR: $1"
@@ -6509,7 +6513,7 @@ preserve_env WINDRES
 
 printf "exec" >>config.status
 for i in "$0" "$@"; do
-  test "$i" = --skip-meson || printf " '%s'" "$i" >>config.status
+  test "$i" = --skip-meson || printf " %s" "$(quote_sh "$i")" >>config.status
 done
 echo ' "$@"' >>config.status
 chmod +x config.status
Signature · 1 line
2.29.2
Reviewed-by on v2 7/8
#23 lore raw

Re: [PATCH 7/8] configure: quote command line arguments in config.status

Quoted 15 lines · Paolo Bonzini

Make config.status generation a bit more robust. (The quote_sh function will also be reused to parse configure's command line arguments in an external script driven by Meson build option introspection).

---
 configure | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
configure +0 -0
index d573058b16..41866cc38e 100755

configure printf " '%s'" "$0" "$@" >> config.log · line 94

Quoted 6 lines
configure +3 -0
@@ -89,6 +89,10 @@ printf " '%s'" "$0" "$@" >> config.log
 echo >> config.log
 echo "#" >> config.log
 
+quote_sh() {
+    printf "%s" "$1" | sed "s,','\\\\'',g; s,.*,'&',"
+}

printf %s does not append a newline, but POSIX does not require sed to behave sanely when its input does not end in a newline.

But unless we hit a case where someone is actually using a sed that complains, this works for me.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#24 lore raw

PATCH v2 8/8 configure: automatically parse command line for meson -D options

In reply to Paolo Bonzini

Right now meson_options.txt lists almost 60 options. Each option needs code in configure to parse it and pass the option down to Meson as a -D command-line argument; in addition the default must be duplicated between configure and meson_options.txt.

This series tries to remove the code duplication by passing unknown --enable and --disable options to a Perl program, and using Meson's introspection support to match those to meson_options.txt. About 80% of the options can be handled completely by the new mechanism. Five meson options are not of the --enable/--disable kind. Six more need to be parsed in configure for various reasons documented in the patch, but they still have their help automatically generated.

The advantages are simple to explain, and are basically what you can expect from an introspection-based system:

- there is obviously much less code in configure. About 1000 lines of the script deal with command line parsing, and the patch removes a quarter of them.

- the script is higher quality than the repetitive code in configure. Help is generally more complete and useful, for example it consistently lists defaults as well as the possible choices if they are not just enabled/disabled/auto. Parsing is more consistent too, for example --enable-slirp and --enable-blobs were not supported.

- new Meson options do not need any change to the configure script. This increases the attractiveness of converting options from hand-crafted parsing and config-host.mak to Meson.

The disadvantages are:

- a few options change name: --enable-tcmalloc and --enable-jemalloc become --enable-malloc={tcmalloc,jemalloc}; --disable-blobs becomes --disable-install-blobs.

- because we need to run the script to generate the full help, we cannot rely on the user supplying the path to a Python interpreter with --python. For this reason, the script is written in Perl. Perl 5 is universally available as "/usr/bin/env perl", while (even ignoring the Python 2/3 difference) some systems do not have a "python" or "python3" binary on the path.

- because we parse command-line options before meson is available, the introspection output is stored in the source tree. This is the reason for the unattractive diffstat; the number of JSON lines added is higher than the number of configure lines removed. Of course the latter are code that must be maintained manually and the former is not.

Note that the output of "meson introspect --buildoptions" is massaged slightly, in order to make it more stable and avoid horrible conflicts on every modification to meson_options.txt.

---
 Makefile                                |  11 +
 configure                               | 371 ++----------
 docs/devel/build-system.rst             |  49 +-
 meson-buildoptions.json                 | 717 ++++++++++++++++++++++++
 meson_options.txt                       |   9 +-
 scripts/configure-parse-buildoptions.pl | 205 +++++++
 6 files changed, 993 insertions(+), 369 deletions(-)
 create mode 100644 meson-buildoptions.json
 create mode 100755 scripts/configure-parse-buildoptions.pl
Makefile +11 -0
index fb9923ff22..eca42f08d3 100644
@@ -142,6 +142,17 @@ ifneq ($(MESON),)
 Makefile.mtest: build.ninja scripts/mtest2make.py
 	$(MESON) introspect --targets --tests --benchmarks | $(PYTHON) scripts/mtest2make.py > $@
 -include Makefile.mtest
+
+# python is used to keep the result stable
+.PHONY: update-buildoptions
+all update-buildoptions: $(SRC_PATH)/meson-buildoptions.json
+$(SRC_PATH)/meson-buildoptions.json: $(SRC_PATH)/meson_options.txt
+	$(MESON) introspect --buildoptions $(SRC_PATH)/meson.build | $(PYTHON) -c \
+	         'import json, sys; print( \
+	            json.dumps(sorted([x for x in json.loads(sys.stdin.read()) \
+	                               if x["section"] == "user"], \
+	                              key=lambda x: x["name"]), \
+	                       indent=2))' > $@
 endif
 
 # 4. Rules to bridge to other makefiles
configure +40 -331

659 lines not on this page · raw message

docs/devel/build-system.rst +12 -37

76 lines not on this page · raw message

meson-buildoptions.json new file +717 -0

717 lines not on this page · raw message

meson_options.txt +8 -1
index b9b106675f..08d02498ac 100644
@@ -1,3 +1,7 @@
+# These options do not correspond to a --enable/--disable-* option
+# on the configure script command line.  If you add more, list them in
+# scripts/configure-parse-buildoptions.pl's SKIP_OPTIONS constant too.
+
 option('qemu_suffix', type : 'string', value: 'qemu',
        description: 'Suffix for QEMU data/modules/config directories (can be empty)')
 option('docdir', type : 'string', value : 'doc',
@@ -6,9 +10,12 @@ option('qemu_firmwarepath', type : 'string', value : '',
        description: 'search PATH for firmware files')
 option('sphinx_build', type : 'string', value : '',
        description: 'Use specified sphinx-build [$sphinx_build] for building document (default to be empty)')
-
 option('default_devices', type : 'boolean', value : true,
        description: 'Include a default selection of devices in emulators')
+
+# Everything else can be set via --enable/--disable-* option
+# on the configure script command line.
+
 option('docs', type : 'feature', value : 'auto',
        description: 'Documentations build support')
 option('gettext', type : 'feature', value : 'auto',
scripts/configure-parse-buildoptions.pl new file +205 -0

205 lines not on this page · raw message

Signature · 1 line
2.29.2
#25 lore raw

Re: [PATCH 8/8] configure: automatically parse command line for meson -D options

Quoted 37 lines · Paolo Bonzini

Right now meson_options.txt lists almost 60 options. Each option needs code in configure to parse it and pass the option down to Meson as a -D command-line argument; in addition the default must be duplicated between configure and meson_options.txt.

This series tries to remove the code duplication by passing unknown --enable and --disable options to a Perl program, and using Meson's introspection support to match those to meson_options.txt. About 80% of the options can be handled completely by the new mechanism. Five meson options are not of the --enable/--disable kind. Six more need to be parsed in configure for various reasons documented in the patch, but they still have their help automatically generated.

The advantages are simple to explain, and are basically what you can expect from an introspection-based system:

- there is obviously much less code in configure. About 1000 lines of the script deal with command line parsing, and the patch removes a quarter of them.

- the script is higher quality than the repetitive code in configure. Help is generally more complete and useful, for example it consistently lists defaults as well as the possible choices if they are not just enabled/disabled/auto. Parsing is more consistent too, for example --enable-slirp and --enable-blobs were not supported.

- new Meson options do not need any change to the configure script. This increases the attractiveness of converting options from hand-crafted parsing and config-host.mak to Meson.

The disadvantages are:

- a few options change name: --enable-tcmalloc and --enable-jemalloc become --enable-malloc={tcmalloc,jemalloc}; --disable-blobs becomes --disable-install-blobs.

Quoted 6 lines

- because we need to run the script to generate the full help, we cannot rely on the user supplying the path to a Python interpreter with --python. For this reason, the script is written in Perl. Perl 5 is universally available as "/usr/bin/env perl", while (even ignoring the Python 2/3 difference) some systems do not have a "python" or "python3" binary on the path.

Can't we just use "/usr/bin/env python3", and if that doesn't exist in $PATH, simply show truncated --help output, with a message requesting that they pass --python to see full help.

Quoted 12 lines

- because we parse command-line options before meson is available, the introspection output is stored in the source tree. This is the reason for the unattractive diffstat; the number of JSON lines added is higher than the number of configure lines removed. Of course the latter are code that must be maintained manually and the former is not.

Note that the output of "meson introspect --buildoptions" is massaged slightly, in order to make it more stable and avoid horrible conflicts on every modification to meson_options.txt.

Quoted 6 lines
---
 Makefile                                |  11 +
 configure                               | 371 ++----------
 docs/devel/build-system.rst             |  49 +-
 meson-buildoptions.json                 | 717 ++++++++++++++++++++++++

I'm not a fan of seeing this file introduced as it has significant
overlap with meson_options.txt. I feel like the latter has enough
information present to do an acceptable job for help output. After all that's sufficient if we were using meson directly.

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 :|
#26 lore raw

Re: [PATCH 8/8] configure: automatically parse command line for meson -D options

Quoted 11 lines · Daniel P. Berrangé
Quoted 7 lines

- because we need to run the script to generate the full help, we cannot rely on the user supplying the path to a Python interpreter with --python. For this reason, the script is written in Perl. Perl 5 is universally available as "/usr/bin/env perl", while (even ignoring the Python 2/3 difference) some systems do not have a "python" or "python3" binary on the path.

Can't we just use "/usr/bin/env python3", and if that doesn't exist in $PATH, simply show truncated --help output, with a message requesting that they pass --python to see full help.

We can and it's what the RFC did, but I found it to be ugly for the user. For example the rest of the build defaults not to "/usr/bin/env python3" but to whatever Python interpreter /usr/bin/meson uses.

Not that Perl is pretty, :) but developer ugliness ranks a notch lower than user-visible ugliness. I cannot think of anything else that is already required to build QEMU and can parse JSON.

I don't expect this script to see any change ever, except for occasionally updating SKIP_OPTIONS. Meson introspection data is backwards-compatible.

Paolo

#27 lore raw

Re: [PATCH 8/8] configure: automatically parse command line for meson -D options

In reply to Daniel P. Berrangé
Quoted 5 lines · Daniel P. Berrangé
Quoted 1 line
  meson-buildoptions.json                 | 717 ++++++++++++++++++++++++

I'm not a fan of seeing this file introduced as it has significant
overlap with meson_options.txt. I feel like the latter has enough
information present to do an acceptable job for help output. After all that's sufficient if we were using meson directly.

Sorry, I missed this remark. meson-buildoptions.json is not hand-written. It is the result of Meson's own parsing meson_options.txt exported as JSON.

In the commit message "because we parse command-line options before meson is available, the introspection output is stored in the source tree. This is the reason for the unattractive diffstat; the number of JSON lines added is higher than the number of configure lines removed. Of course the latter are code that must be maintained manually and the former is not".

Paolo

#28 lore raw

Re: [PATCH 8/8] configure: automatically parse command line for meson -D options

Hi Paolo, as python and meson are required dependencies to building qemu now,
can we detecting python/meson at the very begining of configure, even before the --help parameter.

Quoted 3 lines · Paolo Bonzini
Quoted 1 line · Daniel P. Berrangé
Quoted 1 line
  meson-buildoptions.json                 | 717

++++++++++++++++++++++++

Quoted 9 lines
Quoted 4 lines

I'm not a fan of seeing this file introduced as it has significant
overlap with meson_options.txt. I feel like the latter has enough
information present to do an acceptable job for help output. After all that's sufficient if we were using meson directly.

Sorry, I missed this remark. meson-buildoptions.json is not hand-written. It is the result of Meson's own parsing meson_options.txt exported as JSON.

Quoted 10 lines

In the commit message "because we parse command-line options before meson is available, the introspection output is stored in the source tree. This is the reason for the unattractive diffstat; the number of JSON lines added is higher than the number of configure lines removed. Of course the latter are code that must be maintained manually and the former is not".

Paolo

--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo

#29 lore raw

Re: [PATCH 8/8] configure: automatically parse command line for meson -D options

Il ven 22 gen 2021, 09:00 罗勇刚(Yonggang Luo) <[email protected]> ha scritto:

Quoted 5 lines

Hi Paolo, as python and meson are required dependencies to building qemu now,
can we detecting python/meson at the very begining of configure, even before the --help parameter.

We could and I did it in the first version. However it's ugly that the user has to use --python on some setups in order to get a full help message.

Paolo

Quoted 34 lines · Paolo Bonzini
Quoted 3 lines · Daniel P. Berrangé
Quoted 1 line
Quoted 1 line
  meson-buildoptions.json                 | 717

++++++++++++++++++++++++

Quoted 9 lines
Quoted 4 lines

I'm not a fan of seeing this file introduced as it has significant
overlap with meson_options.txt. I feel like the latter has enough
information present to do an acceptable job for help output. After all that's sufficient if we were using meson directly.

Sorry, I missed this remark. meson-buildoptions.json is not hand-written. It is the result of Meson's own parsing meson_options.txt exported as JSON.

Quoted 10 lines

In the commit message "because we parse command-line options before meson is available, the introspection output is stored in the source tree. This is the reason for the unattractive diffstat; the number of JSON lines added is higher than the number of configure lines removed. Of course the latter are code that must be maintained manually and the former is not".

Paolo

--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo

#30 lore raw

Re: [PATCH 8/8] configure: automatically parse command line for meson -D options

Quoted 4 lines · Paolo Bonzini

Il ven 22 gen 2021, 09:00 罗勇刚(Yonggang Luo) <[email protected]> ha

scritto:

Quoted 2 lines
Quoted 2 lines

Hi Paolo, as python and meson are required dependencies to building qemu

now,

Quoted 5 lines
Quoted 2 lines

can we detecting python/meson at the very begining of configure, even before the --help parameter.

We could and I did it in the first version. However it's ugly that the

user has to use --python on some setups in order to get a full help message.

Yeap, but finally configure should gone, so I think --python are
acceptable by user, just need make sure to be noticed when the default python
are not python3

Quoted 5 lines

Paolo

Quoted 2 lines

On Wed, Jan 13, 2021 at 6:08 AM Paolo Bonzini <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines · Daniel P. Berrangé
Quoted 1 line
Quoted 1 line
  meson-buildoptions.json                 | 717

++++++++++++++++++++++++

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

I'm not a fan of seeing this file introduced as it has significant
overlap with meson_options.txt. I feel like the latter has enough
information present to do an acceptable job for help output. After all that's sufficient if we were using meson directly.

Sorry, I missed this remark. meson-buildoptions.json is not hand-written. It is the result of Meson's own parsing

meson_options.txt

Quoted 14 lines
Quoted 14 lines
Quoted 12 lines

exported as JSON.

In the commit message "because we parse command-line options before meson is available, the introspection output is stored in the source tree. This is the reason for the unattractive diffstat; the number of JSON lines added is higher than the number of configure lines removed. Of course the latter are code that must be maintained manually and the former is not".

Paolo

Quoted 7 lines
Quoted 7 lines

--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo

--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo

#31 lore raw

Re: [PATCH 8/8] configure: automatically parse command line for meson -D options

Quoted 6 lines · 罗勇刚(Yonggang Luo)
Quoted 1 line

We could and I did it in the first version. However it's ugly that

the user has to use --python on some setups in order to get a full help message.

  Yeap, but finally configure should gone, so I think --python are
acceptable by user, just need make sure to be noticed when the default python are not python3

When configure will be gone, these 200 lines of Perl will disappear with it, so we don't have to think for future users and developers, but for the present.

I don't expect configure or Makefile to go away completely, because for example things such as "git submodule" handling are easier to do in the shell. However, we also need to evaluate what's the road to a minimal configure (just like our Makefile is pretty minimal, only tests/tcg still has lots of build logic). In that respect, automatic parsing command line simplifies moving things from configure to meson, and that is true no matter what language the parser is written in.

(BTW, I'm not such a Perl fan. I have only ever written like 3 or 4 programs in Perl).

Paolo