Skip to content

Commit 033f05f

Browse files
ojedaFabo
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 c32a2ca commit 033f05f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

arch/x86/Makefile

+5
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,
@@ -195,6 +199,7 @@ KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
195199
# Avoid indirect branches in kernel to deal with Spectre
196200
ifdef CONFIG_RETPOLINE
197201
KBUILD_CFLAGS += $(RETPOLINE_CFLAGS)
202+
KBUILD_RUSTFLAGS += $(RETPOLINE_RUSTFLAGS)
198203
# Additionally, avoid generating expensive indirect jumps which
199204
# are subject to retpolines for small number of switch cases.
200205
# LLVM turns off jump table generation by default when under

init/Kconfig

-1
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)