Skip to contentSkip to conversation

Upgrade Meson to 0.57.x

PATCH In review Paolo Bonzini 3 participants 9 messages Mar 10, 2021 – Mar 11, 2021 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover Upgrade Meson to 0.57.x

While Meson 0.57 was already tested with QEMU prior to the release, it had a few regressions so I opted for waiting until a few weeks after 0.57.1. This way, distros that want to avoid the bundled versions of Meson do not have to deal with the bugs in 0.57.

There are some new features and changes that are of interest for QEMU:

- there is a new "env" keyword argument to custom_target, which is nice to have in the hexagon target. This is handled by patches 1 and 4; patch 1 also fixes some Windows portability issues, which currently are masked by not having a softmmu target for hexagon.

- that build.ninja sorting order is stable and rerunning meson will not trigger a full rebuild. Unfortunately this is not enough to avoid full rebuilds in subsequent CI pipeline phases, those seem to be caused by "wrong" timestamps after a checkout (see for example
https://gitlab.com/gitlab-org/gitlab/-/issues/234078).

- with the new version it is possible to use "meson test" to run the QEMU testsuite. This is not yet done by default, and it won't be for 6.0, but you are encouraged to try it out.

- there is an easier method to load a project's version from an external file

Paolo Bonzini (4):
hexagon: do not specify Python scripts as inputs
meson: bump submodule to 0.57.1
meson: switch minimum meson version to 0.57.0
hexagon: use env keyword argument to pass PYTHONPATH

 configure                     |  7 +----
 docs/meson.build              | 12 ++++----
 meson                         |  2 +-
 meson.build                   | 54 ++++++++++++++++-------------------
 plugins/meson.build           |  4 +--
 target/hexagon/meson.build    | 31 +++++++-------------
 tests/meson.build             |  2 +-
 tests/qapi-schema/meson.build |  4 +--
 tests/qtest/meson.build       |  2 +-
 trace/meson.build             |  4 +--
 10 files changed, 52 insertions(+), 70 deletions(-)
Signature · 1 line
2.29.2
#1 lore raw

PATCH 1/4 hexagon: do not specify Python scripts as inputs

Python scripts are not inputs, and putting them in @INPUT@. This puts requirements on the command line format, keeping all inputs close to the name of the script. Avoid that by not including the script in the command and not in the inputs.

Also wrap "PYTHONPATH" usage with "env", since setting the environment this way is not valid under Windows.

---
 target/hexagon/meson.build | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)
target/hexagon/meson.build +10 -20
index 5dd68907b1..bb0b4fb621 100644
@@ -53,90 +53,81 @@ hexagon_ss.add(semantics_generated)
 shortcode_generated = custom_target(
     'shortcode_generated.h.inc',
     output: 'shortcode_generated.h.inc',
-    input: 'gen_shortcode.py',
     depends: [semantics_generated],
     depend_files: [hex_common_py, attribs_def],
-    command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
+    command: [python, files('gen_shortcode.py'), semantics_generated, attribs_def, '@OUTPUT@'],
 )
 hexagon_ss.add(shortcode_generated)
 
 helper_protos_generated = custom_target(
     'helper_protos_generated.h.inc',
     output: 'helper_protos_generated.h.inc',
-    input: 'gen_helper_protos.py',
     depends: [semantics_generated],
     depend_files: [hex_common_py, attribs_def, gen_tcg_h],
-    command: [python, '@INPUT@', semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
+    command: [python, files('gen_helper_protos.py'), semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
 )
 hexagon_ss.add(helper_protos_generated)
 
 tcg_funcs_generated = custom_target(
     'tcg_funcs_generated.c.inc',
     output: 'tcg_funcs_generated.c.inc',
-    input: 'gen_tcg_funcs.py',
     depends: [semantics_generated],
     depend_files: [hex_common_py, attribs_def, gen_tcg_h],
-    command: [python, '@INPUT@', semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
+    command: [python, files('gen_tcg_funcs.py'), semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
 )
 hexagon_ss.add(tcg_funcs_generated)
 
 tcg_func_table_generated = custom_target(
     'tcg_func_table_generated.c.inc',
     output: 'tcg_func_table_generated.c.inc',
-    input: 'gen_tcg_func_table.py',
     depends: [semantics_generated],
     depend_files: [hex_common_py, attribs_def],
-    command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
+    command: [python, files('gen_tcg_func_table.py'), semantics_generated, attribs_def, '@OUTPUT@'],
 )
 hexagon_ss.add(tcg_func_table_generated)
 
 helper_funcs_generated = custom_target(
     'helper_funcs_generated.c.inc',
     output: 'helper_funcs_generated.c.inc',
-    input: 'gen_helper_funcs.py',
     depends: [semantics_generated],
     depend_files: [hex_common_py, attribs_def, gen_tcg_h],
-    command: [python, '@INPUT@', semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
+    command: [python, files('gen_helper_funcs.py'), semantics_generated, attribs_def, gen_tcg_h, '@OUTPUT@'],
 )
 hexagon_ss.add(helper_funcs_generated)
 
 printinsn_generated = custom_target(
     'printinsn_generated.h.inc',
     output: 'printinsn_generated.h.inc',
-    input: 'gen_printinsn.py',
     depends: [semantics_generated],
     depend_files: [hex_common_py, attribs_def],
-    command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
+    command: [python, files('gen_printinsn.py'), semantics_generated, attribs_def, '@OUTPUT@'],
 )
 hexagon_ss.add(printinsn_generated)
 
 op_regs_generated = custom_target(
     'op_regs_generated.h.inc',
     output: 'op_regs_generated.h.inc',
-    input: 'gen_op_regs.py',
     depends: [semantics_generated],
     depend_files: [hex_common_py, attribs_def],
-    command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
+    command: [python, files('gen_op_regs.py'), semantics_generated, attribs_def, '@OUTPUT@'],
 )
 hexagon_ss.add(op_regs_generated)
 
 op_attribs_generated = custom_target(
     'op_attribs_generated.h.inc',
     output: 'op_attribs_generated.h.inc',
-    input: 'gen_op_attribs.py',
     depends: [semantics_generated],
     depend_files: [hex_common_py, attribs_def],
-    command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
+    command: [python, files('gen_op_attribs.py'), semantics_generated, attribs_def, '@OUTPUT@'],
 )
 hexagon_ss.add(op_attribs_generated)
 
 opcodes_def_generated = custom_target(
     'opcodes_def_generated.h.inc',
     output: 'opcodes_def_generated.h.inc',
-    input: 'gen_opcodes_def.py',
     depends: [semantics_generated],
     depend_files: [hex_common_py, attribs_def],
-    command: [python, '@INPUT@', semantics_generated, attribs_def, '@OUTPUT@'],
+    command: [python, files('gen_opcodes_def.py'), semantics_generated, attribs_def, '@OUTPUT@'],
 )
 hexagon_ss.add(opcodes_def_generated)
 
@@ -164,9 +155,8 @@ hexagon_ss.add(iset_py)
 dectree_generated = custom_target(
     'dectree_generated.h.inc',
     output: 'dectree_generated.h.inc',
-    input: 'dectree.py',
     depends: [iset_py],
-    command: ['PYTHONPATH=' + meson.current_build_dir(), '@INPUT@', '@OUTPUT@'],
+    command: ['env', 'PYTHONPATH=' + meson.current_build_dir(), files('dectree.py'), '@OUTPUT@'],
 )
 hexagon_ss.add(dectree_generated)
 
Signature · 1 line
2.29.2
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] hexagon: do not specify Python scripts as inputs

Quoted 5 lines · Paolo Bonzini

Python scripts are not inputs, and putting them in @INPUT@. This puts requirements on the command line format, keeping all inputs close to the name of the script. Avoid that by not including the script in the command and not in the inputs.

Quoted 7 lines

Also wrap "PYTHONPATH" usage with "env", since setting the environment this way is not valid under Windows.

---
 target/hexagon/meson.build | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)
#3 lore raw

Re: [PATCH 1/4] hexagon: do not specify Python scripts as inputs

In reply to Paolo Bonzini

target/hexagon/meson.build hexagon_ss.add(iset_py) · line 159

Quoted 2 lines · Paolo Bonzini
target/hexagon/meson.build +1 -1
-    command: ['PYTHONPATH=' + meson.current_build_dir(), '@INPUT@', '@OUTPUT@'],
+    command: ['env', 'PYTHONPATH=' + meson.current_build_dir(), files('dectree.py'), '@OUTPUT@'],

Should we not use the python variable in this command-line?

r~

#4 lore raw

Re: [PATCH 1/4] hexagon: do not specify Python scripts as inputs

Quoted 7 lines · Richard Henderson
Quoted 4 lines · Paolo Bonzini

-    command: ['PYTHONPATH=' + meson.current_build_dir(), '@INPUT@', '@OUTPUT@'],
+    command: ['env', 'PYTHONPATH=' + meson.current_build_dir(), files('dectree.py'), '@OUTPUT@'],

Should we not use the python variable in this command-line?

I wanted to just fix the portability issue, but yeah I could have placed it here or even in a separate patch.

Paolo

#5 lore raw

PATCH 2/4 meson: bump submodule to 0.57.1

In reply to Paolo Bonzini

The main advantage of 0.57 is that it fixes
https://github.com/mesonbuild/meson/pull/7900, thus avoiding unnecessary rebuilds after running meson.

---
 meson | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meson +1 -1
index 776acd2a80..7182685b22 160000
@@ -1 +1 @@
-Subproject commit 776acd2a805c9b42b4f0375150977df42130317f
+Subproject commit 7182685b2241e88340b6c3340afba59a26be213f
Signature · 1 line
2.29.2
#6 lore raw

PATCH 3/4 meson: switch minimum meson version to 0.57.0

In reply to Paolo Bonzini

Meson 0.57.0 does not need b_staticpic=$pie anymore, and has stabilized the keyval module. Remove the workaround and use a few replacements for features deprecated in the 0.57.0 release cycle.

---
 configure                     |  7 +----
 docs/meson.build              | 12 ++++----
 meson.build                   | 54 ++++++++++++++++-------------------
 plugins/meson.build           |  4 +--
 tests/meson.build             |  2 +-
 tests/qapi-schema/meson.build |  4 +--
 tests/qtest/meson.build       |  2 +-
 trace/meson.build             |  4 +--
 8 files changed, 40 insertions(+), 49 deletions(-)
configure +1 -6
index 34fccaa2ba..899922ca47 100755
@@ -1945,7 +1945,7 @@ python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0]
 python="$python -B"
 
 if test -z "$meson"; then
-    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.3; then
+    if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.57.0; then
         meson=meson
     elif test $git_submodules_action != 'ignore' ; then
         meson=git
@@ -6384,10 +6384,6 @@ fi
 mv $cross config-meson.cross
 
 rm -rf meson-private meson-info meson-logs
-unset staticpic
-if ! version_ge "$($meson --version)" 0.56.0; then
-  staticpic=$(if test "$pie" = yes; then echo true; else echo false; fi)
-fi
 NINJA=$ninja $meson setup \
         --prefix "$prefix" \
         --libdir "$libdir" \
@@ -6407,7 +6403,6 @@ NINJA=$ninja $meson setup \
         -Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
         -Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
         -Db_pie=$(if test "$pie" = yes; then echo true; else echo false; fi) \
-        ${staticpic:+-Db_staticpic=$staticpic} \
         -Db_coverage=$(if test "$gcov" = yes; then echo true; else echo false; fi) \
         -Db_lto=$lto -Dcfi=$cfi -Dcfi_debug=$cfi_debug \
         -Dmalloc=$malloc -Dmalloc_trim=$malloc_trim -Dsparse=$sparse \
docs/meson.build +6 -6
index f84306ba7e..0aa98719af 100644
@@ -38,12 +38,12 @@ endif
 if build_docs
   SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + config_host['PKGVERSION']]
 
-  sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py',
-                          meson.source_root() / 'docs/sphinx/hxtool.py',
-                          meson.source_root() / 'docs/sphinx/kerneldoc.py',
-                          meson.source_root() / 'docs/sphinx/kernellog.py',
-                          meson.source_root() / 'docs/sphinx/qapidoc.py',
-                          meson.source_root() / 'docs/sphinx/qmp_lexer.py',
+  sphinx_extn_depends = [ meson.current_source_dir() / 'sphinx/depfile.py',
+                          meson.current_source_dir() / 'sphinx/hxtool.py',
+                          meson.current_source_dir() / 'sphinx/kerneldoc.py',
+                          meson.current_source_dir() / 'sphinx/kernellog.py',
+                          meson.current_source_dir() / 'sphinx/qapidoc.py',
+                          meson.current_source_dir() / 'sphinx/qmp_lexer.py',
                           qapi_gen_depends ]
 
   have_ga = have_tools and config_host.has_key('CONFIG_GUEST_AGENT')
meson.build +25 -29

95 lines not on this page · raw message

plugins/meson.build +2 -2
index e77723010e..d58efc980e 100644
@@ -1,7 +1,7 @@
 if 'CONFIG_HAS_LD_DYNAMIC_LIST' in config_host
-  plugin_ldflags = ['-Wl,--dynamic-list=' + (meson.build_root() / 'qemu-plugins-ld.symbols')]
+  plugin_ldflags = ['-Wl,--dynamic-list=' + (meson.project_build_root() / 'qemu-plugins-ld.symbols')]
 elif 'CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST' in config_host
-  plugin_ldflags = ['-Wl,-exported_symbols_list,' + (meson.build_root() / 'qemu-plugins-ld64.symbols')]
+  plugin_ldflags = ['-Wl,-exported_symbols_list,' + (meson.project_build_root() / 'qemu-plugins-ld64.symbols')]
 else
   plugin_ldflags = []
 endif
tests/meson.build +1 -1
index 656d211e25..c45f5e2275 100644
@@ -112,7 +112,7 @@ tests = {
   'test-keyval': [testqapi],
   'test-logging': [],
   'test-uuid': [],
-  'ptimer-test': ['ptimer-test-stubs.c', meson.source_root() / 'hw/core/ptimer.c'],
+  'ptimer-test': ['ptimer-test-stubs.c', meson.project_source_root() / 'hw/core/ptimer.c'],
   'test-qapi-util': [],
 }
 
tests/qapi-schema/meson.build +2 -2
index 304ef939bd..26588396d2 100644
@@ -1,5 +1,5 @@
 test_env = environment()
-test_env.set('PYTHONPATH', meson.source_root() / 'scripts')
+test_env.set('PYTHONPATH', meson.project_source_root() / 'scripts')
 test_env.set('PYTHONIOENCODING', 'utf-8')
 
 schemas = [
@@ -240,7 +240,7 @@ if build_docs
                                # clutter up the build dir with the cache.
                                command: [SPHINX_ARGS,
                                          '-b', 'text', '-E',
-                                         '-c', meson.source_root() / 'docs',
+                                         '-c', meson.project_source_root() / 'docs',
                                          '-D', 'master_doc=doc-good',
                                          meson.current_source_dir(),
                                          meson.current_build_dir()])
tests/qtest/meson.build +1 -1
index 58efc46144..eb254341eb 100644
@@ -260,7 +260,7 @@ foreach dir : target_dirs
     qtest_env.set('QTEST_QEMU_IMG', './qemu-img')
     test_deps += [qemu_img]
   endif
-  qtest_env.set('G_TEST_DBUS_DAEMON', meson.source_root() / 'tests/dbus-vmstate-daemon.sh')
+  qtest_env.set('G_TEST_DBUS_DAEMON', meson.project_source_root() / 'tests/dbus-vmstate-daemon.sh')
   qtest_env.set('QTEST_QEMU_BINARY', './qemu-system-' + target_base)
   
   foreach test : target_qtests
trace/meson.build +2 -2
index 08f83a15c3..317b557915 100644
@@ -3,7 +3,7 @@ specific_ss.add(files('control-target.c'))
 
 trace_events_files = []
 foreach dir : [ '.' ] + trace_events_subdirs
-  trace_events_file = meson.source_root() / dir / 'trace-events'
+  trace_events_file = meson.project_source_root() / dir / 'trace-events'
   trace_events_files += [ trace_events_file ]
   group_name = dir == '.' ? 'root' : dir.underscorify()
   group = '--group=' + group_name
@@ -69,7 +69,7 @@ foreach d : [
 ]
   gen = custom_target(d[0],
                 output: d[0],
-                input: meson.source_root() / 'trace-events',
+                input: meson.project_source_root() / 'trace-events',
                 command: [ tracetool, '--group=root', '--format=@0@'.format(d[1]), '@INPUT@', '@OUTPUT@' ],
                 depend_files: tracetool_depends)
   specific_ss.add(when: 'CONFIG_TCG', if_true: gen)
Signature · 1 line
2.29.2
#7 lore raw

PATCH 4/4 hexagon: use env keyword argument to pass PYTHONPATH

In reply to Paolo Bonzini

This feature is new in meson 0.57 and allows getting rid of the "env" wrapper.

---
 target/hexagon/meson.build | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
target/hexagon/meson.build +2 -1
index bb0b4fb621..aaeee11ac1 100644
@@ -156,7 +156,8 @@ dectree_generated = custom_target(
     'dectree_generated.h.inc',
     output: 'dectree_generated.h.inc',
     depends: [iset_py],
-    command: ['env', 'PYTHONPATH=' + meson.current_build_dir(), files('dectree.py'), '@OUTPUT@'],
+    env: {'PYTHONPATH': meson.current_build_dir()},
+    command: [python, files('dectree.py'), '@OUTPUT@'],
 )
 hexagon_ss.add(dectree_generated)
 
Signature · 1 line
2.29.2
Reviewed-by on v1 4/4
#8 lore raw

Re: [PATCH 4/4] hexagon: use env keyword argument to pass PYTHONPATH

Quoted 13 lines · Paolo Bonzini

This feature is new in meson 0.57 and allows getting rid of the "env" wrapper.

---
  target/hexagon/meson.build | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
target/hexagon/meson.build +0 -0
index bb0b4fb621..aaeee11ac1 100644

target/hexagon/meson.build dectree_generated = custom_target( · line 163

Quoted 9 lines
target/hexagon/meson.build +2 -1
@@ -156,7 +156,8 @@ dectree_generated = custom_target(
      'dectree_generated.h.inc',
      output: 'dectree_generated.h.inc',
      depends: [iset_py],
-    command: ['env', 'PYTHONPATH=' + meson.current_build_dir(), files('dectree.py'), '@OUTPUT@'],
+    env: {'PYTHONPATH': meson.current_build_dir()},
+    command: [python, files('dectree.py'), '@OUTPUT@'],
  )
  hexagon_ss.add(dectree_generated)
 

This also fixes the python command nit I mentioned vs patch 1.

r~