Message ID | 20250204-jag-fix_meson-v1-1-ecb6bdb1db51@kernel.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | build: Replace meson introspection argument with a builddir | expand |
On 04/02/2025 21.10, Joel Granados wrote: > Replace the meson introspect argument with the build directory instead > of the meson.build file. The introspect command accepts an optional > build directory not a file. > > Signed-off-by: Joel Granados <joel.granados@kernel.org> > --- > For some reason this causes an error when I "remote" compile qemu. > In any case, the introspect only accepts directories, so having it point > the to the meson.build file is a mistake. > > Comments are greatly appreciated > --- > Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index b65b0bd41a..da88d9bb31 100644 > --- a/Makefile > +++ b/Makefile > @@ -129,7 +129,7 @@ Makefile.mtest: build.ninja scripts/mtest2make.py > .PHONY: update-buildoptions > all update-buildoptions: $(SRC_PATH)/scripts/meson-buildoptions.sh > $(SRC_PATH)/scripts/meson-buildoptions.sh: $(SRC_PATH)/meson_options.txt > - $(MESON) introspect --buildoptions $(SRC_PATH)/meson.build | $(PYTHON) \ > + $(MESON) introspect --buildoptions $(BUILD_DIR) | $(PYTHON) \ > scripts/meson-buildoptions.py > $@.tmp && mv $@.tmp $@ > endif Reviewed-by: Thomas Huth <thuth@redhat.com> I'll queue this patch for my next pull request, unless Paolo rather wants to take it.
On 2/4/25 21:10, Joel Granados wrote: > Replace the meson introspect argument with the build directory instead > of the meson.build file. The introspect command accepts an optional > build directory not a file. > > Signed-off-by: Joel Granados <joel.granados@kernel.org> > --- > For some reason this causes an error when I "remote" compile qemu. > In any case, the introspect only accepts directories, so having it point > the to the meson.build file is a mistake. Unfortunately, the help for "meson introspect" doesn't tell the whole story... Instead, https://mesonbuild.com/IDE-integration.html under "Build options" says: Since Meson 0.50.0 it is also possible to get the default buildoptions without a build directory by providing the root meson.build instead of a build directory to meson introspect --buildoptions. Running --buildoptions without a build directory produces the same output as running it with a freshly configured build directory. The idea here is to make it possible to update the meson-buildoptions.sh script even in case the build directory if somehow hosed. So I'd rather avoid this patch if possible. What's the error that you have and do you have a reproducer? Paolo > Comments are greatly appreciated > --- > Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index b65b0bd41a..da88d9bb31 100644 > --- a/Makefile > +++ b/Makefile > @@ -129,7 +129,7 @@ Makefile.mtest: build.ninja scripts/mtest2make.py > .PHONY: update-buildoptions > all update-buildoptions: $(SRC_PATH)/scripts/meson-buildoptions.sh > $(SRC_PATH)/scripts/meson-buildoptions.sh: $(SRC_PATH)/meson_options.txt > - $(MESON) introspect --buildoptions $(SRC_PATH)/meson.build | $(PYTHON) \ > + $(MESON) introspect --buildoptions $(BUILD_DIR) | $(PYTHON) \ > scripts/meson-buildoptions.py > $@.tmp && mv $@.tmp $@ > endif > > > --- > base-commit: d922088eb4ba6bc31a99f17b32cf75e59dd306cd > change-id: 20250204-jag-fix_meson-43db4d290315 > > Best regards,
On Mon, Feb 24, 2025 at 11:57:24AM +0100, Paolo Bonzini wrote: > On 2/4/25 21:10, Joel Granados wrote: > > Replace the meson introspect argument with the build directory instead > > of the meson.build file. The introspect command accepts an optional > > build directory not a file. > > > > Signed-off-by: Joel Granados <joel.granados@kernel.org> > > --- > > For some reason this causes an error when I "remote" compile qemu. > > In any case, the introspect only accepts directories, so having it point > > the to the meson.build file is a mistake. > > Unfortunately, the help for "meson introspect" doesn't tell the whole > story... Instead, https://mesonbuild.com/IDE-integration.html under "Build > options" says: > > Since Meson 0.50.0 it is also possible to get the default > buildoptions without a build directory by providing the root > meson.build instead of a build directory to meson introspect > --buildoptions. > > Running --buildoptions without a build directory produces the same > output as running it with a freshly configured build directory. Thx for the clarification. Never would have thought to looking to the IDE-integration. If it *is* supposed to work with the file instead of the BUILDDIR, maybe the error is somewhere else. > > The idea here is to make it possible to update the meson-buildoptions.sh > script even in case the build directory if somehow hosed. So I'd rather > avoid this patch if possible. > > What's the error that you have and do you have a reproducer? Here is the error I see: cmd: meson introspect --buildoptions /home/joel/src/qemu/meson.build output: meson.build:88:12: ERROR: Unknown compiler(s): [['rustc']] The following exception(s) were encountered: Running `rustc --version` gave "[Errno 2] No such file or directory: 'rustc'" When I pass it a builddir it actually gives me all the buildoptions (which is what I expect) cmd: meson introspect --buildoptions /home/joel/src/qemu/bdir output (Just pasted a few values as it is too long): [{"name": "build.cmake_prefix_path", "value": [], "section": "core", "machine": "build", "type": "array", "description": "List of additional prefixes for cmake to search"}, {"name": "build.pkg_config_path", "value": ["/nix/store/xslbksjj97g6nagcx4n5maj9fpvnyhvs-glib-2.82.1-dev/lib/pkgconfig", "/nix/store/06q0p7bhn2ffxxya20rrfqdib3h32csn-zlib-1.3.1-dev/lib/pkgconfig", "/nix/store/30gl46y1afg6crvcw9v3ipb6hmkmd7hj-libffi-3.4.6-dev/lib/pkgconfig", "/nix/store/08dqyhwwvn0yvc0zziw9q8vc4njb7jal-lz4-1.10.0-dev/lib/pkgconfig", "/nix/store/zcg3yygpamw1hk28yd46zswvyjf26vnz-libslirp-4.8.0/lib/pkgconfig", "/nix/store/3alx4nrhy7ss32i6fmfgj0hp96pfjvx6-python3-3.11.11/lib/pkgconfig", "/nix/store/l8g4dx38bkhfphgwyhi513nhw2x47c6r-python3-3.11.11/lib/pkgconfig"], "section": "core", "machine": "build", "type": "array", "description": "List of additional paths for pkg-config to search"}, {"name": "auto_features", "value": "auto", "section": "core", "machine": "any", "choices": ["enabled", "disabled", "auto"], "type": "combo", "description": "Override value of all 'auto' features"}, {"name": "backend", "value": "ninja", "section": "core", "machine": "any", "choices": ["ninja", "vs", "vs2010", "vs2012", "vs2013", "vs2015", ... Quickly looking at the error message and at line 88 shows me that it has to do with the build trying to call the rust compiler (which I do **not** have installed). It seems that have_rust has the true value even though I do not have it installed. However all this goes away when I pass it a builddir. Maybe the fix is to change the detection logic for the rust compiler? FYI: 1. These are the lines that have rust in the meson_options.txt: option('rust', type: 'feature', value: 'disabled', description: 'Rust support') option('strict_rust_lints', type: 'boolean', value: false, description: 'Enable stricter set of Rust warnings') 2. This is how I run configure: ../configure --target-list=x86_64-softmmu --disable-docs Notice that in meson.build:88 the value of has_rust depends on have_system which in turn depends on target_dirs. Does target_dirs have values outside a builddir? Hopes this helps clarify my situation Best
On 2/27/25 11:07, Joel Granados wrote: > Here is the error I see: > cmd: > meson introspect --buildoptions /home/joel/src/qemu/meson.build > > output: > meson.build:88:12: ERROR: Unknown compiler(s): [['rustc']] > The following exception(s) were encountered: > Running `rustc --version` gave "[Errno 2] No such file or directory: 'rustc'" Thanks, this helps. > When I pass it a builddir it actually gives me all the buildoptions > (which is what I expect) > cmd: > meson introspect --buildoptions /home/joel/src/qemu/bdir Yes, the difference is that the builddir version uses the results of actually executing meson.build, whereas the srcdir version only does some cursory parsing and always looks at both branches of "if" statements. This is actually not a bug, and in fact now I remember why it is using the srcdir version... Looking at the required languages is needed in order to figure out language-dependent build options, and the srcdir version includes the options for all languages that QEMU could use. None of the language-dependent options (for example c_std) are surfaced in meson-buildoptions.sh, which is why your patch works in the first place. But I think it's a better fix for you to install rustc, since it will anyway become mandatory sooner or later. Paolo > Quickly looking at the error message and at line 88 shows me that it has > to do with the build trying to call the rust compiler (which I do > **not** have installed). It seems that have_rust has the true value even > though I do not have it installed. However all this goes away when I > pass it a builddir. > > Maybe the fix is to change the detection logic for the rust compiler? > FYI: > 1. These are the lines that have rust in the meson_options.txt: > option('rust', type: 'feature', value: 'disabled', > description: 'Rust support') > option('strict_rust_lints', type: 'boolean', value: false, > description: 'Enable stricter set of Rust warnings') > 2. This is how I run configure: > ../configure --target-list=x86_64-softmmu --disable-docs > > Notice that in meson.build:88 the value of has_rust depends on > have_system which in turn depends on target_dirs. Does target_dirs have > values outside a builddir?
On Thu, 27 Feb 2025 at 10:20, Paolo Bonzini <pbonzini@redhat.com> wrote: > > On 2/27/25 11:07, Joel Granados wrote: > > Here is the error I see: > > cmd: > > meson introspect --buildoptions /home/joel/src/qemu/meson.build > > > > output: > > meson.build:88:12: ERROR: Unknown compiler(s): [['rustc']] > > The following exception(s) were encountered: > > Running `rustc --version` gave "[Errno 2] No such file or directory: 'rustc'" > > Thanks, this helps. > > > When I pass it a builddir it actually gives me all the buildoptions > > (which is what I expect) > > cmd: > > meson introspect --buildoptions /home/joel/src/qemu/bdir > > Yes, the difference is that the builddir version uses the results of > actually executing meson.build, whereas the srcdir version only does > some cursory parsing and always looks at both branches of "if" statements. > > This is actually not a bug, and in fact now I remember why it is using > the srcdir version... Looking at the required languages is needed in > order to figure out language-dependent build options, and the srcdir > version includes the options for all languages that QEMU could use. > > None of the language-dependent options (for example c_std) are surfaced > in meson-buildoptions.sh, which is why your patch works in the first > place. But I think it's a better fix for you to install rustc, since it > will anyway become mandatory sooner or later. It's not mandatory *now*, though. So I think it would be better to fix whatever this problem is rather than papering over it... -- PMM
On Thu, Feb 27, 2025 at 10:38:11AM +0000, Peter Maydell wrote: > On Thu, 27 Feb 2025 at 10:20, Paolo Bonzini <pbonzini@redhat.com> wrote: > > > > On 2/27/25 11:07, Joel Granados wrote: > > > Here is the error I see: > > > cmd: > > > meson introspect --buildoptions /home/joel/src/qemu/meson.build > > > > > > output: > > > meson.build:88:12: ERROR: Unknown compiler(s): [['rustc']] > > > The following exception(s) were encountered: > > > Running `rustc --version` gave "[Errno 2] No such file or directory: 'rustc'" > > > > Thanks, this helps. > > > > > When I pass it a builddir it actually gives me all the buildoptions > > > (which is what I expect) > > > cmd: > > > meson introspect --buildoptions /home/joel/src/qemu/bdir > > > > Yes, the difference is that the builddir version uses the results of > > actually executing meson.build, whereas the srcdir version only does > > some cursory parsing and always looks at both branches of "if" statements. > > > > This is actually not a bug, and in fact now I remember why it is using > > the srcdir version... Looking at the required languages is needed in > > order to figure out language-dependent build options, and the srcdir > > version includes the options for all languages that QEMU could use. > > > > None of the language-dependent options (for example c_std) are surfaced > > in meson-buildoptions.sh, which is why your patch works in the first > > place. But I think it's a better fix for you to install rustc, since it > > will anyway become mandatory sooner or later. > > It's not mandatory *now*, though. So I think it would be better > to fix whatever this problem is rather than papering over it... Would my fix work even though there is no BUILD_DIR? If I understand Paolo's point (and please correct me if I don't) this is supposed to run with and without a builddir. My point being that I would also get an error if the update-buildoptions target is called with BUILD_DIR = CURDIR (default value). cmd: meson introspect --buildoptions /home/joel/src/qemu output: Current directory is not a meson build directory. Please specify a valid build dir or change the working directory to it. It is a pity that not finding rustc results in an error and exit instead of just trimming that if branch but continuing to see what options are available Best
diff --git a/Makefile b/Makefile index b65b0bd41a..da88d9bb31 100644 --- a/Makefile +++ b/Makefile @@ -129,7 +129,7 @@ Makefile.mtest: build.ninja scripts/mtest2make.py .PHONY: update-buildoptions all update-buildoptions: $(SRC_PATH)/scripts/meson-buildoptions.sh $(SRC_PATH)/scripts/meson-buildoptions.sh: $(SRC_PATH)/meson_options.txt - $(MESON) introspect --buildoptions $(SRC_PATH)/meson.build | $(PYTHON) \ + $(MESON) introspect --buildoptions $(BUILD_DIR) | $(PYTHON) \ scripts/meson-buildoptions.py > $@.tmp && mv $@.tmp $@ endif
Replace the meson introspect argument with the build directory instead of the meson.build file. The introspect command accepts an optional build directory not a file. Signed-off-by: Joel Granados <joel.granados@kernel.org> --- For some reason this causes an error when I "remote" compile qemu. In any case, the introspect only accepts directories, so having it point the to the meson.build file is a mistake. Comments are greatly appreciated --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- base-commit: d922088eb4ba6bc31a99f17b32cf75e59dd306cd change-id: 20250204-jag-fix_meson-43db4d290315 Best regards,