* [PATCH] rust: add --check-cfg test to rustc arguments
@ 2025-01-07 15:54 Paolo Bonzini
2025-01-07 18:43 ` Paolo Bonzini
2025-01-17 16:00 ` Alex Bennée
0 siblings, 2 replies; 4+ messages in thread
From: Paolo Bonzini @ 2025-01-07 15:54 UTC (permalink / raw)
To: qemu-devel
rustc will check that every reachable #[cfg] matches a list of
the expected config names and values. Recent versions of rustc are
also complaining about #[cfg(test)], even if it is basically a standard
part of the language. So, always allow it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
scripts/rust/rustc_args.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/rust/rustc_args.py b/scripts/rust/rustc_args.py
index 5525b3886fa..d79dc6d81f1 100644
--- a/scripts/rust/rustc_args.py
+++ b/scripts/rust/rustc_args.py
@@ -215,6 +215,8 @@ def main() -> None:
if rustc_version >= (1, 80):
if args.lints:
+ print("--check-cfg")
+ print("test")
for cfg in sorted(cargo_toml.check_cfg):
print("--check-cfg")
print(cfg)
--
2.47.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] rust: add --check-cfg test to rustc arguments
2025-01-07 15:54 [PATCH] rust: add --check-cfg test to rustc arguments Paolo Bonzini
@ 2025-01-07 18:43 ` Paolo Bonzini
2025-01-17 16:00 ` Alex Bennée
1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2025-01-07 18:43 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]
Il mar 7 gen 2025, 16:54 Paolo Bonzini <pbonzini@redhat.com> ha scritto:
> rustc will check that every reachable #[cfg] matches a list of
> the expected config names and values. Recent versions of rustc are
> also complaining about #[cfg(test)], even if it is basically a standard
> part of the language. So, always allow it.
>
This is https://github.com/rust-lang/compiler-team/issues/785; I will add
it to the commit message.
Paolo
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> scripts/rust/rustc_args.py | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/scripts/rust/rustc_args.py b/scripts/rust/rustc_args.py
> index 5525b3886fa..d79dc6d81f1 100644
> --- a/scripts/rust/rustc_args.py
> +++ b/scripts/rust/rustc_args.py
> @@ -215,6 +215,8 @@ def main() -> None:
>
> if rustc_version >= (1, 80):
> if args.lints:
> + print("--check-cfg")
> + print("test")
> for cfg in sorted(cargo_toml.check_cfg):
> print("--check-cfg")
> print(cfg)
> --
> 2.47.1
>
[-- Attachment #2: Type: text/html, Size: 2022 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] rust: add --check-cfg test to rustc arguments
2025-01-07 15:54 [PATCH] rust: add --check-cfg test to rustc arguments Paolo Bonzini
2025-01-07 18:43 ` Paolo Bonzini
@ 2025-01-17 16:00 ` Alex Bennée
2025-01-17 16:04 ` Paolo Bonzini
1 sibling, 1 reply; 4+ messages in thread
From: Alex Bennée @ 2025-01-17 16:00 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
Paolo Bonzini <pbonzini@redhat.com> writes:
> rustc will check that every reachable #[cfg] matches a list of
> the expected config names and values. Recent versions of rustc are
> also complaining about #[cfg(test)], even if it is basically a standard
> part of the language. So, always allow it.
Hmm this breaks the non-project CI builds even further (I as hoping it
would help):
FAILED: rust/qemu-api/libqemu_api.rlib
/usr/local/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc -C linker=cc -C link-arg=-m64 --color=auto -C debug-assertions=yes -C overflow-checks=no --crate-type rlib -D warnings --edition=2021 -C opt-level=2 -g -D unexpected_cfgs -D unsafe_op_in_unsafe_fn -D warnings -D unknown_lints --check-cfg test --check-cfg 'cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)' --check-cfg 'cfg(MESON)' --check-cfg 'cfg(has_offset_of)' --cfg MESON -C default-linker-libraries --crate-name qemu_api --emit dep-info=rust/qemu-api/qemu_api.d --emit link=rust/qemu-api/libqemu_api.rlib --out-dir rust/qemu-api/libqemu_api.rlib.p -C metadata=81e2432@@qemu_api@sta --check-cfg 'cfg(feature,values("allocator"))' --check-cfg 'cfg(feature,values("debug_cell"))' --cfg HAVE_GLIB_WITH_ALIGNED_ALLOC --cfg has_offset_of rust/qemu-api/libqemu_api.rlib.p/structured/lib.rs
error: invalid `--check-cfg` argument: `test`
|
= note: expected `cfg(name, values("value1", "value2", ... "valueN"))`
= note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details
[778/3165] Generating tests/Test QAPI files with a custom command
[779/3165] Compiling Rust source ../subprojects/syn-2.0.66/src/lib.rs
ninja: build stopped: subcommand failed.
make: *** [Makefile:168: run-ninja] Error 1
See https://gitlab.com/stsquad/qemu/-/jobs/8883566658
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> scripts/rust/rustc_args.py | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/scripts/rust/rustc_args.py b/scripts/rust/rustc_args.py
> index 5525b3886fa..d79dc6d81f1 100644
> --- a/scripts/rust/rustc_args.py
> +++ b/scripts/rust/rustc_args.py
> @@ -215,6 +215,8 @@ def main() -> None:
>
> if rustc_version >= (1, 80):
> if args.lints:
> + print("--check-cfg")
> + print("test")
> for cfg in sorted(cargo_toml.check_cfg):
> print("--check-cfg")
> print(cfg)
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] rust: add --check-cfg test to rustc arguments
2025-01-17 16:00 ` Alex Bennée
@ 2025-01-17 16:04 ` Paolo Bonzini
0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2025-01-17 16:04 UTC (permalink / raw)
To: Alex Bennée; +Cc: qemu-devel
On Fri, Jan 17, 2025 at 5:01 PM Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Paolo Bonzini <pbonzini@redhat.com> writes:
>
> > rustc will check that every reachable #[cfg] matches a list of
> > the expected config names and values. Recent versions of rustc are
> > also complaining about #[cfg(test)], even if it is basically a standard
> > part of the language. So, always allow it.
>
> Hmm this breaks the non-project CI builds even further (I as hoping it
> would help):
You hoped right; the patch has a typo (sorry about that) and needs to
print 'cfg(test)'. The correct patch is included in my latest pull
request.
Do not worry too much about failures in the nightly Rust job unless
you're working on Rust itself; it's there so that future breakage is
detected early, as in this case of a compiler change that had a
matching cargo change.
Paolo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-17 16:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-07 15:54 [PATCH] rust: add --check-cfg test to rustc arguments Paolo Bonzini
2025-01-07 18:43 ` Paolo Bonzini
2025-01-17 16:00 ` Alex Bennée
2025-01-17 16:04 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.