* [PATCH v3 0/2] clean up EXPORT_SYMBOL_RUST_GPL
2026-10-22 13:46 ` [PATCH v2 0/2] clean up EXPORT_SYMBOL_RUST_GPL Giuliano Procida
@ 2026-11-03 12:58 ` Giuliano Procida
2026-11-03 12:58 ` [PATCH v3 1/2] rust: move EXPORT_SYMBOL_RUST_GPL to include/linux/export.h Giuliano Procida
2026-11-03 12:58 ` [PATCH v3 " Giuliano Procida
2 siblings, 0 replies; 17+ messages in thread
From: Giuliano Procida @ 2026-11-03 12:58 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Miguel Ojeda, rust-for-linux, Alice Ryhl, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, linux-modules,
Luis Chamberlain, Petr Pavlu, Daniel Gomez, Sami Tolvanen,
Aaron Tomlin, Giuliano Procida
Move EXPORT_SYMBOL_RUST_GPL definitions into linux/export.h and
prevent the emission of bogus type information for Rust symbols.
Addressing Sashiko review comments, the first commit now ensures the
moves do not trigger warnings from scripts/misc-check about missing
symbol exports.
Giuliano Procida (2):
rust: move EXPORT_SYMBOL_RUST_GPL to include/linux/export.h
rust: exports: emit ___EXPORT_SYMBOL without C declarations
drivers/gpu/Makefile | 4 ++--
drivers/gpu/nova-core/nova_core_exports.c | 5 ++---
include/linux/export.h | 14 ++++++++++++++
rust/exports.c | 12 +-----------
scripts/misc-check | 4 ++--
5 files changed, 21 insertions(+), 18 deletions(-)
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 1/2] rust: move EXPORT_SYMBOL_RUST_GPL to include/linux/export.h
2026-10-22 13:46 ` [PATCH v2 0/2] clean up EXPORT_SYMBOL_RUST_GPL Giuliano Procida
2026-11-03 12:58 ` [PATCH v3 " Giuliano Procida
@ 2026-11-03 12:58 ` Giuliano Procida
2026-11-03 15:57 ` Petr Pavlu
2026-11-03 12:58 ` [PATCH v3 " Giuliano Procida
2 siblings, 1 reply; 17+ messages in thread
From: Giuliano Procida @ 2026-11-03 12:58 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Miguel Ojeda, rust-for-linux, Alice Ryhl, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, linux-modules,
Luis Chamberlain, Petr Pavlu, Daniel Gomez, Sami Tolvanen,
Aaron Tomlin, Giuliano Procida
Move identical definitions of `EXPORT_SYMBOL_RUST_GPL` to
`include/linux/export.h` from:
- `rust/exports.c`
- `drivers/gpu/nova-core/nova_core_exports.c`
Both files already include `<linux/export.h>`.
Update `scripts/misc-check` to recognize `EXPORT_SYMBOL_RUST_GPL()` and
reference it in `nova_core_exports.c`'s header comment so `W=2` builds
do not warn about an unused `<linux/export.h>` include.
Signed-off-by: Giuliano Procida <gprocida@google.com>
---
drivers/gpu/nova-core/nova_core_exports.c | 5 ++---
include/linux/export.h | 13 +++++++++++++
rust/exports.c | 12 +-----------
scripts/misc-check | 4 ++--
4 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/nova-core/nova_core_exports.c b/drivers/gpu/nova-core/nova_core_exports.c
index 6e80ca9792ee..51858f376c7b 100644
--- a/drivers/gpu/nova-core/nova_core_exports.c
+++ b/drivers/gpu/nova-core/nova_core_exports.c
@@ -2,7 +2,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/*
- * Exports Rust symbols from the `nova_core` crate for use by dependent modules.
+ * Exports Rust symbols from the `nova_core` crate for use by dependent modules
+ * via `EXPORT_SYMBOL_RUST_GPL()`.
*
* This is a workaround until the build system supports Rust cross-module
* dependencies natively.
@@ -10,6 +11,4 @@
#include <linux/export.h>
-#define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
-
#include "exports_nova_core_generated.h"
diff --git a/include/linux/export.h b/include/linux/export.h
index a686fd0ba406..4aeb422d86af 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -93,4 +93,17 @@
#define EXPORT_SYMBOL_FOR_MODULES(sym, mods) __EXPORT_SYMBOL(sym, "GPL", "module:" mods)
+/*
+ * A hack to export Rust symbols for loadable modules without having to redo
+ * the entire `EXPORT_SYMBOL_GPL` 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).
+ *
+ * All symbols are exported as GPL-only to guarantee no GPL-only feature is
+ * accidentally exposed.
+ */
+#define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
+
#endif /* _LINUX_EXPORT_H */
diff --git a/rust/exports.c b/rust/exports.c
index 1b52460b0f4e..8b2dd4aa1f92 100644
--- a/rust/exports.c
+++ b/rust/exports.c
@@ -1,20 +1,10 @@
// 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).
- *
- * All symbols are exported as GPL-only to guarantee no GPL-only feature is
- * accidentally exposed.
+ * Export symbols from the `rust/` crates and C helpers for loadable modules.
*/
#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"
diff --git a/scripts/misc-check b/scripts/misc-check
index 40e5a4b01ff4..b39d731cb413 100755
--- a/scripts/misc-check
+++ b/scripts/misc-check
@@ -45,7 +45,7 @@ check_tracked_ignored_files () {
# does not automatically fix it.
check_missing_include_linux_export_h () {
- git -C "${srctree:-.}" grep --files-with-matches -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' \
+ git -C "${srctree:-.}" grep --files-with-matches -E 'EXPORT_SYMBOL((_RUST)?(_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' \
-- '*.[ch]' :^tools/ :^include/linux/export.h |
xargs -r git -C "${srctree:-.}" grep --files-without-match '#include[[:space:]]*<linux/export\.h>' |
xargs -r printf "%s: warning: EXPORT_SYMBOL() is used, but #include <linux/export.h> is missing\n" >&2
@@ -58,7 +58,7 @@ check_unnecessary_include_linux_export_h () {
git -C "${srctree:-.}" grep --files-with-matches '#include[[:space:]]*<linux/export\.h>' \
-- '*.[c]' :^tools/ |
- xargs -r git -C "${srctree:-.}" grep --files-without-match -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' |
+ xargs -r git -C "${srctree:-.}" grep --files-without-match -E 'EXPORT_SYMBOL((_RUST)?(_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' |
xargs -r printf "%s: warning: EXPORT_SYMBOL() is not used, but #include <linux/export.h> is present\n" >&2
}
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH v3 1/2] rust: move EXPORT_SYMBOL_RUST_GPL to include/linux/export.h
2026-11-03 12:58 ` [PATCH v3 1/2] rust: move EXPORT_SYMBOL_RUST_GPL to include/linux/export.h Giuliano Procida
@ 2026-11-03 15:57 ` Petr Pavlu
2026-11-03 16:25 ` Giuliano Procida
0 siblings, 1 reply; 17+ messages in thread
From: Petr Pavlu @ 2026-11-03 15:57 UTC (permalink / raw)
To: Giuliano Procida
Cc: Miguel Ojeda, Miguel Ojeda, rust-for-linux, Alice Ryhl,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Trevor Gross, Danilo Krummrich, Daniel Almeida,
Tamir Duberstein, Alexandre Courbot, Onur Özkan,
linux-modules, Luis Chamberlain, Daniel Gomez, Sami Tolvanen,
Aaron Tomlin
On 11/3/26 1:58 PM, Giuliano Procida wrote:
> diff --git a/scripts/misc-check b/scripts/misc-check
> index 40e5a4b01ff4..b39d731cb413 100755
> --- a/scripts/misc-check
> +++ b/scripts/misc-check
> @@ -45,7 +45,7 @@ check_tracked_ignored_files () {
> # does not automatically fix it.
> check_missing_include_linux_export_h () {
>
> - git -C "${srctree:-.}" grep --files-with-matches -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' \
> + git -C "${srctree:-.}" grep --files-with-matches -E 'EXPORT_SYMBOL((_RUST)?(_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' \
> -- '*.[ch]' :^tools/ :^include/linux/export.h |
> xargs -r git -C "${srctree:-.}" grep --files-without-match '#include[[:space:]]*<linux/export\.h>' |
> xargs -r printf "%s: warning: EXPORT_SYMBOL() is used, but #include <linux/export.h> is missing\n" >&2
> @@ -58,7 +58,7 @@ check_unnecessary_include_linux_export_h () {
>
> git -C "${srctree:-.}" grep --files-with-matches '#include[[:space:]]*<linux/export\.h>' \
> -- '*.[c]' :^tools/ |
> - xargs -r git -C "${srctree:-.}" grep --files-without-match -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' |
> + xargs -r git -C "${srctree:-.}" grep --files-without-match -E 'EXPORT_SYMBOL((_RUST)?(_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' |
> xargs -r printf "%s: warning: EXPORT_SYMBOL() is not used, but #include <linux/export.h> is present\n" >&2
> }
>
This is minor, but the updated pattern matches non-existent
EXPORT_SYMBOL() variants. To preserve the current strict matching, it
should instead be changed to:
EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES|_RUST_GPL)\(.*\)
Alternatively, I think the pattern could be made more permissive in
general, something like:
EXPORT_SYMBOL(_[A-Z_]+)?\(.*\)
This has the advantage of not requiring changes when a variant of
EXPORT_SYMBOL() is added/removed and shouldn't sacrifice any of the
desired functionality.
-- Petr
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH v3 1/2] rust: move EXPORT_SYMBOL_RUST_GPL to include/linux/export.h
2026-11-03 15:57 ` Petr Pavlu
@ 2026-11-03 16:25 ` Giuliano Procida
2026-11-03 16:58 ` [PATCH v4 0/2] clean up EXPORT_SYMBOL_RUST_GPL Giuliano Procida
` (2 more replies)
0 siblings, 3 replies; 17+ messages in thread
From: Giuliano Procida @ 2026-11-03 16:25 UTC (permalink / raw)
To: Petr Pavlu
Cc: Miguel Ojeda, Miguel Ojeda, rust-for-linux, Alice Ryhl,
Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Trevor Gross, Danilo Krummrich, Daniel Almeida,
Tamir Duberstein, Alexandre Courbot, Onur Özkan,
linux-modules, Luis Chamberlain, Daniel Gomez, Sami Tolvanen,
Aaron Tomlin
On Tue, 3 Nov 2026 at 15:57, Petr Pavlu <petr.pavlu@suse.com> wrote:
>
> On 11/3/26 1:58 PM, Giuliano Procida wrote:
> > diff --git a/scripts/misc-check b/scripts/misc-check
> > index 40e5a4b01ff4..b39d731cb413 100755
> > --- a/scripts/misc-check
> > +++ b/scripts/misc-check
> > @@ -45,7 +45,7 @@ check_tracked_ignored_files () {
> > # does not automatically fix it.
> > check_missing_include_linux_export_h () {
> >
> > - git -C "${srctree:-.}" grep --files-with-matches -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' \
> > + git -C "${srctree:-.}" grep --files-with-matches -E 'EXPORT_SYMBOL((_RUST)?(_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' \
> > -- '*.[ch]' :^tools/ :^include/linux/export.h |
> > xargs -r git -C "${srctree:-.}" grep --files-without-match '#include[[:space:]]*<linux/export\.h>' |
> > xargs -r printf "%s: warning: EXPORT_SYMBOL() is used, but #include <linux/export.h> is missing\n" >&2
> > @@ -58,7 +58,7 @@ check_unnecessary_include_linux_export_h () {
> >
> > git -C "${srctree:-.}" grep --files-with-matches '#include[[:space:]]*<linux/export\.h>' \
> > -- '*.[c]' :^tools/ |
> > - xargs -r git -C "${srctree:-.}" grep --files-without-match -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' |
> > + xargs -r git -C "${srctree:-.}" grep --files-without-match -E 'EXPORT_SYMBOL((_RUST)?(_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' |
> > xargs -r printf "%s: warning: EXPORT_SYMBOL() is not used, but #include <linux/export.h> is present\n" >&2
> > }
> >
>
> This is minor, but the updated pattern matches non-existent
> EXPORT_SYMBOL() variants. To preserve the current strict matching, it
> should instead be changed to:
>
> EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES|_RUST_GPL)\(.*\)
I'll take this suggestion which was also my initial thought.
My second thought was that if Linux were ever going to allow non-GPL
or namespaced
Rust symbols, the syntax I came up with would be the best future-proofing.
> Alternatively, I think the pattern could be made more permissive in
> general, something like:
>
> EXPORT_SYMBOL(_[A-Z_]+)?\(.*\)
>
> This has the advantage of not requiring changes when a variant of
> EXPORT_SYMBOL() is added/removed and shouldn't sacrifice any of the
> desired functionality.
AI analysis: Using a permissive regex in check_missing_include_linux_export_h
introduces 81 to 84 false-positive warnings across the kernel.
Things like: EXPORT_SYMBOL_IF_KUNIT, EXPORT_SYMBOL_ACPI_LIB.
> -- Petr
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH v4 0/2] clean up EXPORT_SYMBOL_RUST_GPL
2026-11-03 16:25 ` Giuliano Procida
@ 2026-11-03 16:58 ` Giuliano Procida
2026-11-03 16:58 ` [PATCH v4 1/2] rust: move EXPORT_SYMBOL_RUST_GPL to include/linux/export.h Giuliano Procida
2026-11-03 16:58 ` [PATCH v4 2/2] rust: exports: emit ___EXPORT_SYMBOL without C declarations Giuliano Procida
2 siblings, 0 replies; 17+ messages in thread
From: Giuliano Procida @ 2026-11-03 16:58 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Miguel Ojeda, rust-for-linux, Alice Ryhl, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, linux-modules,
Luis Chamberlain, Petr Pavlu, Daniel Gomez, Sami Tolvanen,
Aaron Tomlin, Giuliano Procida
Move EXPORT_SYMBOL_RUST_GPL definitions into linux/export.h and
prevent the emission of bogus type information for Rust symbols.
Addressing review comments, the first commit now ensures the moves do
not trigger warnings from scripts/misc-check about missing symbol
exports by extending regexes to match EXPORT_SYMBOL_RUST_GPL as well.
Giuliano Procida (2):
rust: move EXPORT_SYMBOL_RUST_GPL to include/linux/export.h
rust: exports: emit ___EXPORT_SYMBOL without C declarations
drivers/gpu/Makefile | 4 ++--
drivers/gpu/nova-core/nova_core_exports.c | 5 ++---
include/linux/export.h | 14 ++++++++++++++
rust/exports.c | 12 +-----------
scripts/misc-check | 4 ++--
5 files changed, 21 insertions(+), 18 deletions(-)
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v4 1/2] rust: move EXPORT_SYMBOL_RUST_GPL to include/linux/export.h
2026-11-03 16:25 ` Giuliano Procida
2026-11-03 16:58 ` [PATCH v4 0/2] clean up EXPORT_SYMBOL_RUST_GPL Giuliano Procida
@ 2026-11-03 16:58 ` Giuliano Procida
2026-11-03 16:58 ` [PATCH v4 2/2] rust: exports: emit ___EXPORT_SYMBOL without C declarations Giuliano Procida
2 siblings, 0 replies; 17+ messages in thread
From: Giuliano Procida @ 2026-11-03 16:58 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Miguel Ojeda, rust-for-linux, Alice Ryhl, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, linux-modules,
Luis Chamberlain, Petr Pavlu, Daniel Gomez, Sami Tolvanen,
Aaron Tomlin, Giuliano Procida
Move identical definitions of `EXPORT_SYMBOL_RUST_GPL` to
`include/linux/export.h` from:
- `rust/exports.c`
- `drivers/gpu/nova-core/nova_core_exports.c`
Both files already include `<linux/export.h>`.
Update `scripts/misc-check` to recognize `EXPORT_SYMBOL_RUST_GPL()` and
reference it in `nova_core_exports.c`'s header comment so `W=2` builds
do not warn about an unused `<linux/export.h>` include.
Signed-off-by: Giuliano Procida <gprocida@google.com>
---
drivers/gpu/nova-core/nova_core_exports.c | 5 ++---
include/linux/export.h | 13 +++++++++++++
rust/exports.c | 12 +-----------
scripts/misc-check | 4 ++--
4 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/nova-core/nova_core_exports.c b/drivers/gpu/nova-core/nova_core_exports.c
index 6e80ca9792ee..51858f376c7b 100644
--- a/drivers/gpu/nova-core/nova_core_exports.c
+++ b/drivers/gpu/nova-core/nova_core_exports.c
@@ -2,7 +2,8 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/*
- * Exports Rust symbols from the `nova_core` crate for use by dependent modules.
+ * Exports Rust symbols from the `nova_core` crate for use by dependent modules
+ * via `EXPORT_SYMBOL_RUST_GPL()`.
*
* This is a workaround until the build system supports Rust cross-module
* dependencies natively.
@@ -10,6 +11,4 @@
#include <linux/export.h>
-#define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
-
#include "exports_nova_core_generated.h"
diff --git a/include/linux/export.h b/include/linux/export.h
index a686fd0ba406..4aeb422d86af 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -93,4 +93,17 @@
#define EXPORT_SYMBOL_FOR_MODULES(sym, mods) __EXPORT_SYMBOL(sym, "GPL", "module:" mods)
+/*
+ * A hack to export Rust symbols for loadable modules without having to redo
+ * the entire `EXPORT_SYMBOL_GPL` 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).
+ *
+ * All symbols are exported as GPL-only to guarantee no GPL-only feature is
+ * accidentally exposed.
+ */
+#define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
+
#endif /* _LINUX_EXPORT_H */
diff --git a/rust/exports.c b/rust/exports.c
index 1b52460b0f4e..8b2dd4aa1f92 100644
--- a/rust/exports.c
+++ b/rust/exports.c
@@ -1,20 +1,10 @@
// 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).
- *
- * All symbols are exported as GPL-only to guarantee no GPL-only feature is
- * accidentally exposed.
+ * Export symbols from the `rust/` crates and C helpers for loadable modules.
*/
#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"
diff --git a/scripts/misc-check b/scripts/misc-check
index 40e5a4b01ff4..bb30247f93de 100755
--- a/scripts/misc-check
+++ b/scripts/misc-check
@@ -45,7 +45,7 @@ check_tracked_ignored_files () {
# does not automatically fix it.
check_missing_include_linux_export_h () {
- git -C "${srctree:-.}" grep --files-with-matches -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' \
+ git -C "${srctree:-.}" grep --files-with-matches -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES|_RUST_GPL)\(.*\)' \
-- '*.[ch]' :^tools/ :^include/linux/export.h |
xargs -r git -C "${srctree:-.}" grep --files-without-match '#include[[:space:]]*<linux/export\.h>' |
xargs -r printf "%s: warning: EXPORT_SYMBOL() is used, but #include <linux/export.h> is missing\n" >&2
@@ -58,7 +58,7 @@ check_unnecessary_include_linux_export_h () {
git -C "${srctree:-.}" grep --files-with-matches '#include[[:space:]]*<linux/export\.h>' \
-- '*.[c]' :^tools/ |
- xargs -r git -C "${srctree:-.}" grep --files-without-match -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES)\(.*\)' |
+ xargs -r git -C "${srctree:-.}" grep --files-without-match -E 'EXPORT_SYMBOL((_NS)?(_GPL)?|_FOR_MODULES|_RUST_GPL)\(.*\)' |
xargs -r printf "%s: warning: EXPORT_SYMBOL() is not used, but #include <linux/export.h> is present\n" >&2
}
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH v4 2/2] rust: exports: emit ___EXPORT_SYMBOL without C declarations
2026-11-03 16:25 ` Giuliano Procida
2026-11-03 16:58 ` [PATCH v4 0/2] clean up EXPORT_SYMBOL_RUST_GPL Giuliano Procida
2026-11-03 16:58 ` [PATCH v4 1/2] rust: move EXPORT_SYMBOL_RUST_GPL to include/linux/export.h Giuliano Procida
@ 2026-11-03 16:58 ` Giuliano Procida
2 siblings, 0 replies; 17+ messages in thread
From: Giuliano Procida @ 2026-11-03 16:58 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Miguel Ojeda, rust-for-linux, Alice Ryhl, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, linux-modules,
Luis Chamberlain, Petr Pavlu, Daniel Gomez, Sami Tolvanen,
Aaron Tomlin, Giuliano Procida
Define `EXPORT_SYMBOL_RUST_GPL(sym)` using `___EXPORT_SYMBOL` directly:
asm(__stringify(___EXPORT_SYMBOL(sym, "GPL", "")))
matching the `__ASSEMBLY__` path.
Previously, `EXPORT_SYMBOL_RUST_GPL(sym)` declared `extern int sym;` so
that it could invoke `EXPORT_SYMBOL_GPL(sym)`, which required `sym` to
be a declared C identifier for `typeof(sym)`, `__ADDRESSABLE(sym)`, and
(when `CONFIG_GENDWARFKSYMS` is enabled) `__GENDWARFKSYMS_EXPORT(sym)`.
This resulted in the compiler emitting DWARF debug information in
`rust/exports.o` and `drivers/gpu/nova-core/nova_core_exports.o`
describing every exported Rust symbol, functions and data alike, as a C
`int` variable.
Although `rust/Makefile` sets `skip_gendwarfksyms = 1` on `exports.o`
and `drivers/gpu/Makefile` runs `gendwarfksyms` on `nova_core.o` rather
than `nova_core_exports.o`, the bogus `int` DWARF entries were still
present in `vmlinux` and `nova-core.ko`, where they conflicted with the
true DWARF types emitted by `rustc` and confused DWARF consumers such as
debuggers and ABI analysis tools.
Omitting the C-level wrappers from `__EXPORT_SYMBOL` is safe because:
- `__GENDWARFKSYMS_EXPORT(sym)` is unneeded because `gendwarfksyms` runs
directly on the defining Rust and helper object files rather than on
`rust/exports.o` or `nova_core_exports.o`.
- `extern int sym;`, `extern typeof(sym) sym;`, and `__ADDRESSABLE(sym)`
have no effect in `rust/exports.c` or `nova_core_exports.c`: the
symbols are already emitted in separate translation units (scraped via
`nm --defined-only`), the fake `extern int` declaration never produced
kCFI function type IDs, and `___EXPORT_SYMBOL` already emits a
`.quad`/`.long` reference to `sym` in `.export_symbol` that satisfies
both ELF linking and LTO module-asm symbol resolution.
- `DEFAULT_SYMBOL_NAMESPACE`, `__DISABLE_EXPORTS`, and `__GENKSYMS__`
are not used by `rust/exports.c` or `nova_core_exports.c`.
Signed-off-by: Giuliano Procida <gprocida@google.com>
---
drivers/gpu/Makefile | 4 ++--
include/linux/export.h | 9 +++++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile
index e372fc02139f..1269ce862ad2 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -47,8 +47,8 @@ $(obj)/nova-core/nova_core_exports.o: $(obj)/nova-core/exports_nova_core_generat
CFLAGS_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.
+# The C 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_gensymtypes_c = \
$(call getexportsymbols,\1) | \
$(objtree)/scripts/gendwarfksyms/gendwarfksyms \
diff --git a/include/linux/export.h b/include/linux/export.h
index 4aeb422d86af..2a0362cc54e1 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -94,16 +94,17 @@
#define EXPORT_SYMBOL_FOR_MODULES(sym, mods) __EXPORT_SYMBOL(sym, "GPL", "module:" mods)
/*
- * A hack to export Rust symbols for loadable modules without having to redo
- * the entire `EXPORT_SYMBOL_GPL` logic in Rust.
+ * Export Rust symbols for loadable modules without having to redo the entire
+ * `EXPORT_SYMBOL_GPL` 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).
*
* All symbols are exported as GPL-only to guarantee no GPL-only feature is
- * accidentally exposed.
+ * accidentally exposed. There is no support for symbol namespaces.
*/
-#define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
+#define EXPORT_SYMBOL_RUST_GPL(sym) \
+ asm(__stringify(___EXPORT_SYMBOL(sym, "GPL", "")))
#endif /* _LINUX_EXPORT_H */
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 2/2] rust: exports: emit ___EXPORT_SYMBOL without C declarations
2026-10-22 13:46 ` [PATCH v2 0/2] clean up EXPORT_SYMBOL_RUST_GPL Giuliano Procida
2026-11-03 12:58 ` [PATCH v3 " Giuliano Procida
2026-11-03 12:58 ` [PATCH v3 1/2] rust: move EXPORT_SYMBOL_RUST_GPL to include/linux/export.h Giuliano Procida
@ 2026-11-03 12:58 ` Giuliano Procida
2 siblings, 0 replies; 17+ messages in thread
From: Giuliano Procida @ 2026-11-03 12:58 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Miguel Ojeda, rust-for-linux, Alice Ryhl, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, linux-modules,
Luis Chamberlain, Petr Pavlu, Daniel Gomez, Sami Tolvanen,
Aaron Tomlin, Giuliano Procida
Define `EXPORT_SYMBOL_RUST_GPL(sym)` using `___EXPORT_SYMBOL` directly:
asm(__stringify(___EXPORT_SYMBOL(sym, "GPL", "")))
matching the `__ASSEMBLY__` path.
Previously, `EXPORT_SYMBOL_RUST_GPL(sym)` declared `extern int sym;` so
that it could invoke `EXPORT_SYMBOL_GPL(sym)`, which required `sym` to
be a declared C identifier for `typeof(sym)`, `__ADDRESSABLE(sym)`, and
(when `CONFIG_GENDWARFKSYMS` is enabled) `__GENDWARFKSYMS_EXPORT(sym)`.
This resulted in the compiler emitting DWARF debug information in
`rust/exports.o` and `drivers/gpu/nova-core/nova_core_exports.o`
describing every exported Rust symbol, functions and data alike, as a C
`int` variable.
Although `rust/Makefile` sets `skip_gendwarfksyms = 1` on `exports.o`
and `drivers/gpu/Makefile` runs `gendwarfksyms` on `nova_core.o` rather
than `nova_core_exports.o`, the bogus `int` DWARF entries were still
present in `vmlinux` and `nova-core.ko`, where they conflicted with the
true DWARF types emitted by `rustc` and confused DWARF consumers such as
debuggers and ABI analysis tools.
Omitting the C-level wrappers from `__EXPORT_SYMBOL` is safe because:
- `__GENDWARFKSYMS_EXPORT(sym)` is unneeded because `gendwarfksyms` runs
directly on the defining Rust and helper object files rather than on
`rust/exports.o` or `nova_core_exports.o`.
- `extern int sym;`, `extern typeof(sym) sym;`, and `__ADDRESSABLE(sym)`
have no effect in `rust/exports.c` or `nova_core_exports.c`: the
symbols are already emitted in separate translation units (scraped via
`nm --defined-only`), the fake `extern int` declaration never produced
kCFI function type IDs, and `___EXPORT_SYMBOL` already emits a
`.quad`/`.long` reference to `sym` in `.export_symbol` that satisfies
both ELF linking and LTO module-asm symbol resolution.
- `DEFAULT_SYMBOL_NAMESPACE`, `__DISABLE_EXPORTS`, and `__GENKSYMS__`
are not used by `rust/exports.c` or `nova_core_exports.c`.
Signed-off-by: Giuliano Procida <gprocida@google.com>
---
drivers/gpu/Makefile | 4 ++--
include/linux/export.h | 9 +++++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile
index e372fc02139f..1269ce862ad2 100644
--- a/drivers/gpu/Makefile
+++ b/drivers/gpu/Makefile
@@ -47,8 +47,8 @@ $(obj)/nova-core/nova_core_exports.o: $(obj)/nova-core/exports_nova_core_generat
CFLAGS_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.
+# The C 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_gensymtypes_c = \
$(call getexportsymbols,\1) | \
$(objtree)/scripts/gendwarfksyms/gendwarfksyms \
diff --git a/include/linux/export.h b/include/linux/export.h
index 4aeb422d86af..2a0362cc54e1 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -94,16 +94,17 @@
#define EXPORT_SYMBOL_FOR_MODULES(sym, mods) __EXPORT_SYMBOL(sym, "GPL", "module:" mods)
/*
- * A hack to export Rust symbols for loadable modules without having to redo
- * the entire `EXPORT_SYMBOL_GPL` logic in Rust.
+ * Export Rust symbols for loadable modules without having to redo the entire
+ * `EXPORT_SYMBOL_GPL` 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).
*
* All symbols are exported as GPL-only to guarantee no GPL-only feature is
- * accidentally exposed.
+ * accidentally exposed. There is no support for symbol namespaces.
*/
-#define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
+#define EXPORT_SYMBOL_RUST_GPL(sym) \
+ asm(__stringify(___EXPORT_SYMBOL(sym, "GPL", "")))
#endif /* _LINUX_EXPORT_H */
--
2.56.0.385.gac671c819a-goog
^ permalink raw reply related [flat|nested] 17+ messages in thread