* [PATCH 0/6] rust: update build system for Meson 1.8.1
@ 2025-05-27 17:03 Paolo Bonzini
2025-05-27 17:03 ` [PATCH 1/6] meson: update to version 1.8.1 Paolo Bonzini
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Paolo Bonzini @ 2025-05-27 17:03 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-rust
Meson 1.7.0 and 1.8.0 include improved support for Rust, namely:
* support for "objects" in Rust executables
* support for doctest targets
* invoking clippy and rustdoc
Use it to remove BQL-related hacks, fix --enable-modules --enable-rust
and also simplify the Meson logic for building the qemu-api crate
(which may help splitting the crate, too).
Note that this does *not* yet require 1.8.1 for all of QEMU; the
requirement is only there if Rust is enabled.
Paolo
Supersedes: <20250405100603.253421-1-pbonzini@redhat.com>
Paolo Bonzini (6):
meson: update to version 1.8.1
rust: use "objects" for Rust executables as well
build, dockerfiles: add support for detecting rustdoc
rust: add qemu-api doctests to "meson test"
rust: cell: remove support for running doctests with "cargo test
--doc"
rust: use native Meson support for clippy and rustdoc
docs/devel/rust.rst | 12 ++++---
configure | 16 +++++++++
meson.build | 4 ++-
.gitlab-ci.d/buildtest-template.yml | 3 +-
.gitlab-ci.d/buildtest.yml | 11 ++-----
rust/clippy.toml => clippy.toml | 0
python/scripts/vendor.py | 4 +--
python/wheels/meson-1.5.0-py3-none-any.whl | Bin 959846 -> 0 bytes
python/wheels/meson-1.8.1-py3-none-any.whl | Bin 0 -> 1013001 bytes
pythondeps.toml | 2 +-
rust/Cargo.toml | 1 -
rust/meson.build | 14 ++------
rust/qemu-api/meson.build | 31 +++++++-----------
rust/qemu-api/src/cell.rs | 22 +++++--------
scripts/rust/rustc_args.py | 5 +--
.../dockerfiles/fedora-rust-nightly.docker | 2 ++
tests/docker/dockerfiles/ubuntu2204.docker | 1 +
tests/lcitool/mappings.yml | 6 +++-
tests/lcitool/refresh | 3 ++
19 files changed, 69 insertions(+), 68 deletions(-)
rename rust/clippy.toml => clippy.toml (100%)
delete mode 100644 python/wheels/meson-1.5.0-py3-none-any.whl
create mode 100644 python/wheels/meson-1.8.1-py3-none-any.whl
--
2.49.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/6] meson: update to version 1.8.1
2025-05-27 17:03 [PATCH 0/6] rust: update build system for Meson 1.8.1 Paolo Bonzini
@ 2025-05-27 17:03 ` Paolo Bonzini
2025-05-27 17:04 ` [PATCH 2/6] rust: use "objects" for Rust executables as well Paolo Bonzini
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2025-05-27 17:03 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-rust
This adds several improvements to Rust support, including
native clippy and rustdoc targets, the "objects" keyword,
and running doctests.
Require it only when Rust support is requested, to avoid
putting a strict requirement on all build platforms for the
sake of an experimental feature.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 8 ++++++++
python/scripts/vendor.py | 4 ++--
python/wheels/meson-1.5.0-py3-none-any.whl | Bin 959846 -> 0 bytes
python/wheels/meson-1.8.1-py3-none-any.whl | Bin 0 -> 1013001 bytes
pythondeps.toml | 2 +-
tests/lcitool/mappings.yml | 6 +++++-
6 files changed, 16 insertions(+), 4 deletions(-)
delete mode 100644 python/wheels/meson-1.5.0-py3-none-any.whl
create mode 100644 python/wheels/meson-1.8.1-py3-none-any.whl
diff --git a/configure b/configure
index 2ce8d29fac2..74b3865e51e 100755
--- a/configure
+++ b/configure
@@ -1178,6 +1178,14 @@ fi
##########################################
# detect rust triple
+meson_version=$($meson --version)
+if test "$rust" != disabled && ! version_ge "$meson_version" 1.8.1; then
+ if test "$rust" = enabled; then
+ error_exit "Rust support needs Meson 1.8.1 or newer"
+ fi
+ echo "Rust needs Meson 1.8.1, disabling" 2>&1
+ rust=disabled
+fi
if test "$rust" != disabled && has "$rustc" && $rustc -vV > "${TMPDIR1}/${TMPB}.out"; then
rust_host_triple=$(sed -n 's/^host: //p' "${TMPDIR1}/${TMPB}.out")
else
diff --git a/python/scripts/vendor.py b/python/scripts/vendor.py
index 0405e910b48..b47db00743a 100755
--- a/python/scripts/vendor.py
+++ b/python/scripts/vendor.py
@@ -41,8 +41,8 @@ def main() -> int:
parser.parse_args()
packages = {
- "meson==1.5.0":
- "52b34f4903b882df52ad0d533146d4b992c018ea77399f825579737672ae7b20",
+ "meson==1.8.1":
+ "374bbf71247e629475fc10b0bd2ef66fc418c2d8f4890572f74de0f97d0d42da",
}
vendor_dir = Path(__file__, "..", "..", "wheels").resolve()
diff --git a/pythondeps.toml b/pythondeps.toml
index 7eaaa0fed10..7884ab521d1 100644
--- a/pythondeps.toml
+++ b/pythondeps.toml
@@ -19,7 +19,7 @@
[meson]
# The install key should match the version in python/wheels/
-meson = { accepted = ">=1.5.0", installed = "1.5.0", canary = "meson" }
+meson = { accepted = ">=1.5.0", installed = "1.8.1", canary = "meson" }
pycotap = { accepted = ">=1.1.0", installed = "1.3.1" }
[docs]
diff --git a/tests/lcitool/mappings.yml b/tests/lcitool/mappings.yml
index 673baf39367..8f0e95e1c56 100644
--- a/tests/lcitool/mappings.yml
+++ b/tests/lcitool/mappings.yml
@@ -8,6 +8,10 @@ mappings:
meson:
OpenSUSELeap15:
+ # Use Meson from PyPI wherever Rust is enabled
+ Debian:
+ Fedora:
+ Ubuntu:
python3:
OpenSUSELeap15: python311-base
@@ -72,7 +76,7 @@ mappings:
pypi_mappings:
# Request more recent version
meson:
- default: meson==1.5.0
+ default: meson==1.8.1
# Drop packages that need devel headers
python3-numpy:
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/6] rust: use "objects" for Rust executables as well
2025-05-27 17:03 [PATCH 0/6] rust: update build system for Meson 1.8.1 Paolo Bonzini
2025-05-27 17:03 ` [PATCH 1/6] meson: update to version 1.8.1 Paolo Bonzini
@ 2025-05-27 17:04 ` Paolo Bonzini
2025-05-27 17:04 ` [PATCH 3/6] build, dockerfiles: add support for detecting rustdoc Paolo Bonzini
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2025-05-27 17:04 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-rust, Bernhard Beschow
libqemuutil is not meant be linked as a whole; if modules are enabled, doing
so results in undefined symbols (corresponding to QMP commands) in
rust/qemu-api/rust-qemu-api-integration.
Support for "objects" in Rust executables is available in Meson 1.8.0; use it
to switching to the same dependencies that C targets use: link_with for
libqemuutil, and objects for everything else.
Reported-by: Bernhard Beschow <shentey@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
docs/devel/rust.rst | 2 --
rust/meson.build | 2 ++
rust/qemu-api/meson.build | 24 +++---------------------
3 files changed, 5 insertions(+), 23 deletions(-)
diff --git a/docs/devel/rust.rst b/docs/devel/rust.rst
index 171d908e0b0..11328c05b45 100644
--- a/docs/devel/rust.rst
+++ b/docs/devel/rust.rst
@@ -66,8 +66,6 @@ be run via ``meson test`` or ``make``::
make check-rust
-Building Rust code with ``--enable-modules`` is not supported yet.
-
Supported tools
'''''''''''''''
diff --git a/rust/meson.build b/rust/meson.build
index 1f0dcce7d04..801f4374dfa 100644
--- a/rust/meson.build
+++ b/rust/meson.build
@@ -14,6 +14,8 @@ quote_rs_native = dependency('quote-1-rs', native: true)
syn_rs_native = dependency('syn-2-rs', native: true)
proc_macro2_rs_native = dependency('proc-macro2-1-rs', native: true)
+qemuutil_rs = qemuutil.partial_dependency(link_args: true, links: true)
+
subdir('qemu-api-macros')
subdir('qemu-api')
diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build
index 1ea86b8bbf1..c647493f712 100644
--- a/rust/qemu-api/meson.build
+++ b/rust/qemu-api/meson.build
@@ -41,26 +41,8 @@ _qemu_api_rs = static_library(
rust.test('rust-qemu-api-tests', _qemu_api_rs,
suite: ['unit', 'rust'])
-qemu_api = declare_dependency(link_with: _qemu_api_rs)
-
-# Rust executables do not support objects, so add an intermediate step.
-rust_qemu_api_objs = static_library(
- 'rust_qemu_api_objs',
- objects: [libqom.extract_all_objects(recursive: false),
- libhwcore.extract_all_objects(recursive: false),
- libchardev.extract_all_objects(recursive: false),
- libcrypto.extract_all_objects(recursive: false),
- libauthz.extract_all_objects(recursive: false),
- libio.extract_all_objects(recursive: false),
- libmigration.extract_all_objects(recursive: false)])
-rust_qemu_api_deps = declare_dependency(
- dependencies: [
- qom_ss.dependencies(),
- chardev_ss.dependencies(),
- crypto_ss.dependencies(),
- authz_ss.dependencies(),
- io_ss.dependencies()],
- link_whole: [rust_qemu_api_objs, libqemuutil])
+qemu_api = declare_dependency(link_with: [_qemu_api_rs],
+ dependencies: [qemuutil_rs, qemu_api_macros, qom, hwcore, chardev, migration])
test('rust-qemu-api-integration',
executable(
@@ -69,7 +51,7 @@ test('rust-qemu-api-integration',
override_options: ['rust_std=2021', 'build.rust_std=2021'],
rust_args: ['--test'],
install: false,
- dependencies: [qemu_api, qemu_api_macros, rust_qemu_api_deps]),
+ dependencies: qemu_api),
args: [
'--test', '--test-threads', '1',
'--format', 'pretty',
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/6] build, dockerfiles: add support for detecting rustdoc
2025-05-27 17:03 [PATCH 0/6] rust: update build system for Meson 1.8.1 Paolo Bonzini
2025-05-27 17:03 ` [PATCH 1/6] meson: update to version 1.8.1 Paolo Bonzini
2025-05-27 17:04 ` [PATCH 2/6] rust: use "objects" for Rust executables as well Paolo Bonzini
@ 2025-05-27 17:04 ` Paolo Bonzini
2025-05-27 17:04 ` [PATCH 4/6] rust: add qemu-api doctests to "meson test" Paolo Bonzini
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2025-05-27 17:04 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-rust
rustdoc is effectively a custom version of rustc, and it is necessary to
specify it in order to run doctests from Meson. Add the relevant configure
option and environment variables.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
configure | 8 ++++++++
meson.build | 2 ++
tests/docker/dockerfiles/fedora-rust-nightly.docker | 2 ++
tests/docker/dockerfiles/ubuntu2204.docker | 1 +
tests/lcitool/refresh | 3 +++
5 files changed, 16 insertions(+)
diff --git a/configure b/configure
index 74b3865e51e..2b2b3d65979 100755
--- a/configure
+++ b/configure
@@ -209,6 +209,8 @@ for opt do
;;
--rustc=*) RUSTC="$optarg"
;;
+ --rustdoc=*) RUSTDOC="$optarg"
+ ;;
--cpu=*) cpu="$optarg"
;;
--extra-cflags=*)
@@ -323,6 +325,7 @@ pkg_config="${PKG_CONFIG-${cross_prefix}pkg-config}"
sdl2_config="${SDL2_CONFIG-${cross_prefix}sdl2-config}"
rustc="${RUSTC-rustc}"
+rustdoc="${RUSTDOC-rustdoc}"
check_define() {
cat > $TMPC <<EOF
@@ -660,6 +663,8 @@ for opt do
;;
--rustc=*)
;;
+ --rustdoc=*)
+ ;;
--make=*)
;;
--install=*)
@@ -890,6 +895,7 @@ Advanced options (experts only):
--cxx=CXX use C++ compiler CXX [$cxx]
--objcc=OBJCC use Objective-C compiler OBJCC [$objcc]
--rustc=RUSTC use Rust compiler RUSTC [$rustc]
+ --rustdoc=RUSTDOC use rustdoc binary RUSTDOC [$rustdoc]
--extra-cflags=CFLAGS append extra C compiler flags CFLAGS
--extra-cxxflags=CXXFLAGS append extra C++ compiler flags CXXFLAGS
--extra-objcflags=OBJCFLAGS append extra Objective C compiler flags OBJCFLAGS
@@ -1901,8 +1907,10 @@ if test "$skip_meson" = no; then
if test "$rust" != disabled; then
if test "$rust_host_triple" != "$rust_target_triple"; then
echo "rust = [$(meson_quote $rustc --target "$rust_target_triple")]" >> $cross
+ echo "rustdoc = [$(meson_quote $rustdoc --target "$rust_target_triple")]" >> $cross
else
echo "rust = [$(meson_quote $rustc)]" >> $cross
+ echo "rustdoc = [$(meson_quote $rustdoc)]" >> $cross
fi
fi
echo "ar = [$(meson_quote $ar)]" >> $cross
diff --git a/meson.build b/meson.build
index 5a2098a2e94..eebd74b1fce 100644
--- a/meson.build
+++ b/meson.build
@@ -106,6 +106,7 @@ if have_rust
endif
if have_rust
+ rustdoc = find_program('rustdoc', required: get_option('rust'))
bindgen = find_program('bindgen', required: get_option('rust'))
if not bindgen.found() or bindgen.version().version_compare('<0.60.0')
if get_option('rust').enabled()
@@ -4729,6 +4730,7 @@ if have_rust
summary_info += {'Rust target': config_host['RUST_TARGET_TRIPLE']}
summary_info += {'rustc': ' '.join(rustc.cmd_array())}
summary_info += {'rustc version': rustc.version()}
+ summary_info += {'rustdoc': rustdoc}
summary_info += {'bindgen': bindgen.full_path()}
summary_info += {'bindgen version': bindgen.version()}
endif
diff --git a/tests/docker/dockerfiles/fedora-rust-nightly.docker b/tests/docker/dockerfiles/fedora-rust-nightly.docker
index fe4a6ed48d6..4a033309b38 100644
--- a/tests/docker/dockerfiles/fedora-rust-nightly.docker
+++ b/tests/docker/dockerfiles/fedora-rust-nightly.docker
@@ -156,6 +156,7 @@ ENV PYTHON "/usr/bin/python3"
RUN dnf install -y wget
ENV RUSTUP_HOME=/usr/local/rustup CARGO_HOME=/usr/local/cargo
ENV RUSTC=/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc
+ENV RUSTDOC=/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustdoc
ENV CARGO=/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo
RUN set -eux && \
rustArch='x86_64-unknown-linux-gnu' && \
@@ -170,6 +171,7 @@ RUN set -eux && \
/usr/local/cargo/bin/rustup run nightly cargo --version && \
/usr/local/cargo/bin/rustup run nightly rustc --version && \
test "$CARGO" = "$(/usr/local/cargo/bin/rustup +nightly which cargo)" && \
+ test "$RUSTDOC" = "$(/usr/local/cargo/bin/rustup +nightly which rustdoc)" && \
test "$RUSTC" = "$(/usr/local/cargo/bin/rustup +nightly which rustc)"
ENV PATH=$CARGO_HOME/bin:$PATH
RUN /usr/local/cargo/bin/rustup run nightly cargo install bindgen-cli
diff --git a/tests/docker/dockerfiles/ubuntu2204.docker b/tests/docker/dockerfiles/ubuntu2204.docker
index 4a1cf2bdff3..28a6f932430 100644
--- a/tests/docker/dockerfiles/ubuntu2204.docker
+++ b/tests/docker/dockerfiles/ubuntu2204.docker
@@ -151,6 +151,7 @@ ENV MAKE "/usr/bin/make"
ENV NINJA "/usr/bin/ninja"
ENV PYTHON "/usr/bin/python3"
ENV RUSTC=/usr/bin/rustc-1.77
+ENV RUSTDOC=/usr/bin/rustdoc-1.77
ENV CARGO_HOME=/usr/local/cargo
ENV PATH=$CARGO_HOME/bin:$PATH
RUN DEBIAN_FRONTEND=noninteractive eatmydata \
diff --git a/tests/lcitool/refresh b/tests/lcitool/refresh
index 8474ea822f4..d3488b2679e 100755
--- a/tests/lcitool/refresh
+++ b/tests/lcitool/refresh
@@ -121,6 +121,7 @@ fedora_rustup_nightly_extras = [
"RUN dnf install -y wget\n",
"ENV RUSTUP_HOME=/usr/local/rustup CARGO_HOME=/usr/local/cargo\n",
"ENV RUSTC=/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc\n",
+ "ENV RUSTDOC=/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustdoc\n",
"ENV CARGO=/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo\n",
"RUN set -eux && \\\n",
" rustArch='x86_64-unknown-linux-gnu' && \\\n",
@@ -135,6 +136,7 @@ fedora_rustup_nightly_extras = [
" /usr/local/cargo/bin/rustup run nightly cargo --version && \\\n",
" /usr/local/cargo/bin/rustup run nightly rustc --version && \\\n",
' test "$CARGO" = "$(/usr/local/cargo/bin/rustup +nightly which cargo)" && \\\n',
+ ' test "$RUSTDOC" = "$(/usr/local/cargo/bin/rustup +nightly which rustdoc)" && \\\n',
' test "$RUSTC" = "$(/usr/local/cargo/bin/rustup +nightly which rustc)"\n',
'ENV PATH=$CARGO_HOME/bin:$PATH\n',
'RUN /usr/local/cargo/bin/rustup run nightly cargo install bindgen-cli\n',
@@ -143,6 +145,7 @@ fedora_rustup_nightly_extras = [
ubuntu2204_rust_extras = [
"ENV RUSTC=/usr/bin/rustc-1.77\n",
+ "ENV RUSTDOC=/usr/bin/rustdoc-1.77\n",
"ENV CARGO_HOME=/usr/local/cargo\n",
'ENV PATH=$CARGO_HOME/bin:$PATH\n',
"RUN DEBIAN_FRONTEND=noninteractive eatmydata \\\n",
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/6] rust: add qemu-api doctests to "meson test"
2025-05-27 17:03 [PATCH 0/6] rust: update build system for Meson 1.8.1 Paolo Bonzini
` (2 preceding siblings ...)
2025-05-27 17:04 ` [PATCH 3/6] build, dockerfiles: add support for detecting rustdoc Paolo Bonzini
@ 2025-05-27 17:04 ` Paolo Bonzini
2025-05-27 17:04 ` [PATCH 5/6] rust: cell: remove support for running doctests with "cargo test --doc" Paolo Bonzini
2025-05-27 17:04 ` [PATCH 6/6] rust: use native Meson support for clippy and rustdoc Paolo Bonzini
5 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2025-05-27 17:04 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-rust
Doctests are weird. They are essentially integration tests, but they're
"ran" by executing rustdoc --test, which takes a compiler-ish
command line. This is supported by Meson 1.8.0.
Because they run the linker and need all the .o files, run them in the
build jobs rather than the test jobs.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
docs/devel/rust.rst | 2 ++
.gitlab-ci.d/buildtest-template.yml | 3 ++-
.gitlab-ci.d/buildtest.yml | 11 +++--------
rust/qemu-api/meson.build | 9 +++++++++
4 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/docs/devel/rust.rst b/docs/devel/rust.rst
index 11328c05b45..f66f2bef60b 100644
--- a/docs/devel/rust.rst
+++ b/docs/devel/rust.rst
@@ -66,6 +66,8 @@ be run via ``meson test`` or ``make``::
make check-rust
+Note that doctests require all ``.o`` files from the build to be available.
+
Supported tools
'''''''''''''''
diff --git a/.gitlab-ci.d/buildtest-template.yml b/.gitlab-ci.d/buildtest-template.yml
index 118371e377d..fea4e8da2f1 100644
--- a/.gitlab-ci.d/buildtest-template.yml
+++ b/.gitlab-ci.d/buildtest-template.yml
@@ -76,7 +76,8 @@
fi
- section_end buildenv
- section_start test "Running tests"
- - $MAKE NINJA=":" $MAKE_CHECK_ARGS
+ # doctests need all the compilation artifacts
+ - $MAKE NINJA=":" MTESTARGS="--no-suite doc" $MAKE_CHECK_ARGS
- section_end test
.native_test_job_template:
diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml
index 248aaed1370..0fdde54bf8e 100644
--- a/.gitlab-ci.d/buildtest.yml
+++ b/.gitlab-ci.d/buildtest.yml
@@ -41,7 +41,7 @@ build-system-ubuntu:
IMAGE: ubuntu2204
CONFIGURE_ARGS: --enable-docs --enable-rust
TARGETS: alpha-softmmu microblazeel-softmmu mips64el-softmmu
- MAKE_CHECK_ARGS: check-build
+ MAKE_CHECK_ARGS: check-build check-doc
check-system-ubuntu:
extends: .native_test_job_template
@@ -115,7 +115,7 @@ build-system-fedora:
CONFIGURE_ARGS: --disable-gcrypt --enable-nettle --enable-docs --enable-crypto-afalg --enable-rust
TARGETS: microblaze-softmmu mips-softmmu
xtensa-softmmu m68k-softmmu riscv32-softmmu ppc-softmmu sparc64-softmmu
- MAKE_CHECK_ARGS: check-build
+ MAKE_CHECK_ARGS: check-build check-doc
build-system-fedora-rust-nightly:
extends:
@@ -127,12 +127,7 @@ build-system-fedora-rust-nightly:
IMAGE: fedora-rust-nightly
CONFIGURE_ARGS: --disable-docs --enable-rust --enable-strict-rust-lints
TARGETS: aarch64-softmmu
- MAKE_CHECK_ARGS: check-build
- after_script:
- - source scripts/ci/gitlab-ci-section
- - section_start test "Running Rust doctests"
- - cd build
- - pyvenv/bin/meson devenv -w ../rust ${CARGO-cargo} test --doc -p qemu_api
+ MAKE_CHECK_ARGS: check-build check-doc
allow_failure: true
diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build
index c647493f712..10e8210f30f 100644
--- a/rust/qemu-api/meson.build
+++ b/rust/qemu-api/meson.build
@@ -44,6 +44,15 @@ rust.test('rust-qemu-api-tests', _qemu_api_rs,
qemu_api = declare_dependency(link_with: [_qemu_api_rs],
dependencies: [qemuutil_rs, qemu_api_macros, qom, hwcore, chardev, migration])
+# Doctests are essentially integration tests, so they need the same dependencies.
+# Note that running them requires the object files for C code, so place them
+# in a separate suite that is run by the "build" CI jobs rather than "check".
+rust.doctest('rust-qemu-api-doctests',
+ _qemu_api_rs,
+ protocol: 'rust',
+ dependencies: qemu_api,
+ suite: ['doc', 'rust'])
+
test('rust-qemu-api-integration',
executable(
'rust-qemu-api-integration',
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/6] rust: cell: remove support for running doctests with "cargo test --doc"
2025-05-27 17:03 [PATCH 0/6] rust: update build system for Meson 1.8.1 Paolo Bonzini
` (3 preceding siblings ...)
2025-05-27 17:04 ` [PATCH 4/6] rust: add qemu-api doctests to "meson test" Paolo Bonzini
@ 2025-05-27 17:04 ` Paolo Bonzini
2025-05-27 17:04 ` [PATCH 6/6] rust: use native Meson support for clippy and rustdoc Paolo Bonzini
5 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2025-05-27 17:04 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-rust
This is not needed anymore now that tests link with libqemuutil.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
rust/qemu-api/src/cell.rs | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
diff --git a/rust/qemu-api/src/cell.rs b/rust/qemu-api/src/cell.rs
index 05ce09f6cb6..27063b049d5 100644
--- a/rust/qemu-api/src/cell.rs
+++ b/rust/qemu-api/src/cell.rs
@@ -225,27 +225,23 @@
/// An internal function that is used by doctests.
pub fn bql_start_test() {
- if cfg!(MESON) {
- // SAFETY: integration tests are run with --test-threads=1, while
- // unit tests and doctests are not multithreaded and do not have
- // any BQL-protected data. Just set bql_locked to true.
- unsafe {
- bindings::rust_bql_mock_lock();
- }
+ // SAFETY: integration tests are run with --test-threads=1, while
+ // unit tests and doctests are not multithreaded and do not have
+ // any BQL-protected data. Just set bql_locked to true.
+ unsafe {
+ bindings::rust_bql_mock_lock();
}
}
pub fn bql_locked() -> bool {
// SAFETY: the function does nothing but return a thread-local bool
- !cfg!(MESON) || unsafe { bindings::bql_locked() }
+ unsafe { bindings::bql_locked() }
}
fn bql_block_unlock(increase: bool) {
- if cfg!(MESON) {
- // SAFETY: this only adjusts a counter
- unsafe {
- bindings::bql_block_unlock(increase);
- }
+ // SAFETY: this only adjusts a counter
+ unsafe {
+ bindings::bql_block_unlock(increase);
}
}
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/6] rust: use native Meson support for clippy and rustdoc
2025-05-27 17:03 [PATCH 0/6] rust: update build system for Meson 1.8.1 Paolo Bonzini
` (4 preceding siblings ...)
2025-05-27 17:04 ` [PATCH 5/6] rust: cell: remove support for running doctests with "cargo test --doc" Paolo Bonzini
@ 2025-05-27 17:04 ` Paolo Bonzini
5 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2025-05-27 17:04 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-rust
Meson has support for invoking clippy and rustdoc on all crates (1.7.0 for
clippy, 1.8.0 for rustdoc). Use it instead of the homegrown version; this
requires disabling the multiple_crate_versions lint (the only one that was
enabled from the "cargo" group)---which was not particularly useful anyway
because all dependencies are converted by hand into Meson subprojects.
rustfmt is still not supported.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
docs/devel/rust.rst | 10 +++++++---
meson.build | 2 +-
rust/clippy.toml => clippy.toml | 0
rust/Cargo.toml | 1 -
rust/meson.build | 12 ------------
scripts/rust/rustc_args.py | 5 +----
6 files changed, 9 insertions(+), 21 deletions(-)
rename rust/clippy.toml => clippy.toml (100%)
diff --git a/docs/devel/rust.rst b/docs/devel/rust.rst
index f66f2bef60b..34d9c7945b7 100644
--- a/docs/devel/rust.rst
+++ b/docs/devel/rust.rst
@@ -37,12 +37,16 @@ output directory (typically ``rust/target/``). A vanilla invocation
of Cargo will complain that it cannot find the generated sources,
which can be fixed in different ways:
-* by using special shorthand targets in the QEMU build directory::
+* by using Makefile targets, provided by Meson, that run ``clippy`` or
+ ``rustdoc``:
make clippy
- make rustfmt
make rustdoc
+A target for ``rustfmt`` is also declared in ``rust/meson.build``:
+
+ make rustfmt
+
* by invoking ``cargo`` through the Meson `development environment`__
feature::
@@ -50,7 +54,7 @@ which can be fixed in different ways:
pyvenv/bin/meson devenv -w ../rust cargo fmt
If you are going to use ``cargo`` repeatedly, ``pyvenv/bin/meson devenv``
- will enter a shell where commands like ``cargo clippy`` just work.
+ will enter a shell where commands like ``cargo fmt`` just work.
__ https://mesonbuild.com/Commands.html#devenv
diff --git a/meson.build b/meson.build
index eebd74b1fce..6f6d743a7d8 100644
--- a/meson.build
+++ b/meson.build
@@ -4376,7 +4376,7 @@ foreach target : target_dirs
build_by_default: true,
build_always_stale: true)
rlib = static_library('rust_' + target.underscorify(),
- rlib_rs,
+ structured_sources([], {'.': rlib_rs}),
dependencies: target_rust.dependencies(),
override_options: ['rust_std=2021', 'build.rust_std=2021'],
rust_abi: 'c')
diff --git a/rust/clippy.toml b/clippy.toml
similarity index 100%
rename from rust/clippy.toml
rename to clippy.toml
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index d9faeecb10b..a00b8ad0bcd 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -63,7 +63,6 @@ ignored_unit_patterns = "deny"
implicit_clone = "deny"
macro_use_imports = "deny"
missing_safety_doc = "deny"
-multiple_crate_versions = "deny"
mut_mut = "deny"
needless_bitwise_bool = "deny"
needless_pass_by_ref_mut = "deny"
diff --git a/rust/meson.build b/rust/meson.build
index 801f4374dfa..afce62f4772 100644
--- a/rust/meson.build
+++ b/rust/meson.build
@@ -24,21 +24,9 @@ subdir('hw')
cargo = find_program('cargo', required: false)
if cargo.found()
- run_target('clippy',
- command: [config_host['MESON'], 'devenv',
- '--workdir', '@CURRENT_SOURCE_DIR@',
- cargo, 'clippy', '--tests'],
- depends: bindings_rs)
-
run_target('rustfmt',
command: [config_host['MESON'], 'devenv',
'--workdir', '@CURRENT_SOURCE_DIR@',
cargo, 'fmt'],
depends: bindings_rs)
-
- run_target('rustdoc',
- command: [config_host['MESON'], 'devenv',
- '--workdir', '@CURRENT_SOURCE_DIR@',
- cargo, 'doc', '--no-deps', '--document-private-items'],
- depends: bindings_rs)
endif
diff --git a/scripts/rust/rustc_args.py b/scripts/rust/rustc_args.py
index 2633157df2a..63b0748e0d3 100644
--- a/scripts/rust/rustc_args.py
+++ b/scripts/rust/rustc_args.py
@@ -104,10 +104,7 @@ def generate_lint_flags(cargo_toml: CargoTOML, strict_lints: bool) -> Iterable[s
else:
raise Exception(f"invalid level {level} for {prefix}{lint}")
- # This may change if QEMU ever invokes clippy-driver or rustdoc by
- # hand. For now, check the syntax but do not add non-rustc lints to
- # the command line.
- if k == "rust" and not (strict_lints and lint in STRICT_LINTS):
+ if not (strict_lints and lint in STRICT_LINTS):
lint_list.append(LintFlag(flags=[flag, prefix + lint], priority=priority))
if strict_lints:
--
2.49.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-05-27 17:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27 17:03 [PATCH 0/6] rust: update build system for Meson 1.8.1 Paolo Bonzini
2025-05-27 17:03 ` [PATCH 1/6] meson: update to version 1.8.1 Paolo Bonzini
2025-05-27 17:04 ` [PATCH 2/6] rust: use "objects" for Rust executables as well Paolo Bonzini
2025-05-27 17:04 ` [PATCH 3/6] build, dockerfiles: add support for detecting rustdoc Paolo Bonzini
2025-05-27 17:04 ` [PATCH 4/6] rust: add qemu-api doctests to "meson test" Paolo Bonzini
2025-05-27 17:04 ` [PATCH 5/6] rust: cell: remove support for running doctests with "cargo test --doc" Paolo Bonzini
2025-05-27 17:04 ` [PATCH 6/6] rust: use native Meson support for clippy and rustdoc Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).