diff --git a/build.rs b/build.rs index 3b68df9eb5..24f48b3730 100644 --- a/build.rs +++ b/build.rs @@ -23,10 +23,16 @@ fn parse_kconfig(arch: &str) -> Option<()> { .as_table() .unwrap(); + let self_modifying = env::var("CARGO_FEATURE_SELF_MODIFYING").is_ok(); + for (name, value) in altfeatures { - let choice = value.as_str().unwrap(); + let mut choice = value.as_str().unwrap(); assert!(matches!(choice, "always" | "never" | "auto")); + if !self_modifying && choice == "auto" { + choice = "never"; + } + println!("cargo:rustc-cfg=cpu_feature_{choice}=\"{name}\""); }