Re: [PATCH 00/15] Implement MODVERSIONS for Rust
From: Masahiro Yamada <masahiroy@kernel.org>
Date: 2024-06-18 16:51:15
Also in:
linux-kbuild, lkml, rust-for-linux
On Wed, Jun 19, 2024 at 1:44 AM Greg Kroah-Hartman [off-list ref] wrote:
On Mon, Jun 17, 2024 at 05:58:19PM +0000, Sami Tolvanen wrote:quoted
Hi folks, This series implements CONFIG_MODVERSIONS for Rust, an important feature for distributions like Android that want to ship Rust kernel modules, and depend on modversions to help ensure module ABI compatibility. There have been earlier proposals [1][2] that would allow Rust modules to coexist with modversions, but none that actually implement symbol versioning. Unlike C, Rust source code doesn't have sufficient information about the final ABI, as the compiler has considerable freedom in adjusting structure layout for improved performance [3], for example, which makes using a source code parser like genksyms a non-starter. Based on Matt's suggestion and previous feedback from maintainers, this series uses DWARF debugging information for computing versions. DWARF is an established and relatively stable format, which includes all the necessary ABI details, and adding a CONFIG_DEBUG_INFO dependency for Rust symbol versioning seems like a reasonable trade-off. The first 12 patches of this series add a small tool for computing symbol versions from DWARF, called gendwarfksyms. When passed a list of exported symbols, the tool generates an expanded type string for each symbol, and computes symbol CRCs similarly to genksyms. gendwarfksyms is written in C and uses libdw to process DWARF, mainly because of the existing support for C host tools that use elfutils (e.g., objtool).That's cool, can the C code be switched to also use this? That way we only have one path/code for all of this?
As the description says, it requires CONFIG_DEBUG_INFO. We can strip the debug info from the final vmlinux, but I guess the build speed will be even slower than the current genksyms. -- Best Regards Masahiro Yamada