Features/Meson: Difference between revisions

From QEMU
Line 7: Line 7:
* You cannot <tt>#include "config-target.h"</tt> and <tt>"config-devices.h"</tt>.  Instead, you <tt>#include CONFIG_TARGET</tt> and <tt>CONFIG_DEVICES</tt> (i.e. filenames are specified via macros).
* You cannot <tt>#include "config-target.h"</tt> and <tt>"config-devices.h"</tt>.  Instead, you <tt>#include CONFIG_TARGET</tt> and <tt>CONFIG_DEVICES</tt> (i.e. filenames are specified via macros).
* Most binaries are built by default by <tt>make all</tt>, including several in contrib/ that weren't built before.  Currently, vhost-user-blk and rdmacm-mux are not because they fail on 32-bit and big-endian platforms respectively.
* Most binaries are built by default by <tt>make all</tt>, including several in contrib/ that weren't built before.  Currently, vhost-user-blk and rdmacm-mux are not because they fail on 32-bit and big-endian platforms respectively.
* .c files cannot be #included.  They have been renamed to .c.inc, for consistency with existing .rst.inc files.
* .c files (including .inc.c files) cannot be #included.  They have been renamed to .c.inc, for consistency with existing .rst.inc files.
* The name of files produced by decodetree is fixed (the C code for <tt>XYZ.decode</tt> ends up in <tt>decode-XYZ.c.inc</tt>).
* Subdirectories with trace events require a forwarding header file; see hw/scsi/trace.h for an example.
* Sphinx manuals are only built if their constituent files are changed, therefore "make sphinxdocs" will be plenty fast when you've only modified a file or two.
* Sphinx manuals are only built if their constituent files are changed, therefore "make sphinxdocs" will be plenty fast when you've only modified a file or two.
* Dependencies added to libqemuutil.a will propagate to all programs that link to it.  If util/ code has dependencies, it should be conditional on have_system or have_block if applicable (this was a bug in the Makefiles).
* Dependencies added to libqemuutil.a will propagate to all programs that link to it.  If util/ code has dependencies, it should be conditional on have_system or have_block if applicable (this was a bug in the Makefiles).

Revision as of 23:16, 19 August 2020

What's next?

Summary of changes

  • New system requirements: GNU Make 3.82, Python setuptools
  • The Makefile is not recursive anymore. You don't make aarch64-softmmu/all or make arm-linux-user/all, you make qemu-system-aarch64 or make qemu-arm.
  • Binaries have moved to the root of the build directory. For now, paths such as cris-softmmu/qemu-system-cris are preserved for backwards compatibility through symlinks (created by configure. They are just a user convenience however. You cannot "rm" them to force a rebuild, for example.
  • You cannot #include "config-target.h" and "config-devices.h". Instead, you #include CONFIG_TARGET and CONFIG_DEVICES (i.e. filenames are specified via macros).
  • Most binaries are built by default by make all, including several in contrib/ that weren't built before. Currently, vhost-user-blk and rdmacm-mux are not because they fail on 32-bit and big-endian platforms respectively.
  • .c files (including .inc.c files) cannot be #included. They have been renamed to .c.inc, for consistency with existing .rst.inc files.
  • The name of files produced by decodetree is fixed (the C code for XYZ.decode ends up in decode-XYZ.c.inc).
  • Subdirectories with trace events require a forwarding header file; see hw/scsi/trace.h for an example.
  • Sphinx manuals are only built if their constituent files are changed, therefore "make sphinxdocs" will be plenty fast when you've only modified a file or two.
  • Dependencies added to libqemuutil.a will propagate to all programs that link to it. If util/ code has dependencies, it should be conditional on have_system or have_block if applicable (this was a bug in the Makefiles).
  • For bisection: incremental builds work fine in the forward direction. They probably don't work at all backwards. This is mitigated by the fact that bisection usually starts at a release, and the patches should be applied on top of the 5.1.0 tag.

CI holes

The following issues were _not_ found by GitLab CI:

  • SDL 2.0.8 requires -Wno-undef
  • s390x-softmmu is special for cross-compilation, because it is the only target to use the host C compiler.
  • There is special code in configure to handle a C++ compiler that does not play well with the C compiler.
  • Big endian platforms are not covered.
  • ARM host platforms are not covered.
  • 32-bit POSIX platforms are not covered.
  • Peter uses Ubuntu+MXE instead of Fedora-mingw to build cross compilers. docker-test-mingw only works for Fedora and should be made more generic. Also container images for Fedora-mingw should be prepared in the same way as the existing container images for Debian+MXE.

Blockers for further conversions

Complete moving installation rules to meson.build
Posted as part of [RFC PATCH v3 000/132] Proof of concept for Meson integration (Dec 2019). You're welcome to propose yourself for helping!
Benefit: allows removing parts of Makefile, leaving it as just an orchestrator for submodules, Makefile.ninja and Makefile.mtest
Complete moving build rules to meson.build
Move the build rules from tests/Makefile.include to tests/meson.build. You can take inspiration from tests/qtest/Makefile.include.
[RFC PATCH v3 000/132] Proof of concept for Meson integration also has patches to convert the build rules in roms/ and pc-bios/
Benefit: allows removing CFLAGS, LDFLAGS, LIBS and LIBS_SOFTMMU, as well as most if not all of rules.mak.
Relocatable install
Not really related to Meson, but it allows removing the pre_prefix hack in the configure script.
Benefit: on Windows only /usr/share/qemu is relocatable, everything else (icons etc.) is not. POSIX is currently not relocatable and would get it for free.

Easy

Move pkg-config tests to meson.build
Replace declare_dependency statements with dependency statements
Benefit: allows removing *_CFLAGS and *_LIBS variables from config-host.mak. Allows using dependency objects instead of CONFIG_* symbols when declaring sourcesets.
Change simple config-host.mak symbols to Meson options
Some symbols (e.g. CONFIG_PARALLELS) are only used placed in config-host.mak to be read from Meson. Instead pass them through -D... command-line options
Benefit: allows removing CONFIG_* variables from config-host.mak.

Medium

"Handle (faked-up) in-tree build
And cleanup code to handle in-tree builds in configure. Or fail gracefully and explain the situation (which would be easier).
Benefit: simpler upgrade path
Include config-target.mak files in the tree
Remove the configuration loop in configure and just include the content of the .mak files directly in the tree, for example in a target/configs/ directory. (There are some small complications because config-target.mak file currently includes the host disassembler symbols too, e.g. CONFIG_I386_DIS).
Benefit: remove large swaths of imperative code, remove *-linux-user and *-softmmu directories from the build tree.
Move other compile tests from configure to meson.build

Hard(er)

Create configure help and command line parsing code from meson_options.txt.
Write a program that takes the output of "meson introspect --buildoptions" and generates shell code to initialize variables, parse command line options, print the help and create -D command line options for meson. May only make sense once many or most options are converted.
Benefit: remove code duplication, centralize command line handling

TBD

Get rid of ninjatool and just require Ninja
Benefit: 1000 lines of code go away, can use things such as ninja -t clean <TARGET>
Disadvantage: recursive build re-enters through the window