Skip to content

Commit e356c4b

Browse files
ojedaBennoLossin
authored andcommitted
rust: build_error: switch choice to config
Instead of having a `choice` with only two variants, use instead a boolean `config` option. Also reword the option to adapt it to the new format and make it slightly more clear the intention of the option and why the default is the old `DENY` mode. Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 0116b56 commit e356c4b

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

lib/Kconfig.debug

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2800,32 +2800,21 @@ config RUST_OVERFLOW_CHECKS
28002800

28012801
If unsure, say Y.
28022802

2803-
choice
2804-
prompt "Build-time assertions"
2805-
default RUST_BUILD_ASSERT_DENY
2803+
config RUST_BUILD_ASSERT_ALLOW
2804+
bool "Allow unoptimized build-time assertions"
28062805
depends on RUST
28072806
help
28082807
Controls how are `build_error!` and `build_assert!` handled during build.
28092808

28102809
If calls to them exist in the binary, it may indicate a violated invariant
28112810
or that the optimizer failed to verify the invariant during compilation.
2812-
You can choose to abort compilation or ignore them during build and let the
2813-
check be carried to runtime.
2814-
2815-
If unsure, say "Deny".
28162811

2817-
config RUST_BUILD_ASSERT_ALLOW
2818-
bool "Allow"
2819-
help
2820-
Unoptimized calls to `build_error!` will be converted to `panic!`
2821-
and checked at runtime.
2812+
This should not happen, thus by default the build is aborted. However,
2813+
as an escape hatch, you can choose Y here to ignore them during build
2814+
and let the check be carried at runtime (with `panic!` being called if
2815+
the check fails).
28222816

2823-
config RUST_BUILD_ASSERT_DENY
2824-
bool "Deny"
2825-
help
2826-
Unoptimized calls to `build_error!` will abort compilation.
2827-
2828-
endchoice
2817+
If unsure, say N.
28292818

28302819
config RUST_KERNEL_KUNIT_TEST
28312820
bool "KUnit test for the `kernel` crate" if !KUNIT_ALL_TESTS

rust/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ obj-$(CONFIG_RUST) += alloc.o bindings.o kernel.o
1919
always-$(CONFIG_RUST) += exports_alloc_generated.h exports_bindings_generated.h \
2020
exports_kernel_generated.h
2121

22-
ifdef CONFIG_RUST_BUILD_ASSERT_DENY
23-
always-$(CONFIG_RUST) += build_error.o
24-
else
22+
ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
2523
obj-$(CONFIG_RUST) += build_error.o
24+
else
25+
always-$(CONFIG_RUST) += build_error.o
2626
endif
2727

2828
obj-$(CONFIG_RUST) += exports.o

rust/exports.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
#include "exports_kernel_generated.h"
2222

2323
// For modules using `rust/build_error.rs`.
24-
#ifndef CONFIG_RUST_BUILD_ASSERT_DENY
24+
#ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
2525
EXPORT_SYMBOL_RUST_GPL(rust_build_error);
2626
#endif

0 commit comments

Comments
 (0)