From d0a84720abb911bc0bcbf78ca5c45d61883c2927 Mon Sep 17 00:00:00 2001 From: Miguel Ojeda Date: Sat, 28 Nov 2020 15:54:09 +0100 Subject: [PATCH] Ensure we don't break conditional compilation At the moment, any mistake passing the kernel configuration for conditional compilation means we break things silently, like initcall handling which implies panics or memory corruption [1]. Let's prevent that from happening again. [1] https://github.com/Rust-for-Linux/linux/pull/23 Signed-off-by: Miguel Ojeda --- rust/kernel/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rust/kernel/src/lib.rs b/rust/kernel/src/lib.rs index a80e6425f1222b..1e1d22cbd8f48d 100644 --- a/rust/kernel/src/lib.rs +++ b/rust/kernel/src/lib.rs @@ -5,6 +5,11 @@ #![no_std] #![feature(allocator_api, alloc_error_handler)] +// Ensure conditional compilation based on the kernel configuration works; +// otherwise we may silently break things like initcall handling. +#[cfg(not(CONFIG_HAS_RUST))] +compile_error!("Missing kernel configuration for conditional compilation"); + extern crate alloc; use core::panic::PanicInfo;