From: Gary Guo <[email protected]> Currently rustdoc will generate function names like "_doctest_main__home_gary_Projects_linux_rust_kernel_io_rs_824_0" for a doctest located at rust/kernel/io.rs:824, when building with separate outdir using `O=`. This creates overlong symbol names and is also not reproducible.
Fix it by doing a custom remapping to trim it to something like `_doctest_main_rust_kernel_io_rs_824_0`. Signed-off-by: Gary Guo <[email protected]> --- Changes in v2: - Do an unconditional replacement to cover all cases. --- scripts/rustdoc_test_builder.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/rustdoc_test_builder.rs b/scripts/rustdoc_test_builder.rs index 5457679c12f9..79cef75f5af3 100644 --- a/scripts/rustdoc_test_builder.rs +++ b/scripts/rustdoc_test_builder.rs @@ -70,6 +70,11 @@ fn main() { // Figure out a smaller test name based on the generated function name. let name = rustdoc_function_name.split_once("_rust_kernel_").unwrap().1; + // The rustdoc function name can include the absolute path when building with `O=` which is + // undesireable and create overlong symbol names. Remap it to use relative path. + let trimmed_function_name = format!("_doctest_main_rust_kernel_{name}"); + let body = body.replace(&rustdoc_function_name, &trimmed_function_name); + let path = format!("rust/test/doctests/kernel/{name}"); std::fs::write(path, body.as_bytes()).unwrap(); -- 2.54.0

