rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: Alice Ryhl <aliceryhl@google.com>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Dave Ertman" <david.m.ertman@intel.com>,
	"Ira Weiny" <ira.weiny@intel.com>,
	"Leon Romanovsky" <leon@kernel.org>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Elle Rhumsaa" <elle@weathered-steel.dev>,
	"Carlos Llamas" <cmllamas@google.com>,
	"Yury Norov" <yury.norov@gmail.com>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	linux-block@vger.kernel.org,
	"FUJITA Tomonori" <fujita.tomonori@gmail.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Michael Turquette" <mturquette@baylibre.com>,
	"Stephen Boyd" <sboyd@kernel.org>,
	linux-clk@vger.kernel.org, "Benno Lossin" <lossin@kernel.org>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Viresh Kumar" <viresh.kumar@linaro.org>,
	linux-pm@vger.kernel.org, "Paul Moore" <paul@paul-moore.com>,
	"Serge Hallyn" <sergeh@kernel.org>,
	linux-security-module@vger.kernel.org,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Abdiel Janulgue" <abdiel.janulgue@gmail.com>,
	"Robin Murphy" <robin.murphy@arm.com>,
	"Lyude Paul" <lyude@redhat.com>,
	"Alexander Viro" <viro@zeniv.linux.org.uk>,
	"Christian Brauner" <brauner@kernel.org>,
	"Jan Kara" <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org,
	"Josh Poimboeuf" <jpoimboe@kernel.org>,
	"Jason Baron" <jbaron@akamai.com>,
	"Steven Rostedt" <rostedt@goodmis.org>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Brendan Higgins" <brendan.higgins@linux.dev>,
	"David Gow" <davidgow@google.com>, "Rae Moar" <rmoar@google.com>,
	linux-kselftest@vger.kernel.org,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Liam R. Howlett" <Liam.Howlett@oracle.com>,
	"Andrew Ballance" <andrewjballance@gmail.com>,
	maple-tree@lists.infradead.org, linux-mm@kvack.org,
	"Lorenzo Stoakes" <lorenzo.stoakes@oracle.com>,
	"Uladzislau Rezki" <urezki@gmail.com>,
	"Vitaly Wool" <vitaly.wool@konsulko.se>,
	"Rob Herring" <robh@kernel.org>,
	"Saravana Kannan" <saravanak@google.com>,
	devicetree@vger.kernel.org, "Bjorn Helgaas" <bhelgaas@google.com>,
	"Krzysztof Wilczy´nski" <kwilczynski@kernel.org>,
	linux-pci@vger.kernel.org, "Remo Senekowitsch" <remo@buenzli.dev>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	rcu@vger.kernel.org, "Will Deacon" <will@kernel.org>,
	"Fiona Behrens" <me@kloenk.dev>, "Gary Guo" <gary@garyguo.net>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Vlastimil Babka" <vbabka@suse.cz>,
	"Christoph Lameter" <cl@gentwo.org>,
	"David Rientjes" <rientjes@google.com>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Waiman Long" <longman@redhat.com>,
	"Mitchell Levy" <levymitchell0@gmail.com>,
	"Frederic Weisbecker" <frederic@kernel.org>,
	"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
	"John Stultz" <jstultz@google.com>,
	linux-usb@vger.kernel.org, "Tejun Heo" <tj@kernel.org>,
	"Lai Jiangshan" <jiangshanlai@gmail.com>,
	"Matthew Wilcox" <willy@infradead.org>,
	"Tamir Duberstein" <tamird@gmail.com>
Subject: Re: [PATCH 00/46] Allow inlining C helpers into Rust when using LTO
Date: Tue, 2 Dec 2025 17:47:03 -0800	[thread overview]
Message-ID: <aS-WlwsvGrbGYIYs@tardis.local> (raw)
In-Reply-To: <20251202-define-rust-helper-v1-0-a2e13cbc17a6@google.com>

On Tue, Dec 02, 2025 at 07:37:24PM +0000, Alice Ryhl wrote:
> This patch series adds __rust_helper to every single rust helper. The
> patches do not depend on each other, so maintainers please go ahead and
> pick up any patches relevant to your subsystem! Or provide your Acked-by
> so that Miguel can pick them up.
> 
> These changes were generated by adding __rust_helper and running
> ClangFormat. Unrelated formatting changes were removed manually.
> 
> Why is __rust_helper needed?
> ============================
> 
> Currently, C helpers cannot be inlined into Rust even when using LTO
> because LLVM detects slightly different options on the codegen units.
> 
> * LLVM doesn't want to inline functions compiled with
>   `-fno-delete-null-pointer-checks` with code compiled without. The C
>   CGUs all have this enabled and Rust CGUs don't. Inlining is okay since
>   this is one of the hardening features that does not change the ABI,
>   and we shouldn't have null pointer dereferences in these helpers.
> 
> * LLVM doesn't want to inline functions with different list of builtins. C
>   side has `-fno-builtin-wcslen`; `wcslen` is not a Rust builtin, so
>   they should be compatible, but LLVM does not perform inlining due to
>   attributes mismatch.
> 
> * clang and Rust doesn't have the exact target string. Clang generates
>   `+cmov,+cx8,+fxsr` but Rust doesn't enable them (in fact, Rust will
>   complain if `-Ctarget-feature=+cmov,+cx8,+fxsr` is used). x86-64
>   always enable these features, so they are in fact the same target
>   string, but LLVM doesn't understand this and so inlining is inhibited.
>   This can be bypassed with `--ignore-tti-inline-compatible`, but this
>   is a hidden option.
> 
> (This analysis was written by Gary Guo.)
> 
> How is this fixed?
> ==================
> 
> To fix this we need to add __always_inline to all helpers when compiling
> with LTO. However, it should not be added when running bindgen as
> bindgen will ignore functions marked inline. To achieve this, we are
> using a #define called __rust_helper that is defined differently
> depending on whether bindgen is running or not.
> 
> Note that __rust_helper is currently always #defined to nothing.
> Changing it to __always_inline will happen separately in another patch
> series.
> 
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>

For the whole series:

Reviewed-by: Boqun Feng <boqun.feng@gmail.com>

Regards,
Boqun

> ---
[...]

  parent reply	other threads:[~2025-12-03  1:47 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-02 19:37 [PATCH 00/46] Allow inlining C helpers into Rust when using LTO Alice Ryhl
2025-12-02 19:37 ` [PATCH 01/46] rust: auxiliary: add __rust_helper to helpers Alice Ryhl
2025-12-02 19:37 ` [PATCH 02/46] rust: barrier: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 03/46] rust: binder: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 04/46] rust: bitmap: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 05/46] rust: bitops: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 06/46] rust: blk: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 07/46] rust: bug: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 08/46] rust: clk: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 09/46] rust: completion: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 10/46] rust: cpu: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 11/46] rust: cpufreq: " Alice Ryhl
2025-12-03  5:48   ` Viresh Kumar
2025-12-02 19:37 ` [PATCH 12/46] rust: cpumask: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 13/46] rust: cred: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 14/46] rust: device: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 15/46] rust: dma: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 16/46] rust: drm: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 17/46] rust: err: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 18/46] rust: fs: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 19/46] rust: io: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 20/46] rust: irq: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 21/46] rust: jump_label: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 22/46] rust: kunit: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 23/46] rust: maple_tree: " Alice Ryhl
2025-12-04 21:07   ` Andrew Ballance
2025-12-02 19:37 ` [PATCH 24/46] rust: mm: " Alice Ryhl
2025-12-03  1:43   ` Boqun Feng
2025-12-03  9:03     ` Alice Ryhl
2025-12-02 19:37 ` [PATCH 25/46] rust: of: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 26/46] rust: pci: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 27/46] rust: pid_namespace: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 28/46] rust: platform: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 29/46] rust: poll: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 30/46] rust: processor: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 31/46] rust: property: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 32/46] rust: rbtree: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 33/46] rust: rcu: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 34/46] rust: refcount: " Alice Ryhl
2025-12-02 19:37 ` [PATCH 35/46] rust: regulator: " Alice Ryhl
2025-12-02 19:38 ` [PATCH 36/46] rust: scatterlist: " Alice Ryhl
2025-12-02 19:38 ` [PATCH 37/46] rust: security: " Alice Ryhl
2025-12-02 19:38 ` [PATCH 38/46] rust: slab: " Alice Ryhl
2025-12-03  1:45   ` Boqun Feng
2025-12-03  9:03     ` Alice Ryhl
2025-12-02 19:38 ` [PATCH 39/46] rust: sync: " Alice Ryhl
2025-12-02 19:38 ` [PATCH 40/46] rust: task: " Alice Ryhl
2025-12-02 19:38 ` [PATCH 41/46] rust: time: " Alice Ryhl
2025-12-02 19:38 ` [PATCH 42/46] rust: uaccess: " Alice Ryhl
2025-12-02 19:38 ` [PATCH 43/46] rust: usb: " Alice Ryhl
2025-12-02 19:38 ` [PATCH 44/46] rust: wait: " Alice Ryhl
2025-12-02 19:38 ` [PATCH 45/46] rust: workqueue: " Alice Ryhl
2025-12-02 19:38 ` [PATCH 46/46] rust: xarray: " Alice Ryhl
2025-12-03  1:47 ` Boqun Feng [this message]
2025-12-03 14:33 ` [PATCH 00/46] Allow inlining C helpers into Rust when using LTO Gary Guo
2025-12-04 10:05 ` (subset) " Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aS-WlwsvGrbGYIYs@tardis.local \
    --to=boqun.feng@gmail.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=a.hindborg@kernel.org \
    --cc=abdiel.janulgue@gmail.com \
    --cc=acourbot@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=aliceryhl@google.com \
    --cc=andrewjballance@gmail.com \
    --cc=anna-maria@linutronix.de \
    --cc=ardb@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=brauner@kernel.org \
    --cc=brendan.higgins@linux.dev \
    --cc=broonie@kernel.org \
    --cc=cl@gentwo.org \
    --cc=cmllamas@google.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=david.m.ertman@intel.com \
    --cc=davidgow@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=elle@weathered-steel.dev \
    --cc=frederic@kernel.org \
    --cc=fujita.tomonori@gmail.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=ira.weiny@intel.com \
    --cc=jack@suse.cz \
    --cc=jbaron@akamai.com \
    --cc=jiangshanlai@gmail.com \
    --cc=jpoimboe@kernel.org \
    --cc=jstultz@google.com \
    --cc=kwilczynski@kernel.org \
    --cc=leon@kernel.org \
    --cc=levymitchell0@gmail.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=lossin@kernel.org \
    --cc=lyude@redhat.com \
    --cc=maple-tree@lists.infradead.org \
    --cc=me@kloenk.dev \
    --cc=mingo@redhat.com \
    --cc=mturquette@baylibre.com \
    --cc=ojeda@kernel.org \
    --cc=paul@paul-moore.com \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=remo@buenzli.dev \
    --cc=rientjes@google.com \
    --cc=rmoar@google.com \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=rostedt@goodmis.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=saravanak@google.com \
    --cc=sboyd@kernel.org \
    --cc=sergeh@kernel.org \
    --cc=tamird@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=urezki@gmail.com \
    --cc=vbabka@suse.cz \
    --cc=viresh.kumar@linaro.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=vitaly.wool@konsulko.se \
    --cc=will@kernel.org \
    --cc=willy@infradead.org \
    --cc=yury.norov@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).