rust: two small improvements for kunit
Subsystems (2)
cover rust: two small improvements for kunit
Two quality of live improvements for running kunit tests for rust/. While today there are only the doctests, more are coming [0].
$ ./tools/testing/kunit/kunit.py run --kunitconfig rust/ [14:25:48] Configuring KUnit Kernel ... [14:25:48] Building KUnit Kernel ... Populating config with: $ make ARCH=um O=.kunit olddefconfig Building with: $ make all compile_commands.json ARCH=um O=.kunit --jobs=16 [14:25:53] Starting KUnit Kernel (1/1)... [14:25:53] ============================================================ Running tests with: $ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt [14:25:53] =========== rust_doctests_kernel (135 subtests) ============ [14:25:53] [PASSED] rust_doctest_kernel_alloc_kbox_rs_0
... [14:25:53] [PASSED] rust_doctest_kernel_workqueue_rs_3 [14:25:53] ============== [PASSED] rust_doctests_kernel =============== [14:25:53] ============================================================ [14:25:53] Testing complete. Ran 135 tests: passed: 135 [14:25:53] Elapsed time: 5.431s total, 0.001s configuring, 5.314s building, 0.086s running
[0] https://lore.kernel.org/rust-for-linux/[email protected]/
---
Thomas Weißschuh (2):
rust: pass correct target to bindgen on Usermode Linux
rust: add kunitconfig
rust/.kunitconfig | 3 +++ rust/Makefile | 1 + 2 files changed, 4 insertions(+)
---
base-commit: beeb78d46249cab8b2b8359a2ce8fa5376b5ad2d
change-id: 20250208-rust-kunit-dd350e1a463c
Best regards,
Signature · 1 line
Thomas Weißschuh <[email protected]>
PATCH 1/2 rust: pass correct target to bindgen on Usermode Linux
Usermode Linux uses "um" as primary architecture name and the underlying physical architecture is provided in "SUBARCH".
Resolve the target architecture flags through that underlying architecture. This is the same pattern as used by scripts/Makefile.clang from which the bindgen flags are derived.
--- rust/Makefile | 1 + 1 file changed, 1 insertion(+)
rust/Makefile +1 -0
@@ -245,6 +245,7 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \ # Derived from `scripts/Makefile.clang`. BINDGEN_TARGET_x86 := x86_64-linux-gnu BINDGEN_TARGET_arm64 := aarch64-linux-gnu +BINDGEN_TARGET_um := $(BINDGEN_TARGET_$(SUBARCH)) BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH)) # All warnings are inhibited since GCC builds are very experimental,
Signature · 1 line
2.48.1
Re: [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux
Quoted 9 lines · Thomas Weißschuh
Usermode Linux uses "um" as primary architecture name and the underlying physical architecture is provided in "SUBARCH".
Resolve the target architecture flags through that underlying architecture. This is the same pattern as used byscripts/Makefile.clangfrom which the bindgen flags are derived.Signed-off-by Thomas Weißschuh <[email protected]>---
(+cc linux-um, but I assume this will probably go in via the Rust tree, anyway.)
Thanks very much: this is enough to get Rust-for-Linux working with gcc under 64-bit UML on my system.
However, this is actually a bit of a coincidence -- and there are still some issues with 32-bit UML -- as the UML Rust flags are currently conditionally set if CC_IS_CLANG. This is my fault (it was to work around some bugs with older gcc), and I've sent a patch[1] to fix it. (Though note that 32-bit UML/Rust still hits issues with atomics in the block driver, so you'll need to disable that for now.)
Regardless, this is a significant improvement, thanks!
Thanks,
-- David
[1]: https://lore.kernel.org/rust-for-linux/[email protected]/
Quoted 20 lines
rust/Makefile | 1 + 1 file changed, 1 insertion(+)rust/Makefile +1
-1@@ -245,6 +245,7 @@ bindgen_skip_c_flags := -mno-fp-ret-in-387 -mpreferred-stack-boundary=% \ # Derived from `scripts/Makefile.clang`. BINDGEN_TARGET_x86 := x86_64-linux-gnu BINDGEN_TARGET_arm64 := aarch64-linux-gnu +BINDGEN_TARGET_um := $(BINDGEN_TARGET_$(SUBARCH)) BINDGEN_TARGET := $(BINDGEN_TARGET_$(SRCARCH)) # All warnings are inhibited since GCC builds are very experimental, --2.48.1
Re: [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux
In reply to Thomas WeißschuhQuoted 9 lines · Thomas Weißschuh
Usermode Linux uses "um" as primary architecture name and the underlying physical architecture is provided in "SUBARCH".
Resolve the target architecture flags through that underlying architecture. This is the same pattern as used byscripts/Makefile.clangfrom which the bindgen flags are derived.Signed-off-by Thomas Weißschuh <[email protected]>---
Is there anything holding this up for the upcoming merge window?
Miguel: I'm assuming you'd rather take this (and possibly [1] as well) via Rust, but if it goes in via the uml tree, that'd be fine by me, too.
Cheers,
-- David
Re: [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux
Quoted 6 lines · David Gow
Is there anything holding this up for the upcoming merge window?
Miguel: I'm assuming you'd rather take this (and possibly [1] as well) via Rust, but if it goes in via the uml tree, that'd be fine by me, too.
We try to get arch maintainers involved (and everyone else, of course), i.e. it is up to them. But I see only the list was Cc'd, not them directly, for some reason -- doing it here.
Ideally, maintainers get involved and pick their own Rust-related patches, but I can also do so with an Acked-by from them, which would be nice.
If they don't say anything, then since you have tested it (and you are a main um user due to KUnit), that should be enough, but then I would suggest we do it after -rc1 to give them time to react.
Thanks!
Cheers,
Miguel
Re: [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux
Quoted 11 lines · Miguel Ojeda
Quoted 6 lines · David Gow
Is there anything holding this up for the upcoming merge window?
Miguel: I'm assuming you'd rather take this (and possibly [1] as well) via Rust, but if it goes in via the uml tree, that'd be fine by me, too.
We try to get arch maintainers involved (and everyone else, of course), i.e. it is up to them. But I see only the list was Cc'd, not them directly, for some reason -- doing it here.
The list is fine, but the patch wasn't even CC'ed there, so we don't have it in our patchwork:
https://patchwork.ozlabs.org/project/linux-um/list/
Quoted 3 lines
Ideally, maintainers get involved and pick their own Rust-related patches, but I can also do so with an Acked-by from them, which would be nice.
I was just picking up um patches, but given that it was a series, and changes rust/ rather than arch/um/, I think it's probably better if you do it, so:
johannes
Re: [PATCH 1/2] rust: pass correct target to bindgen on Usermode Linux
Quoted 4 lines · Johannes Berg
The list is fine, but the patch wasn't even CC'ed there, so we don't have it in our patchwork:
https://patchwork.ozlabs.org/project/linux-um/list/
Ah, right, David added it.
Quoted 5 lines
I was just picking up um patches, but given that it was a series, and changes
rust/rather thanarch/um/, I think it's probably better if you do it, so:Acked-by Johannes Berg <[email protected]>
Thanks for the very quick reply!
I guess they could be picked independently, but I am happy to pick both.
Cheers,
Miguel
PATCH 2/2 rust: add kunitconfig
In reply to Thomas WeißschuhThe kunitconfig file in a directory is used by kunit.py to enable all necessary kernel configurations to run the tests in that subdirectory. Add such a file for rust/.
--- rust/.kunitconfig | 3 +++ 1 file changed, 3 insertions(+)
rust/.kunitconfig new file +3 -0
@@ -0,0 +1,3 @@ +CONFIG_KUNIT=y +CONFIG_RUST=y +CONFIG_RUST_KERNEL_DOCTESTS=y
Signature · 1 line
2.48.1
Re: [PATCH 2/2] rust: add kunitconfig
Quoted 7 lines · Thomas Weißschuh
The kunitconfig file in a directory is used by
kunit.pyto enable all necessary kernel configurations to run the tests in that subdirectory. Add such a file forrust/.Signed-off-by Thomas Weißschuh <[email protected]>---
I could swear we already had one of these lying around: maybe it was in an old Pull Request somewhere...
Anyway, this is great, thanks!
Cheers,
-- David
Quoted 17 lines
rust/.kunitconfig | 3 +++ 1 file changed, 3 insertions(+)rust/.kunitconfig new file +3
-1@@ -0,0 +1,3 @@ +CONFIG_KUNIT=y +CONFIG_RUST=y +CONFIG_RUST_KERNEL_DOCTESTS=y --2.48.1
Miguel Ojeda
AppliedQuoted 26 lines · Thomas Weißschuh
Two quality of live improvements for running kunit tests for
rust/. While today there are only the doctests, more are coming [0].$ ./tools/testing/kunit/kunit.py run --kunitconfig rust/ [14:25:48] Configuring KUnit Kernel ... [14:25:48] Building KUnit Kernel ... Populating config with: $ make ARCH=um O=.kunit olddefconfig Building with: $ make all compile_commands.json ARCH=um O=.kunit --jobs=16 [14:25:53] Starting KUnit Kernel (1/1)... [14:25:53] ============================================================ Running tests with: $ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt [14:25:53] =========== rust_doctests_kernel (135 subtests) ============ [14:25:53] [PASSED] rust_doctest_kernel_alloc_kbox_rs_0... [14:25:53] [PASSED] rust_doctest_kernel_workqueue_rs_3 [14:25:53] ============== [PASSED] rust_doctests_kernel =============== [14:25:53] ============================================================ [14:25:53] Testing complete. Ran 135 tests: passed: 135 [14:25:53] Elapsed time: 5.431s total, 0.001s configuring, 5.314s building, 0.086s running
Quoted 3 lines
[0] https://lore.kernel.org/rust-for-linux/[email protected]/
Signed-off-by Thomas Weißschuh <[email protected]>
Applied to rust-next -- thanks everyone!
[ David says:
(...) this is enough to get Rust-for-Linux working with gcc under 64-bit UML on my system.
- Miguel ]
Cheers,
Miguel