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 2/4] rust: convert exports.c to assembly
Date: Thu, 12 Nov 2026 12:15:10 +0000 [thread overview]
Message-ID: <20261112121512.1670347-3-gprocida@google.com> (raw)
In-Reply-To: <20261112121512.1670347-1-gprocida@google.com>
Previously, `rust/exports.c` defined `EXPORT_SYMBOL_RUST_GPL(sym)` with
`extern int sym;` so that it could invoke the C `EXPORT_SYMBOL_GPL(sym)`
macro, which requires `sym` to be a declared C identifier in scope for
`typeof(sym)`, `__ADDRESSABLE(sym)` and `__GENDWARFKSYMS_EXPORT(sym)`.
This caused the C compiler to emit DWARF debug information in
`rust/exports.o` describing every exported Rust and helper symbol,
functions and data alike, as a C `int` variable. Those bogus `int` DWARF
entries ended up in `vmlinux`, conflicting with the true DWARF types
emitted by `rustc` and confusing debuggers and ABI analysis tools.
Convert `rust/exports.c` to `rust/exports.S` and emit
`EXPORT_SYMBOL_GPL(sym)` directly. Under `__ASSEMBLY__`,
`<linux/export.h>` expands `EXPORT_SYMBOL_GPL(sym)` straight to
`___EXPORT_SYMBOL(sym, "GPL", ...)` without requiring symbol
declarations or emitting bogus DWARF entries, while also avoiding a C
compilation step.
Signed-off-by: Giuliano Procida <gprocida@google.com>
---
rust/Makefile | 2 +-
rust/{exports.c => exports.S} | 12 +++++-------
2 files changed, 6 insertions(+), 8 deletions(-)
rename rust/{exports.c => exports.S} (72%)
diff --git a/rust/Makefile b/rust/Makefile
index 0ac9ab28cc2b..2e5f5a84bb24 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -564,7 +564,7 @@ rust_exports = $(NM) -p --defined-only $(1) | awk '$$2~/(T|R|D|B)/ && $$3!~/__(p
quiet_cmd_exports = EXPORTS $@
cmd_exports = \
- $(call rust_exports,$<,"EXPORT_SYMBOL_RUST_GPL(%s);\n") > $@
+ $(call rust_exports,$<,"EXPORT_SYMBOL_GPL(%s)\n") > $@
$(obj)/exports_core_generated.h: $(obj)/core.o FORCE
$(call if_changed,exports)
diff --git a/rust/exports.c b/rust/exports.S
similarity index 72%
rename from rust/exports.c
rename to rust/exports.S
index 1b52460b0f4e..e1a6923081fa 100644
--- a/rust/exports.c
+++ b/rust/exports.S
@@ -1,11 +1,11 @@
-// SPDX-License-Identifier: GPL-2.0
+/* SPDX-License-Identifier: GPL-2.0 */
/*
* A hack to export Rust symbols for loadable modules without having to redo
* the entire `include/linux/export.h` logic in Rust.
*
* This requires Rust's new/future `v0` mangling scheme because the default one
- * ("legacy") uses invalid characters for C identifiers (thus we cannot use the
- * `EXPORT_SYMBOL_*` macros).
+ * ("legacy") uses invalid characters for C identifiers (thus we could not use
+ * the `EXPORT_SYMBOL_*` macros).
*
* All symbols are exported as GPL-only to guarantee no GPL-only feature is
* accidentally exposed.
@@ -13,8 +13,6 @@
#include <linux/export.h>
-#define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
-
#include "exports_core_generated.h"
#include "exports_bindings_generated.h"
#include "exports_kernel_generated.h"
@@ -23,7 +21,7 @@
#include "exports_helpers_generated.h"
#endif
-// For modules using `rust/build_error.rs`.
+/* For modules using `rust/build_error.rs`. */
#ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
-EXPORT_SYMBOL_RUST_GPL(rust_build_error);
+EXPORT_SYMBOL_GPL(rust_build_error)
#endif
--
2.56.0.567.gdb80ae8cd5-goog
next prev 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 ` Giuliano Procida [this message]
2026-11-12 14:20 ` [PATCH v5 2/4] rust: convert exports.c to assembly Miguel Ojeda
2026-11-12 12:15 ` [PATCH v5 3/4] gpu: nova-core: convert nova_core_exports.c " Giuliano Procida
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-3-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