From: "Alexandre Courbot" <acourbot@nvidia.com>
To: "Joel Fernandes" <joelagnelf@nvidia.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nicolas Schier" <nsc@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>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"John Hubbard" <jhubbard@nvidia.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Timur Tabi" <ttabi@nvidia.com>, "Zhi Wang" <zhiw@nvidia.com>,
"Eliot Courtney" <ecourtney@nvidia.com>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org, nova-gpu@lists.linux.dev,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 4/7] gpu: nova-core: export Rust symbols for dependent modules
Date: Fri, 01 May 2026 12:30:09 +0900 [thread overview]
Message-ID: <DI70T742B4GZ.1DQ9DK7AKDZRX@nvidia.com> (raw)
In-Reply-To: <7a33e348-4a08-4f80-aa6e-c684b4d7f1c6@nvidia.com>
On Fri May 1, 2026 at 12:22 AM JST, Joel Fernandes wrote:
>
> Reviewed-by: Joel Fernandes <joelagnelf@nvidia.com>
> One comment below:
>
> On 4/30/2026 10:55 AM, Alexandre Courbot wrote:
>> Export `nova-core`'s Rust symbols so that other loadable modules,
>> particularly `nova-drm`, can resolve references to `nova-core` at
>> runtime.
>>
>> This is done by generating declarations and `EXPORT_SYMBOL_GPL()` calls
>> for Rust global text symbols using `nm` and compiling them into the
>> module as `nova_core_exports.o`.
>>
>> This is a workaround until the build system supports Rust cross-crate
>> dependencies natively.
>>
>> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
>> ---
>> drivers/gpu/nova-core/Makefile | 22 +++++++++++++++++++++-
>> drivers/gpu/nova-core/nova_core_exports.c | 11 +++++++++++
>> 2 files changed, 32 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/nova-core/Makefile b/drivers/gpu/nova-core/Makefile
>> index 1f794baadc86..f9aaf19f2477 100644
>> --- a/drivers/gpu/nova-core/Makefile
>> +++ b/drivers/gpu/nova-core/Makefile
>> @@ -2,4 +2,24 @@
>>
>> obj-$(CONFIG_NOVA_CORE) += nova-core.o
>>
>> -nova-core-y := nova_core.o
>> +nova-core-y := nova_core.o nova_core_exports.o
>> +
>> +# Export Rust symbols so dependent modules can use them at runtime.
>> +#
>> +# This is a workaround until the build system supports Rust cross-module
>> +# dependencies natively.
>> +# Kbuild uses Rust v0 mangling, whose symbols start with "_R".
>> +rust_exports = \
>> + $(NM) -p --defined-only $(1) | \
>> + awk '$$2 == "T" && $$3 ~ /^_R/ { \
>> + printf "extern void %s(void); EXPORT_SYMBOL_GPL(%s);\n", $$3, $$3 \
>> + }'
>
> I am curious (in a fun way) how this (Or Miguel's later approach) will work with
> generics. I don't think we have such use cases but suppose a module has a
> function foo<T> which is expected to be called externally outside the module.
> Suppose the module itself does not call foo internally.
>
> How does the rust compiler know that this function can be called externally if
> it resolves to no callers within the translation unit?
>
> Further, as a result, how does the above extern get emitted then if foo never
> ended up in the object?
>
> Probably Miguel's future infrastructure will address this? If so, probably the
> limitation of the above approach should be called out in the code comments and
> commit message.
Short version: it should Just Work (c). The next patch of the series
generates the metadata of the `nova-core` crate, which contains the MIR
representation of all generic elements. If `nova-drm` needs to
monomorphize some generic code, it will do it from that representation -
thus an export of the symbol is not needed.
IIUC this is how inter-crate generics are handled in Rust, so this is
also the way the kernel is also expected to do.
next prev parent reply other threads:[~2026-05-01 3:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-30 14:55 [PATCH 0/7] gpu: drm: nova: enable calling into nova-core Alexandre Courbot
2026-04-30 14:55 ` [PATCH 1/7] scripts: modpost: detect and report truncated buf_printf() output Alexandre Courbot
2026-04-30 14:55 ` [PATCH 2/7] scripts: modpost: increase buf_printf's buffer size Alexandre Courbot
2026-05-01 13:02 ` Gary Guo
2026-05-01 15:31 ` Miguel Ojeda
2026-04-30 14:55 ` [PATCH 3/7] gpu: nova-core: rename module from nova_core to nova-core Alexandre Courbot
2026-04-30 15:07 ` Joel Fernandes
2026-05-01 3:25 ` Alexandre Courbot
2026-05-01 10:38 ` John Hubbard
2026-05-01 12:31 ` Danilo Krummrich
2026-04-30 14:55 ` [PATCH 4/7] gpu: nova-core: export Rust symbols for dependent modules Alexandre Courbot
2026-04-30 15:22 ` Joel Fernandes
2026-05-01 3:30 ` Alexandre Courbot [this message]
2026-05-01 10:24 ` Miguel Ojeda
2026-04-30 14:55 ` [PATCH 5/7] gpu: nova-core: emit Rust metadata " Alexandre Courbot
2026-04-30 14:55 ` [PATCH 6/7] gpu: drm: nova: build after nova-core metadata Alexandre Courbot
2026-04-30 14:55 ` [PATCH POC 7/7] drm: nova: demonstrate interaction with nova-core Alexandre Courbot
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=DI70T742B4GZ.1DQ9DK7AKDZRX@nvidia.com \
--to=acourbot@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=apopple@nvidia.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=jhubbard@nvidia.com \
--cc=joelagnelf@nvidia.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=nathan@kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=nsc@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
--cc=ttabi@nvidia.com \
--cc=zhiw@nvidia.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