From: "Gary Guo" <gary@garyguo.net>
To: "Alexandre Courbot" <acourbot@nvidia.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Onur Özkan" <work@onurozkan.dev>
Cc: <rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rust: export zerocopy symbols to modules
Date: Wed, 08 Jul 2026 12:34:32 +0100 [thread overview]
Message-ID: <DJT5P43GJ9MT.2527G7CFCEW46@garyguo.net> (raw)
In-Reply-To: <20260708-zerocopy-export-v1-1-2bfc355853c6@nvidia.com>
On Wed Jul 8, 2026 at 11:37 AM BST, Alexandre Courbot wrote:
> Non-generic, non-inlined functions of the `zerocopy` crate are only
> codegen'd into `zerocopy.o`, with their symbols currently not exported,
> making them unavailable to loadable modules.
>
> This can break e.g. nova-core built as a module when
> `CONFIG_CC_OPTIMIZE_FOR_SIZE=y`:
>
> ERROR: modpost: "_RNvMNtCs5wX7wwEUCR9_8zerocopy6layoutNtB2_8SizeInfo24try_to_nonzero_elem_size" [drivers/gpu/nova-core.ko] undefined!
> ERROR: modpost: "_RNvNtCs5wX7wwEUCR9_8zerocopy4util18padding_needed_for" [drivers/gpu/nova-core.ko] undefined!
It looks to me that this should be done by fixing zerocopy.
Both these functions should be marked as `#[inline]`. I would expect zerocopy.o
to be having no .text.
Instead of exporting this, I would vouch for going to another extreme --
completely leave zerocopy.o unlinked, so we catch cases where code is actually
generated.
Best,
Gary
>
> Fix this by generating and including exports for `zerocopy.o`, similarly
> to what is already done for `kernel.o`. All defined symbols (~12 in
> total) are exported since the compiler gives no guarantee as to which
> functions are codegen'd.
>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
> My `CONFIG_CC_OPTIMIZE_FOR_SIZE=y` config is uncovering the most
> interesting bugs. :) This one was revealed after applying [1].
>
> I am not a build system expert at all, so be aware that the patch is
> mostly mimicking what I am seeing for the kernel crate and there might
> be a better way.
>
> [1] https://lore.kernel.org/20260702120324.40388-4-niyudi.honda@gmail.com
> ---
> rust/Makefile | 4 ++++
> rust/exports.c | 1 +
> 2 files changed, 5 insertions(+)
next prev parent reply other threads:[~2026-07-08 11:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 10:37 [PATCH] rust: export zerocopy symbols to modules Alexandre Courbot
2026-07-08 10:50 ` Miguel Ojeda
2026-07-08 11:34 ` Gary Guo [this message]
2026-07-08 11:37 ` Miguel Ojeda
[not found] ` <CAPvrYMF3L0x5PBJk2TnSPyi0Lci2H0vGBu6QS_Rm4XFQtTV6mw@mail.gmail.com>
2026-07-08 16:23 ` Miguel Ojeda
2026-07-08 11:51 ` Gary Guo
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=DJT5P43GJ9MT.2527G7CFCEW46@garyguo.net \
--to=gary@garyguo.net \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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