Rust for Linux List
 help / color / mirror / Atom feed
From: Giuliano Procida <gprocida@google.com>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	rust-for-linux@vger.kernel.org,
	"Alice Ryhl" <aliceryhl@google.com>,
	"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>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	linux-modules@vger.kernel.org,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	"Petr Pavlu" <petr.pavlu@suse.com>,
	"Daniel Gomez" <da.gomez@kernel.org>,
	"Sami Tolvanen" <samitolvanen@google.com>,
	"Aaron Tomlin" <atomlin@atomlin.com>,
	"Giuliano Procida" <gprocida@google.com>
Subject: [PATCH v5 3/4] gpu: nova-core: convert nova_core_exports.c to assembly
Date: Thu, 12 Nov 2026 12:15:11 +0000	[thread overview]
Message-ID: <20261112121512.1670347-4-gprocida@google.com> (raw)
In-Reply-To: <20261112121512.1670347-1-gprocida@google.com>

Like `rust/exports.c` before it, `nova_core_exports.c` defined
`EXPORT_SYMBOL_RUST_GPL(sym)` with `extern int sym;` so that it could
invoke the C `EXPORT_SYMBOL_GPL(sym)` macro. This emitted bogus `int`
DWARF debug information in `nova_core_exports.o` and `nova-core.ko` for
every exported Rust symbol, conflicting with the DWARF types emitted by
`rustc`.

Convert `nova_core_exports.c` to `nova_core_exports.S`, emit
`EXPORT_SYMBOL_GPL(sym)` directly in `exports_nova_core_generated.h`
and switch the include path and `MODVERSIONS` symbol-versioning hook in
`drivers/gpu/Makefile` from the `.c` rules (`CFLAGS_*` /
`cmd_gensymtypes_c`) to the `.S` rules (`AFLAGS_*` /
`cmd_gensymtypes_S`).

Also set `private cmd_gen_symversions_S = $(call gen_symversions,S)`
under `CONFIG_MODVERSIONS`. Kbuild normally defines
`cmd_gen_symversions_S` only under `CONFIG_ASM_MODVERSIONS` (which
requires `<asm/asm-prototypes.h>` and is not selected on 32-bit `arm`),
whereas `nova_core_exports.o` generates CRCs directly from `nova_core.o`
via `gendwarfksyms` without needing `<asm/asm-prototypes.h>`. Although
`NOVA_CORE` currently depends on `64BIT`, keeping the `MODVERSIONS`
override self-contained avoids an implicit `CONFIG_ASM_MODVERSIONS`
dependency if `64BIT` is ever relaxed or the pattern is reused by
another Rust module.

This removes the last definition and use of `EXPORT_SYMBOL_RUST_GPL`.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 drivers/gpu/Makefile                                  | 11 ++++++-----
 .../{nova_core_exports.c => nova_core_exports.S}      |  8 +++-----
 2 files changed, 9 insertions(+), 10 deletions(-)
 rename drivers/gpu/nova-core/{nova_core_exports.c => nova_core_exports.S} (62%)

diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile
index e372fc02139f..49205525d2a5 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -36,7 +36,7 @@ rust_needed_exports = \
 
 quiet_cmd_exports = EXPORTS $@
       cmd_exports = \
-	$(call rust_needed_exports,$<,$(nova-core-export-deps),EXPORT_SYMBOL_RUST_GPL(%s);\n) > $@
+	$(call rust_needed_exports,$<,$(nova-core-export-deps),EXPORT_SYMBOL_GPL(%s)\n) > $@
 
 $(obj)/nova-core/exports_nova_core_generated.h: $(obj)/nova-core/nova_core.o $(nova-core-export-deps) FORCE
 	$(call if_changed,exports)
@@ -44,12 +44,13 @@ $(obj)/nova-core/exports_nova_core_generated.h: $(obj)/nova-core/nova_core.o $(n
 targets += nova-core/exports_nova_core_generated.h
 
 $(obj)/nova-core/nova_core_exports.o: $(obj)/nova-core/exports_nova_core_generated.h
-CFLAGS_nova-core/nova_core_exports.o := -I $(objtree)/$(obj)/nova-core
+AFLAGS_nova-core/nova_core_exports.o := -I $(objtree)/$(obj)/nova-core
 
 ifdef CONFIG_MODVERSIONS
-# The C export shim declares Rust symbols as `extern int`, so reuse its export
-# list but generate symbol CRCs from the Rust object instead of the shim's DWARF.
-$(obj)/nova-core/nova_core_exports.o: private cmd_gensymtypes_c = \
+# The assembly export shim has no DWARF type info for Rust symbols, so reuse
+# its export list but generate symbol CRCs from the Rust object.
+$(obj)/nova-core/nova_core_exports.o: private cmd_gen_symversions_S = $(call gen_symversions,S)
+$(obj)/nova-core/nova_core_exports.o: private cmd_gensymtypes_S = \
 	$(call getexportsymbols,\1) | \
 	$(objtree)/scripts/gendwarfksyms/gendwarfksyms \
 		$(if $(KBUILD_GENDWARFKSYMS_STABLE), --stable) \
diff --git a/drivers/gpu/nova-core/nova_core_exports.c b/drivers/gpu/nova-core/nova_core_exports.S
similarity index 62%
rename from drivers/gpu/nova-core/nova_core_exports.c
rename to drivers/gpu/nova-core/nova_core_exports.S
index 6e80ca9792ee..90a9f709ed38 100644
--- a/drivers/gpu/nova-core/nova_core_exports.c
+++ b/drivers/gpu/nova-core/nova_core_exports.S
@@ -1,7 +1,7 @@
-// SPDX-License-Identifier: GPL-2.0
-// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
-
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
+ * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+ *
  * Exports Rust symbols from the `nova_core` crate for use by dependent modules.
  *
  * This is a workaround until the build system supports Rust cross-module
@@ -10,6 +10,4 @@
 
 #include <linux/export.h>
 
-#define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
-
 #include "exports_nova_core_generated.h"
-- 
2.56.0.567.gdb80ae8cd5-goog


  parent reply	other threads:[~2026-11-12 12:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 12:15 [PATCH v5 0/4] clean up EXPORT_SYMBOL_RUST_GPL Giuliano Procida
2026-11-12 12:15 ` [PATCH v5 1/4] kbuild: respect skip_gendwarfksyms in cmd_gensymtypes_S Giuliano Procida
2026-11-12 12:15 ` [PATCH v5 2/4] rust: convert exports.c to assembly Giuliano Procida
2026-11-12 14:20   ` Miguel Ojeda
2026-11-12 12:15 ` Giuliano Procida [this message]
2026-11-12 12:15 ` [PATCH v5 4/4] scripts/sbom: update rust export macro in nm parser test Giuliano Procida
2026-11-12 12:21 ` [PATCH v5 0/4] clean up EXPORT_SYMBOL_RUST_GPL Giuliano Procida

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=20261112121512.1670347-4-gprocida@google.com \
    --to=gprocida@google.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=atomlin@atomlin.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=da.gomez@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=linux-modules@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=ojeda@kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=samitolvanen@google.com \
    --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