build: Replace meson introspection argument with a builddir
PATCH 1/1 build: Replace meson introspection argument with a builddir
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.
---
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(-)
Makefile +1 -1
@@ -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 > [email protected] && mv [email protected] $@ endif
---
base-commit: d922088eb4ba6bc31a99f17b32cf75e59dd306cd
change-id: 20250204-jag-fix_meson-43db4d290315
Best regards,
Signature · 1 line
Joel Granados <[email protected]>
Quoted 20 lines · Joel Granados
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 <[email protected]>---
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(-)Makefile +0
-0
Makefile Makefile.mtest: build.ninja scripts/mtest2make.py · line 134
Quoted 7 lines
Makefile +1
-1@@ -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 > [email protected] && mv [email protected] $@ endif
I'll queue this patch for my next pull request, unless Paolo rather wants to take it.
Quoted 9 lines · Joel Granados
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 <[email protected]>---
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
Quoted 24 lines
Comments are greatly appreciated
--- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Makefile +1
-2@@ -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 > [email protected] && mv [email protected] $@ endif ---base-commit:
d922088eb4ba6bc31a99f17b32cf75e59dd306cd
change-id: 20250204-jag-fix_meson-43db4d290315Best regards,
Quoted 15 lines · Paolo Bonzini
Quoted 9 lines · Joel Granados
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 <[email protected]>---
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:
Quoted 7 lines
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.
Quoted 6 lines
The idea here is to make it possible to update the
meson-buildoptions.shscript 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
Signature · 1 line
Joel Granados
Quoted 8 lines · Joel Granados
Here is the error I see:
cmd:meson introspect --buildoptions /home/joel/src/qemu/meson.buildoutput:
meson.build:88:12: ERROR: Unknown compiler(s): [['rustc']]
The following exception(s) were encountered:
Runningrustc --versiongave "[Errno 2] No such file or directory: 'rustc'"
Thanks, this helps.
Quoted 4 lines
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
Quoted 19 lines
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_rusthas 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-docsNotice that in meson.build:88 the value of
has_rustdepends onhave_systemwhich in turn depends ontarget_dirs. Doestarget_dirshave values outside a builddir?
Quoted 27 lines · Paolo Bonzini
Quoted 8 lines · Joel Granados
Here is the error I see:
cmd:meson introspect --buildoptions /home/joel/src/qemu/meson.buildoutput:
meson.build:88:12: ERROR: Unknown compiler(s): [['rustc']]
The following exception(s) were encountered:
Runningrustc --versiongave "[Errno 2] No such file or directory: 'rustc'"Thanks, this helps.
Quoted 4 lines
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/bdirYes, 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.
Quoted 4 lines
None of the language-dependent options (for example
c_std) are surfaced inmeson-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
Quoted 28 lines · Peter Maydell
Quoted 27 lines · Paolo Bonzini
Quoted 8 lines · Joel Granados
Here is the error I see:
cmd:meson introspect --buildoptions /home/joel/src/qemu/meson.buildoutput:
meson.build:88:12: ERROR: Unknown compiler(s): [['rustc']]
The following exception(s) were encountered:
Runningrustc --versiongave "[Errno 2] No such file or directory: 'rustc'"Thanks, this helps.
Quoted 4 lines
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/bdirYes, 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.
Quoted 7 lines
Quoted 4 lines
None of the language-dependent options (for example
c_std) are surfaced inmeson-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
Signature · 1 line
Joel Granados