diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 55afb238cbc529..bab595003f07cf 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -21,7 +21,6 @@ ifdef CONFIG_CC_IS_CLANG RETPOLINE_CFLAGS := -mretpoline-external-thunk RETPOLINE_VDSO_CFLAGS := -mretpoline endif -RETPOLINE_RUSTFLAGS := -Ctarget-feature=+retpoline-external-thunk ifdef CONFIG_RETHUNK RETHUNK_CFLAGS := -mfunction-return=thunk-extern @@ -203,7 +202,6 @@ ifdef CONFIG_RETPOLINE ifndef CONFIG_CC_IS_CLANG KBUILD_CFLAGS += -fno-jump-tables endif - KBUILD_RUSTFLAGS += $(RETPOLINE_RUSTFLAGS) endif ifdef CONFIG_SLS diff --git a/scripts/generate_rust_target.rs b/scripts/generate_rust_target.rs index fb4bd5751dab10..0a1ba95d74e772 100644 --- a/scripts/generate_rust_target.rs +++ b/scripts/generate_rust_target.rs @@ -204,7 +204,11 @@ fn main() { "data-layout", "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", ); - ts.push("features", "-3dnow,-3dnowa,-mmx,+soft-float"); + let mut features = "-3dnow,-3dnowa,-mmx,+soft-float".to_string(); + if cfg.has("RETPOLINE") { + features += ",+retpoline-external-thunk"; + } + ts.push("features", features); ts.push("llvm-target", "x86_64-linux-gnu"); ts.push("target-pointer-width", "64"); } else {