Skip to content

Commit 021d355

Browse files
ojedaintel-lab-lkp
authored andcommitted
x86/rust: support RETHUNK
When support for `-Zfunction-return` lands in Rust [1], this patch may be used to enable RETHUNK support on top of the previous patch. Link: rust-lang/rust#116892 [1] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent a85c6d9 commit 021d355

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

arch/x86/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch-cs-prefix)
2424

2525
ifdef CONFIG_RETHUNK
2626
RETHUNK_CFLAGS := -mfunction-return=thunk-extern
27+
RETHUNK_RUSTFLAGS := -Zfunction-return=thunk-extern
2728
RETPOLINE_CFLAGS += $(RETHUNK_CFLAGS)
29+
RETPOLINE_RUSTFLAGS += $(RETHUNK_RUSTFLAGS)
2830
endif
2931

3032
export RETHUNK_CFLAGS
33+
export RETHUNK_RUSTFLAGS
3134
export RETPOLINE_CFLAGS
35+
export RETPOLINE_RUSTFLAGS
3236
export RETPOLINE_VDSO_CFLAGS
3337

3438
# For gcc stack alignment is specified with -mpreferred-stack-boundary,
@@ -193,6 +197,7 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
193197
# Avoid indirect branches in kernel to deal with Spectre
194198
ifdef CONFIG_RETPOLINE
195199
KBUILD_CFLAGS += $(RETPOLINE_CFLAGS)
200+
KBUILD_RUSTFLAGS += $(RETPOLINE_RUSTFLAGS)
196201
# Additionally, avoid generating expensive indirect jumps which
197202
# are subject to retpolines for small number of switch cases.
198203
# LLVM turns off jump table generation by default when under

init/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1889,7 +1889,6 @@ config RUST
18891889
depends on !GCC_PLUGINS
18901890
depends on !RANDSTRUCT
18911891
depends on !DEBUG_INFO_BTF || PAHOLE_HAS_LANG_EXCLUDE
1892-
depends on !RETHUNK
18931892
select CONSTRUCTORS
18941893
help
18951894
Enables Rust support in the kernel.

0 commit comments

Comments
 (0)