Skip to content

Commit

Permalink
x86: rust: move unknown-to-rustc codegen features back to the targe…
Browse files Browse the repository at this point in the history
…t spec file

Similar to c5eae3a ("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 rust-lang/rust#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 rust-lang/rust#96472 as well for a report.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
  • Loading branch information
ojeda committed Aug 1, 2022
1 parent 61104a0 commit 9a9d6ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 0 additions & 2 deletions arch/x86/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion scripts/generate_rust_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9a9d6ee

Please sign in to comment.