Re: [PATCH v2] rust: sync: optimize rust symbol generation for CondVar

From: Kunwu Chan
Date: Mon Mar 24 2025 - 23:02:49 EST


On 2025/3/24 17:37, Miguel Ojeda wrote:
On Mon, Mar 24, 2025 at 7:19 AM Kunwu Chan<kunwu.chan@xxxxxxxxx> wrote:
Link:https://github.com/Rust-for-Linux/linux/issues/1145
Suggested-by: Alice Ryhl<aliceryhl@xxxxxxxxxx>
Nit: I typically use Link after Suggested-by, to mimic what the docs
require about Reported-by with Link. (No need to resend a new version
just for this :)
Thanks for the kind reminder, I'll follow this next time
- Remove '#[inline]' for notify()
It is good that the commit matches the log now, though I wonder if in
the future we may want the `#[inline]` for `notify` anyway, even if
LLVM does that one on its own today.
Now, the default '-Copt-level' is 2 when define 'CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE',
and in  KBUILD_RUSTFLAGS the  '-Ccodegen-units' is 1.

So if the config not change, the result should be the same.

And the actualy compile steps for rust/kernel.o is as following:

make -f ./scripts/Makefile.build obj=rust
# RUSTC L rust/kernel.o
OBJTREE=/media/kunwuchan/68d922f3-5dde-45b0-af93-c45ba81d85ef/linux-next rustc --edition=2021 -Zbinary_dep_depinfo=y -Astable_features -Dnon_ascii_idents -Dunsafe_op_in_unsafe_fn -Wmissing_docs -Wrust_2018_idioms -Wunreachable_pub -Wclippy::all -Wclippy::ignored_unit_patterns -Wclippy::mut_mut -Wclippy::needless_bitwise_bool -Wclippy::needless_continue -Aclippy::needless_lifetimes -Wclippy::no_mangle_with_rust_abi -Wclippy::undocumented_unsafe_blocks -Wclippy::unnecessary_safety_comment -Wclippy::unnecessary_safety_doc -Wrustdoc::missing_crate_level_docs -Wrustdoc::unescaped_backticks -Cpanic=abort -Cembed-bitcode=n -Clto=n -Cforce-unwind-tables=n -Ccodegen-units=1 -Csymbol-mangling-version=v0 -Crelocation-model=static -Zfunction-sections=n -Wclippy::float_arithmetic --target=aarch64-unknown-none-softfloat -Cforce-unwind-tables=n -Zbranch-protection=bti,pac-ret -Copt-level=2 -Cdebug-assertions=y -Coverflow-checks=y -Cforce-frame-pointers=y -Cdebuginfo=1 @./include/generated/rustc_cfg --extern ffi --extern pin_init --extern build_error --extern macros --extern bindings --extern uapi --emit=dep-info=rust/.kernel.o.d --emit=obj=rust/kernel.o --emit=metadata=rust/libkernel.rmeta --crate-type rlib -L./rust --crate-name kernel rust/kernel/lib.rs --sysroot=/dev/null
# EXPORTS rust/exports_kernel_generated.h
  llvm-nm -p --defined-only rust/kernel.o | awk '$2~/(T|R|D|B)/ && $3!~/__cfi/ && $3!~/__odr_asan/ { printf "EXPORT_SYMBOL_RUST_GPL(%s);
",$3 }' > rust/exports_kernel_generated.h

Cheers,
Miguel

--
Thanks,
Kunwu.Chan(Tao.Chan)