Skip to content

Commit f2a7bfe

Browse files
committed
rust: build_error: remove RUST_BUILD_ASSERT_WARN support
There are several problems with `RUST_BUILD_ASSERT_WARN`: - ld.lld behaves differently than ld.bfd and emits warnings even when all calls are correct and optimized away in `DENY` mode. This could be solved by restricting the `WARN` mode so that it can only be used when the GNU linker is used. - Since we need to export the `rust_build_error` for loadable kernel modules, even ld.bfd considers that as a use. - For loadable modules, we do not get warnings since the section is in `build_error`, not the module. These last two issues may be possible to solve all by creating a symbol and section per loadable kernel module. While all the above may be possible to solve, supporting the `WARN` mode gets more complex and it is not worth to support. It was introduced back when we had configurable optimization levels, but nowadays optimizations are always enabled. Therefore, `DENY` is probably good enough for all use cases, with `ALLOW` being the escape hatch. Thus remove the `WARN` support. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 571a9e0 commit f2a7bfe

File tree

2 files changed

+0
-11
lines changed

2 files changed

+0
-11
lines changed

lib/Kconfig.debug

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,12 +2820,6 @@ config RUST_BUILD_ASSERT_ALLOW
28202820
Unoptimized calls to `build_error!` will be converted to `panic!`
28212821
and checked at runtime.
28222822

2823-
config RUST_BUILD_ASSERT_WARN
2824-
bool "Warn"
2825-
help
2826-
Unoptimized calls to `build_error!` will be converted to `panic!`
2827-
and checked at runtime, but warnings will be generated when building.
2828-
28292823
config RUST_BUILD_ASSERT_DENY
28302824
bool "Deny"
28312825
help

rust/build_error.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,3 @@
2222
pub const fn build_error(msg: &'static str) -> ! {
2323
panic!("{}", msg);
2424
}
25-
26-
#[cfg(CONFIG_RUST_BUILD_ASSERT_WARN)]
27-
#[link_section = ".gnu.warning.rust_build_error"]
28-
#[used]
29-
static BUILD_ERROR_WARNING: [u8; 45] = *b"call to build_error present after compilation";

0 commit comments

Comments
 (0)