diff mbox series

configure, meson: synchronize defaults for configure and Meson Rust options

Message ID 20241014110113.173946-1-pbonzini@redhat.com (mailing list archive)
State New, archived
Headers show
Series configure, meson: synchronize defaults for configure and Meson Rust options | expand

Commit Message

Paolo Bonzini Oct. 14, 2024, 11:01 a.m. UTC
If the defaults for --enable-rust ($rust in configure) and Meson's rust
option are out of sync, incremental builds will pick Meson's default.

This happens because, on an incremental build, configure does not run
Meson, Make does instead.  Meson then gets the command line options
from either coredata.dat (which has everything cached in Python's pickle
format) or cmd_line.txt (slow path when Meson version is upgraded), but
neither knows about the rust option, and the meson_options.txt default
is used.

This will cause have_rust to be true if rustc is available; and the build
to fail because configure did not put a RUST_TARGET_TRIPLE in config-host.mak.

When in the Rust pull request I changed the $rust default from auto
to disabled, I should have made the same change to meson_options.txt;
do it now.

Cc: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure         | 2 +-
 meson_options.txt | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Peter Maydell Oct. 14, 2024, 11:45 a.m. UTC | #1
On Mon, 14 Oct 2024 at 12:01, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> If the defaults for --enable-rust ($rust in configure) and Meson's rust
> option are out of sync, incremental builds will pick Meson's default.
>
> This happens because, on an incremental build, configure does not run
> Meson, Make does instead.  Meson then gets the command line options
> from either coredata.dat (which has everything cached in Python's pickle
> format) or cmd_line.txt (slow path when Meson version is upgraded), but
> neither knows about the rust option, and the meson_options.txt default
> is used.
>
> This will cause have_rust to be true if rustc is available; and the build
> to fail because configure did not put a RUST_TARGET_TRIPLE in config-host.mak.
>
> When in the Rust pull request I changed the $rust default from auto
> to disabled, I should have made the same change to meson_options.txt;
> do it now.
>
> Cc: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Reported-by: Daniel P. Berrangé <berrange@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

This fixes the issue I was seeing with my local
incremental rebuild.

Tested-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM
Peter Maydell Oct. 14, 2024, 12:09 p.m. UTC | #2
On Mon, 14 Oct 2024 at 12:45, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Mon, 14 Oct 2024 at 12:01, Paolo Bonzini <pbonzini@redhat.com> wrote:
> >
> > If the defaults for --enable-rust ($rust in configure) and Meson's rust
> > option are out of sync, incremental builds will pick Meson's default.
> >
> > This happens because, on an incremental build, configure does not run
> > Meson, Make does instead.  Meson then gets the command line options
> > from either coredata.dat (which has everything cached in Python's pickle
> > format) or cmd_line.txt (slow path when Meson version is upgraded), but
> > neither knows about the rust option, and the meson_options.txt default
> > is used.
> >
> > This will cause have_rust to be true if rustc is available; and the build
> > to fail because configure did not put a RUST_TARGET_TRIPLE in config-host.mak.
> >
> > When in the Rust pull request I changed the $rust default from auto
> > to disabled, I should have made the same change to meson_options.txt;
> > do it now.
> >
> > Cc: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> > Reported-by: Peter Maydell <peter.maydell@linaro.org>
> > Reported-by: Daniel P. Berrangé <berrange@redhat.com>
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>
> This fixes the issue I was seeing with my local
> incremental rebuild.
>
> Tested-by: Peter Maydell <peter.maydell@linaro.org>

...but this change broke 'make vm-build-openbsd', because
meson-buildoptions.py fell over with an error from the JSON
decoder:

make: Entering directory '/home/peter.maydell/qemu-openbsd/build'
/home/peter.maydell/qemu-openbsd/build/pyvenv/bin/meson introspect
--buildoptions /home/peter.maydell/qemu-openbsd/meson.build |
/home/peter.maydell/qemu-openbsd/build/pyvenv/bin/python3 -B \
  scripts/meson-buildoptions.py >
/home/peter.maydell/qemu-openbsd/scripts/meson-buildoptions.sh.tmp &&
mv /home/peter.maydell/qemu-openbsd/scripts/meson-buildoptions.sh.tmp
/home/peter.maydell/qemu-openbsd/scripts/meson-buildoptions.sh
Trying to enter hw/core which has already been visited --> Skipping
Unable to evaluate subdir([]) in AstInterpreter --> Skipping
Traceback (most recent call last):
  File "/home/peter.maydell/qemu-openbsd/build/scripts/meson-buildoptions.py",
line 245, in <module>
    options = load_options(json.load(sys.stdin))
  File "/usr/lib/python3.10/json/__init__.py", line 293, in load
    return loads(fp.read(),
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
make: *** No rule to make target
'/home/peter.maydell/qemu-openbsd/scripts/meson-buildoptions.sh',
needed by 'config-host.mak'.  Stop.
make: Leaving directory '/home/peter.maydell/qemu-openbsd/build'

-- PMM
Peter Maydell Oct. 14, 2024, 1:45 p.m. UTC | #3
On Mon, 14 Oct 2024 at 13:09, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Mon, 14 Oct 2024 at 12:45, Peter Maydell <peter.maydell@linaro.org> wrote:
> >
> > On Mon, 14 Oct 2024 at 12:01, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > >
> > > If the defaults for --enable-rust ($rust in configure) and Meson's rust
> > > option are out of sync, incremental builds will pick Meson's default.
> > >
> > > This happens because, on an incremental build, configure does not run
> > > Meson, Make does instead.  Meson then gets the command line options
> > > from either coredata.dat (which has everything cached in Python's pickle
> > > format) or cmd_line.txt (slow path when Meson version is upgraded), but
> > > neither knows about the rust option, and the meson_options.txt default
> > > is used.
> > >
> > > This will cause have_rust to be true if rustc is available; and the build
> > > to fail because configure did not put a RUST_TARGET_TRIPLE in config-host.mak.
> > >
> > > When in the Rust pull request I changed the $rust default from auto
> > > to disabled, I should have made the same change to meson_options.txt;
> > > do it now.
> > >
> > > Cc: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> > > Reported-by: Peter Maydell <peter.maydell@linaro.org>
> > > Reported-by: Daniel P. Berrangé <berrange@redhat.com>
> > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> >
> > This fixes the issue I was seeing with my local
> > incremental rebuild.
> >
> > Tested-by: Peter Maydell <peter.maydell@linaro.org>
>
> ...but this change broke 'make vm-build-openbsd', because
> meson-buildoptions.py fell over with an error from the JSON
> decoder:

This happens also on the macos-14 CI job:

https://gitlab.com/qemu-project/qemu/-/jobs/8078308341

Same
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

error and backtrace.

-- PMM
Peter Maydell Oct. 14, 2024, 1:54 p.m. UTC | #4
On Mon, 14 Oct 2024 at 13:09, Peter Maydell <peter.maydell@linaro.org> wrote:
>
> On Mon, 14 Oct 2024 at 12:45, Peter Maydell <peter.maydell@linaro.org> wrote:
> >
> > On Mon, 14 Oct 2024 at 12:01, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > >
> > > If the defaults for --enable-rust ($rust in configure) and Meson's rust
> > > option are out of sync, incremental builds will pick Meson's default.
> > >
> > > This happens because, on an incremental build, configure does not run
> > > Meson, Make does instead.  Meson then gets the command line options
> > > from either coredata.dat (which has everything cached in Python's pickle
> > > format) or cmd_line.txt (slow path when Meson version is upgraded), but
> > > neither knows about the rust option, and the meson_options.txt default
> > > is used.
> > >
> > > This will cause have_rust to be true if rustc is available; and the build
> > > to fail because configure did not put a RUST_TARGET_TRIPLE in config-host.mak.
> > >
> > > When in the Rust pull request I changed the $rust default from auto
> > > to disabled, I should have made the same change to meson_options.txt;
> > > do it now.
> > >
> > > Cc: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> > > Reported-by: Peter Maydell <peter.maydell@linaro.org>
> > > Reported-by: Daniel P. Berrangé <berrange@redhat.com>
> > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> >
> > This fixes the issue I was seeing with my local
> > incremental rebuild.
> >
> > Tested-by: Peter Maydell <peter.maydell@linaro.org>
>
> ...but this change broke 'make vm-build-openbsd', because
> meson-buildoptions.py fell over with an error from the JSON
> decoder:
>
> make: Entering directory '/home/peter.maydell/qemu-openbsd/build'
> /home/peter.maydell/qemu-openbsd/build/pyvenv/bin/meson introspect
> --buildoptions /home/peter.maydell/qemu-openbsd/meson.build |
> /home/peter.maydell/qemu-openbsd/build/pyvenv/bin/python3 -B \
>   scripts/meson-buildoptions.py >
> /home/peter.maydell/qemu-openbsd/scripts/meson-buildoptions.sh.tmp &&
> mv /home/peter.maydell/qemu-openbsd/scripts/meson-buildoptions.sh.tmp
> /home/peter.maydell/qemu-openbsd/scripts/meson-buildoptions.sh
> Trying to enter hw/core which has already been visited --> Skipping
> Unable to evaluate subdir([]) in AstInterpreter --> Skipping
> Traceback (most recent call last):
>   File "/home/peter.maydell/qemu-openbsd/build/scripts/meson-buildoptions.py",
> line 245, in <module>
>     options = load_options(json.load(sys.stdin))
>   File "/usr/lib/python3.10/json/__init__.py", line 293, in load
>     return loads(fp.read(),
>   File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
>     return _default_decoder.decode(s)
>   File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
>     obj, end = self.raw_decode(s, idx=_w(s, 0).end())
>   File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
>     raise JSONDecodeError("Expecting value", s, err.value) from None
> json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
> make: *** No rule to make target
> '/home/peter.maydell/qemu-openbsd/scripts/meson-buildoptions.sh',
> needed by 'config-host.mak'.  Stop.
> make: Leaving directory '/home/peter.maydell/qemu-openbsd/build'

Trying to debug this I tried running 'meson introspect --buildoptions'
by hand on that machine, which falls over like this:

~/qemu-openbsd/build$ ./pyvenv/bin/meson introspect --buildoptions
../meson.build
Trying to enter hw/core which has already been visited --> Skipping
Unable to evaluate subdir([]) in AstInterpreter --> Skipping

../rust/qemu-api-macros/meson.build:1:0: ERROR: Unknown compiler(s): [['rustc']]
The following exception(s) were encountered:
Running `rustc --version` gave "[Errno 2] No such file or directory: 'rustc'"

-- PMM
Peter Maydell Oct. 14, 2024, 4:04 p.m. UTC | #5
On Mon, 14 Oct 2024 at 12:01, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
> If the defaults for --enable-rust ($rust in configure) and Meson's rust
> option are out of sync, incremental builds will pick Meson's default.
>
> This happens because, on an incremental build, configure does not run
> Meson, Make does instead.  Meson then gets the command line options
> from either coredata.dat (which has everything cached in Python's pickle
> format) or cmd_line.txt (slow path when Meson version is upgraded), but
> neither knows about the rust option, and the meson_options.txt default
> is used.
>
> This will cause have_rust to be true if rustc is available; and the build
> to fail because configure did not put a RUST_TARGET_TRIPLE in config-host.mak.
>
> When in the Rust pull request I changed the $rust default from auto
> to disabled, I should have made the same change to meson_options.txt;
> do it now.
>
> Cc: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Reported-by: Daniel P. Berrangé <berrange@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Applied directly to git, thanks.

-- PMM
diff mbox series

Patch

diff --git a/configure b/configure
index 3e38a91616a..8a9a4153310 100755
--- a/configure
+++ b/configure
@@ -1987,7 +1987,7 @@  if test "$skip_meson" = no; then
   fi
 
   # QEMU options
-  test "$rust" != "auto" && meson_option_add "-Drust=$rust"
+  test "$rust" != "disabled" && meson_option_add "-Drust=$rust"
   test "$cfi" != false && meson_option_add "-Dcfi=$cfi" "-Db_lto=$cfi"
   test "$docs" != auto && meson_option_add "-Ddocs=$docs"
   test -n "${LIB_FUZZING_ENGINE+xxx}" && meson_option_add "-Dfuzzing_engine=$LIB_FUZZING_ENGINE"
diff --git a/meson_options.txt b/meson_options.txt
index 2211f291b2d..fc6d5526d58 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -372,5 +372,5 @@  option('hexagon_idef_parser', type : 'boolean', value : true,
 option('x86_version', type : 'combo', choices : ['0', '1', '2', '3', '4'], value: '1',
        description: 'tweak required x86_64 architecture version beyond compiler default')
 
-option('rust', type: 'feature', value: 'auto',
+option('rust', type: 'feature', value: 'disabled',
        description: 'Rust support')