Skip to content

Commit a85c6d9

Browse files
ojedaintel-lab-lkp
authored andcommitted
x86/rust: depend on !RETHUNK
The Rust compiler does not support the equivalent of `-mfunction-return=thunk-extern` yet [1]. Thus, currently, `objtool` warns about it, e.g.: samples/rust/rust_print.o: warning: objtool: _R...init+0xa5c: 'naked' return found in RETHUNK build The support in `rustc` for `-Zfunction-return` has been submitted and is being reviewed [2]. It adds the needed LLVM function attributes and, with it, I got a RETHUNK kernel build with Rust enabled that does not print the `objtool` related warnings, boots in QEMU and can load a kernel loadable module. In any case, until proper/complete support is added to `rustc`, make it a hard restriction until the mitigation is in place. This may have an impact for developers that may not need/care about the mitigation in the Rust side (e.g. Ubuntu offers Rust as a "technology preview" [3]), but given we are getting closer to having the first actual in-tree Rust kernel users, it seems like the right time to disallow it. This should also avoid confusion [4]. Link: rust-lang/rust#116853 [1] Link: rust-lang/rust#116892 [2] Link: https://lore.kernel.org/rust-for-linux/ZSQXqX2%2Flhf5ICZP@gpd/ [3] Link: https://lore.kernel.org/rust-for-linux/CANiq72n6DMeXQrgOzS_+3VdgNYAmpcnneAHJnZERUQhMExg+0A@mail.gmail.com/ [4] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 84ea629 commit a85c6d9

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Diff for: init/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,7 @@ 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
18921893
select CONSTRUCTORS
18931894
help
18941895
Enables Rust support in the kernel.

0 commit comments

Comments
 (0)