Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: kbuild: simplify `--cfg` handling

We need to handle `cfg`s in both `rustc` and `rust-analyzer`, and in
future commits some of those contain double quotes, which complicates
things further.

Thus, instead of removing the `--cfg ` part in the rust-analyzer
generation script, have the `*-cfgs` variables contain just the actual
`cfg`, and use that to generate the actual flags in `*-flags`.

Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Tested-by: Gary Guo <gary@garyguo.net>
Tested-by: Jesung Yang <y.j3ms.n@gmail.com>
Link: https://patch.msgid.link/20251124151837.2184382-3-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

+5 -3
+4 -2
rust/Makefile
··· 60 60 rustdoc_test_kernel_quiet=>/dev/null 61 61 endif 62 62 63 + cfgs-to-flags = $(patsubst %,--cfg='%',$1) 64 + 63 65 core-cfgs := \ 64 - --cfg no_fp_fmt_parse 66 + no_fp_fmt_parse 65 67 66 68 core-edition := $(if $(call rustc-min-version,108700),2024,2021) 67 69 ··· 74 72 75 73 core-flags := \ 76 74 --edition=$(core-edition) \ 77 - $(core-cfgs) 75 + $(call cfgs-to-flags,$(core-cfgs)) 78 76 79 77 # `rustdoc` did not save the target modifiers, thus workaround for 80 78 # the time being (https://github.com/rust-lang/rust/issues/144521).
+1 -1
scripts/generate_rust_analyzer.py
··· 15 15 crates_cfgs = {} 16 16 for cfg in cfgs: 17 17 crate, vals = cfg.split("=", 1) 18 - crates_cfgs[crate] = vals.replace("--cfg", "").split() 18 + crates_cfgs[crate] = vals.split() 19 19 20 20 return crates_cfgs 21 21