lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87344hipy8.fsf@t14s.mail-host-address-is-not-set>
Date: Wed, 07 Jan 2026 13:10:07 +0100
From: Andreas Hindborg <a.hindborg@...nel.org>
To: Gary Guo <gary@...yguo.net>, Alice Ryhl <aliceryhl@...gle.com>
Cc: Miguel Ojeda <ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>,
 Björn Roy Baron <bjorn3_gh@...tonmail.com>, Benno Lossin
 <lossin@...nel.org>, Trevor Gross <tmgross@...ch.edu>, Danilo Krummrich
 <dakr@...nel.org>, Alexandre Courbot <acourbot@...dia.com>, Will Deacon
 <will@...nel.org>, Peter Zijlstra <peterz@...radead.org>, Mark Rutland
 <mark.rutland@....com>, Nathan
 Chancellor <nathan@...nel.org>, Nick Desaulniers
 <nick.desaulniers+lkml@...il.com>, Bill Wendling <morbo@...gle.com>,
 Justin
 Stitt <justinstitt@...gle.com>, Nicolas Schier <nicolas.schier@...ux.dev>,
 Andrew Morton <akpm@...ux-foundation.org>, Uladzislau Rezki
 <urezki@...il.com>, rust-for-linux@...r.kernel.org,
 linux-kernel@...r.kernel.org, llvm@...ts.linux.dev,
 linux-kbuild@...r.kernel.org, linux-mm@...ck.org,
 nouveau@...ts.freedesktop.org, Matthew Maurer <mmaurer@...gle.com>
Subject: Re: [PATCH 4/4] build: rust: provide an option to inline C helpers
 into Rust

Gary Guo <gary@...yguo.net> writes:

> On Tue, 02 Dec 2025 20:27:59 +0000
> Alice Ryhl <aliceryhl@...gle.com> wrote:
>
>> From: Gary Guo <gary@...yguo.net>
>> 
>> A new experimental Kconfig option, `RUST_INLINE_HELPERS` is added to
>> allow C helpers (which were created to allow Rust to call into
>> inline/macro C functions without having to re-implement the logic in
>> Rust) to be inlined into Rust crates without performing global LTO.
>> 
>> If the option is enabled, the following is performed:
>> * For helpers, instead of compiling them to an object file to be linked
>>   into vmlinux, they're compiled to LLVM IR.
>> * The LLVM IR is compiled to bitcode (This is step is not necessary, but
>>   is a performance optimisation to prevent LLVM from always have to
>>   reparse the same IR).
>> * When a Rust crate is compiled, instead of generating an object file, we
>>   ask LLVM bitcode to be generated.
>> * llvm-link is invoked with --internalize to combine the helper bitcode
>>   with the crate bitcode. This step is similar to LTO, but this is much
>>   faster since it only needs to inline the helpers.
>> * clang is invoked to turn the combined bitcode into a final object file.
>> 
>> The --internalize flag tells llvm-link to treat all symbols in
>> helpers.bc using `internal` linkage. This matches the behavior of
>> `clang` on `static inline` functions, and avoids exporting the symbol
>> from the object file.
>
> Huge shout-out to Matthew for discovering this option, this makes thing
> so much nicer and it feels way less hacky and more reliable now.
>
>> 
>> To ensure that RUST_INLINE_HELPERS is not incompatible with BTF, we pass
>> the -g0 flag when building helpers. See commit 5daa0c35a1f0 ("rust:
>> Disallow BTF generation with Rust + LTO") for details.
>
> Again this is a much nicer way to workaround the issue than changing
> the language name in the DWARF info using text replacement that I come
> up with :)
>
>> 
>> We have an intended triple mismatch of `aarch64-unknown-none` vs
>> `aarch64-unknown-linux-gnu`, so we suppress the warning.
>> 
>> Co-developed-by: Boqun Feng <boqun.feng@...il.com>
>> Signed-off-by: Boqun Feng <boqun.feng@...il.com>
>> Co-developed-by: Matthew Maurer <mmaurer@...gle.com>
>> Signed-off-by: Matthew Maurer <mmaurer@...gle.com>
>> Signed-off-by: Gary Guo <gary@...yguo.net>
>> Co-developed-by: Alice Ryhl <aliceryhl@...gle.com>
>> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
>> ---
>>  Makefile               |  4 +++-
>>  lib/Kconfig.debug      | 15 +++++++++++++++
>>  rust/Makefile          | 26 ++++++++++++++++++++++----
>>  rust/exports.c         |  5 ++++-
>>  scripts/Makefile.build |  5 ++++-
>>  5 files changed, 48 insertions(+), 7 deletions(-)
>> 
>> diff --git a/Makefile b/Makefile
>> index 96ddbaae7e12de71bcfabef4639de3a13a6e4815..5834bfd568548d1bee34b328dccce5d60f85526f 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -517,6 +517,8 @@ OBJCOPY		= $(LLVM_PREFIX)llvm-objcopy$(LLVM_SUFFIX)
>>  OBJDUMP		= $(LLVM_PREFIX)llvm-objdump$(LLVM_SUFFIX)
>>  READELF		= $(LLVM_PREFIX)llvm-readelf$(LLVM_SUFFIX)
>>  STRIP		= $(LLVM_PREFIX)llvm-strip$(LLVM_SUFFIX)
>> +LLVM_LINK	= $(LLVM_PREFIX)llvm-link$(LLVM_SUFFIX)
>> +LLVM_AS		= $(LLVM_PREFIX)llvm-as$(LLVM_SUFFIX)
>
> I think this is no longer needed as we only use LLVM BC now without
> having to round-trip between LLVM IR.
>

We should update the commit message to reflect this as well.


Best regards,
Andreas Hindborg




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ