From 9a9d6eea257edf99f32161775de82b171181cf59 Mon Sep 17 00:00:00 2001 From: Miguel Ojeda Date: Mon, 1 Aug 2022 22:02:30 +0200 Subject: [PATCH] x86: rust: move unknown-to-`rustc` codegen features back to the target spec file Similar to c5eae3a6e69c ("x86: rust: move unknown-to-`rustc` codegen features back to the target spec file"), but for `retpoline-external-thunk`: Only a subset of the LLVM codegen features are recognized by `rustc`, and since https://github.com/rust-lang/rust/pull/87402 (Rust 1.61.0) the compiler gives a warning about it: warning: unknown feature specified for `-Ctarget-feature`: `mmx` | = note: it is still passed through to the codegen backend = note: consider filing a feature request ...since those features may be renamed or removed at any point: $ rustc --print target-features [...] Code-generation features cannot be used in cfg or #[target_feature], and may be renamed or removed in a future version of LLVM or rustc. Thus move them back to the target spec generated file. See https://github.com/rust-lang/rust/issues/96472 as well for a report. Signed-off-by: Miguel Ojeda --- arch/x86/Makefile | 2 -- scripts/generate_rust_target.rs | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) 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 {