objtool/rust: add one more `noreturn` Rust function
Subsystems (3)
Miguel Ojeda
maintainerPATCH 1/1 objtool/rust: add one more `noreturn` Rust function
Between Rust 1.79 and 1.86, under CONFIG_RUST_KERNEL_DOCTESTS=y, objtool may report:
rust/doctests_kernel_generated.o: warning: objtool:
rust_doctest_kernel_alloc_kbox_rs_13() falls through to next function rust_doctest_kernel_alloc_kvec_rs_0()
(as well as in rust_doctest_kernel_alloc_kvec_rs_0) due to calls to the noreturn symbol:
core::option::expect_failed
from code added in commits 779db37373a3 ("rust: alloc: kvec: implement AsPageIter for VVec") and 671618432f46 ("rust: alloc: kbox: implement AsPageIter for VBox").
Thus add the mangled one to the list so that objtool knows it is actually noreturn.
This can be reproduced as well in other versions by tweaking the code, such as the latest stable Rust (1.90.0).
Stable does not have code that triggers this, but it could have it in the future. Downstream forks could too. Thus tag it for backport.
See commit 56d680dd23c3 ("objtool/rust: list noreturn Rust functions") for more details.
--- tools/objtool/check.c | 1 + 1 file changed, 1 insertion(+)
tools/objtool/check.c +1 -0
@@ -217,6 +217,7 @@ static bool is_rust_noreturn(const struct symbol *func)* these come from the Rust standard library). */ return str_ends_with (func->name,"_4core5sliceSp15copy_from_slice17len_mismatch_fail" ) || +str_ends_with (func->name,"_4core6option13expect_failed" ) ||str_ends_with (func->name,"_4core6option13unwrap_failed" ) ||str_ends_with (func->name,"_4core6result13unwrap_failed" ) || str_ends_with(func->name, "_4core9panicking5panic") ||
base-commit: 211ddde0823f1442e4ad052a2f30f050145ccada
Signature · 1 line
2.51.0
Quoted 25 lines · Miguel Ojeda
Between Rust 1.79 and 1.86, under
CONFIG_RUST_KERNEL_DOCTESTS=y,objtoolmay report:
rust/doctests_kernel_generated.o: warning: objtool:
rust_doctest_kernel_alloc_kbox_rs_13()falls through to next functionrust_doctest_kernel_alloc_kvec_rs_0()(as well as in
rust_doctest_kernel_alloc_kvec_rs_0) due to calls to thenoreturnsymbol:
core::option::expect_failedfrom code added in commits
779db37373a3("rust: alloc: kvec: implement AsPageIter for VVec") and671618432f46("rust: alloc: kbox: implement AsPageIter for VBox").Thus add the mangled one to the list so that
objtoolknows it is actuallynoreturn.This can be reproduced as well in other versions by tweaking the code, such as the latest stable Rust (1.90.0).
Stable does not have code that triggers this, but it could have it in the future. Downstream forks could too. Thus tag it for backport.
Quoted 7 lines
See commit
56d680dd23c3("objtool/rust: listnoreturnRust functions") for more details.Cc [email protected] # Needed in 6.12.y and later.Cc Josh Poimboeuf <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Miguel Ojeda <[email protected]>
Peter Zijlstra
maintainerQuoted 42 lines · Miguel Ojeda
Between Rust 1.79 and 1.86, under
CONFIG_RUST_KERNEL_DOCTESTS=y,objtoolmay report:
rust/doctests_kernel_generated.o: warning: objtool:
rust_doctest_kernel_alloc_kbox_rs_13()falls through to next functionrust_doctest_kernel_alloc_kvec_rs_0()(as well as in
rust_doctest_kernel_alloc_kvec_rs_0) due to calls to thenoreturnsymbol:
core::option::expect_failedfrom code added in commits
779db37373a3("rust: alloc: kvec: implement AsPageIter for VVec") and671618432f46("rust: alloc: kbox: implement AsPageIter for VBox").Thus add the mangled one to the list so that
objtoolknows it is actuallynoreturn.This can be reproduced as well in other versions by tweaking the code, such as the latest stable Rust (1.90.0).
Stable does not have code that triggers this, but it could have it in the future. Downstream forks could too. Thus tag it for backport.
See commit
56d680dd23c3("objtool/rust: listnoreturnRust functions") for more details.Cc [email protected] # Needed in 6.12.y and later.Cc Josh Poimboeuf <[email protected]>Cc Peter Zijlstra <[email protected]>Signed-off-by Miguel Ojeda <[email protected]>--- tools/objtool/check.c | 1 + 1 file changed, 1 insertion(+)tools/objtool/check.c +0
-0
tools/objtool/check.c static bool is_rust_noreturn(const struct symbol *func) · line 223
Quoted 7 lines
tools/objtool/check.c +1
-0@@ -217,6 +217,7 @@ static bool is_rust_noreturn(const struct symbol *func)* these come from the Rust standard library). */ return str_ends_with (func->name,"_4core5sliceSp15copy_from_slice17len_mismatch_fail" ) || +str_ends_with (func->name,"_4core6option13expect_failed" ) ||str_ends_with (func->name,"_4core6option13unwrap_failed" ) ||str_ends_with (func->name,"_4core6result13unwrap_failed" ) || str_ends_with(func->name, "_4core9panicking5panic") ||
I'll go stick it in tip/objtool/core; but I gotta ask, where are we with the toolchain support for noreturn?
Quoted 3 lines · Peter Zijlstra
I'll go stick it in tip/objtool/core; but I gotta ask, where are we with the toolchain support for noreturn?
Thanks Peter!
We discussed it with upstream Rust, and they understood the need, so we may get something like --emit=noreturn or similar, but it is still open (and not too high in the priority list since we can survive with this for now and we have other things that we really need them to get stabilized etc. But if you feel it should be prioritized more, please let me know).
I have the status under "Export (somehow) a list of all noreturn symbols." at:
https://github.com/Rust-for-Linux/linux/issues/355
In particular, Gary proposed an alternative during those discussions:
"Gary proposed reading DWARF instead and wrote a quick Rust script
for it via object and gimli, though DWARF would need to be available or generated on the fly just for that (and we cannot commit a fixed list since the kernel config may change and we support several Rust versions and so on):
https://gist.github.com/nbdd0121/449692570622c2f46a29ad9f47c3379a."
Cheers,
Miguel
Peter Zijlstra
maintainerQuoted 5 lines · Miguel Ojeda
Quoted 3 lines · Peter Zijlstra
I'll go stick it in tip/objtool/core; but I gotta ask, where are we with the toolchain support for noreturn?
Quoted 8 lines
Thanks Peter!
We discussed it with upstream Rust, and they understood the need, so we may get something like
--emit=noreturnor similar, but it is still open (and not too high in the priority list since we can survive with this for now and we have other things that we really need them to get stabilized etc. But if you feel it should be prioritized more, please let me know).
Nah, as long as its not forgotten I suppose it'll show up at some point.
I would place including C headers in Rust at a *MUCH* higher priority than this. This bindgen nonsense is a giant pain in the arse.
Quoted 4 lines
I have the status under "Export (somehow) a list of all noreturn symbols." at:
https://github.com/Rust-for-Linux/linux/issues/355
Quoted 8 lines
In particular, Gary proposed an alternative during those discussions:
"Gary proposed reading DWARF instead and wrote a quick Rust script
for it via object and gimli, though DWARF would need to be available or generated on the fly just for that (and we cannot commit a fixed list since the kernel config may change and we support several Rust versions and so on):
https://gist.github.com/nbdd0121/449692570622c2f46a29ad9f47c3379a."
Right, the problem with DWARF is that you need to have DWARF and debug builds are *SLOW* :/ But perhaps rust compile times are such that that isn't noticable?
The following commit has been merged into the objtool/urgent branch of tip:
The following commit has been merged into the objtool/urgent branch of tip:
Commit-ID: dbdf2a7feb422f9bacfd12774e624cf26f503eb0 Gitweb: https://git.kernel.org/tip/dbdf2a7feb422f9bacfd12774e624cf26f503eb0 Author: Miguel Ojeda <[email protected]> AuthorDate: Mon, 20 Oct 2025 04:07:14 +02:00 Committer: Peter Zijlstra <[email protected]> CommitterDate: Wed, 22 Oct 2025 15:21:54 +02:00
objtool/rust: add one more noreturn Rust function
Between Rust 1.79 and 1.86, under CONFIG_RUST_KERNEL_DOCTESTS=y, objtool may report:
rust/doctests_kernel_generated.o: warning: objtool:
rust_doctest_kernel_alloc_kbox_rs_13() falls through to next function rust_doctest_kernel_alloc_kvec_rs_0()
(as well as in rust_doctest_kernel_alloc_kvec_rs_0) due to calls to the noreturn symbol:
core::option::expect_failed
from code added in commits 779db37373a3 ("rust: alloc: kvec: implement AsPageIter for VVec") and 671618432f46 ("rust: alloc: kbox: implement AsPageIter for VBox").
Thus add the mangled one to the list so that objtool knows it is actually noreturn.
This can be reproduced as well in other versions by tweaking the code, such as the latest stable Rust (1.90.0).
Stable does not have code that triggers this, but it could have it in the future. Downstream forks could too. Thus tag it for backport.
See commit 56d680dd23c3 ("objtool/rust: list noreturn Rust functions") for more details.
--- tools/objtool/check.c | 1 + 1 file changed, 1 insertion(+)
tools/objtool/check.c +1 -0
@@ -217,6 +217,7 @@ static bool is_rust_noreturn(const struct symbol *func)* these come from the Rust standard library). */ return str_ends_with (func->name,"_4core5sliceSp15copy_from_slice17len_mismatch_fail" ) || +str_ends_with (func->name,"_4core6option13expect_failed" ) ||str_ends_with (func->name,"_4core6option13unwrap_failed" ) ||str_ends_with (func->name,"_4core6result13unwrap_failed" ) || str_ends_with(func->name, "_4core9panicking5panic") ||