* [PATCH v2] rust: macros: fix `make rusttest` build on macOS
@ 2025-02-10 14:51 Tamir Duberstein
2025-03-23 22:38 ` Miguel Ojeda
0 siblings, 1 reply; 2+ messages in thread
From: Tamir Duberstein @ 2025-02-10 14:51 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich
Cc: rust-for-linux, linux-kernel, Tamir Duberstein
Do not emit `#[link_section = ".modinfo"]` on macOS (i.e. when building
userspace tests); .modinfo is not a legal section specifier in mach-o.
Before this change tests failed to compile:
---- ../rust/macros/lib.rs - module (line 66) stdout ----
rustc-LLVM ERROR: Global variable '_ZN8rust_out13__module_init13__module_init27__MY_DEVICE_DRIVER_MODULE_017h141f80536770e0d4E' has an invalid section specifier '.modinfo': mach-o section specifier requires a segment and section separated by a comma.
Couldn't compile the test.
---- ../rust/macros/lib.rs - module (line 33) stdout ----
rustc-LLVM ERROR: Global variable '_ZN8rust_out13__module_init13__module_init20__MY_KERNEL_MODULE_017h5d79189564b41e07E' has an invalid section specifier '.modinfo': mach-o section specifier requires a segment and section separated by a comma.
Couldn't compile the test.
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
---
Changes in v2:
- Drop patch: "rust: macros: improve panic messages".
- Rebase on v6.14-rc2.
- Link to v1: https://lore.kernel.org/r/20250207-macros-section-v1-0-8f018cb05a20@gmail.com
---
rust/macros/module.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/macros/module.rs b/rust/macros/module.rs
index cdf94f4982df..56f746be4ab7 100644
--- a/rust/macros/module.rs
+++ b/rust/macros/module.rs
@@ -56,7 +56,7 @@ fn emit_base(&mut self, field: &str, content: &str, builtin: bool) {
"
{cfg}
#[doc(hidden)]
- #[link_section = \".modinfo\"]
+ #[cfg_attr(not(target_os = \"macos\"), link_section = \".modinfo\")]
#[used]
pub static __{module}_{counter}: [u8; {length}] = *{string};
",
---
base-commit: a64dcfb451e254085a7daee5fe51bf22959d52d3
change-id: 20250207-macros-section-f7cddc7bbdea
Best regards,
--
Tamir Duberstein <tamird@gmail.com>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] rust: macros: fix `make rusttest` build on macOS
2025-02-10 14:51 [PATCH v2] rust: macros: fix `make rusttest` build on macOS Tamir Duberstein
@ 2025-03-23 22:38 ` Miguel Ojeda
0 siblings, 0 replies; 2+ messages in thread
From: Miguel Ojeda @ 2025-03-23 22:38 UTC (permalink / raw)
To: Tamir Duberstein
Cc: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kernel
On Mon, Feb 10, 2025 at 3:51 PM Tamir Duberstein <tamird@gmail.com> wrote:
>
> Do not emit `#[link_section = ".modinfo"]` on macOS (i.e. when building
> userspace tests); .modinfo is not a legal section specifier in mach-o.
>
> Before this change tests failed to compile:
>
> ---- ../rust/macros/lib.rs - module (line 66) stdout ----
> rustc-LLVM ERROR: Global variable '_ZN8rust_out13__module_init13__module_init27__MY_DEVICE_DRIVER_MODULE_017h141f80536770e0d4E' has an invalid section specifier '.modinfo': mach-o section specifier requires a segment and section separated by a comma.
> Couldn't compile the test.
> ---- ../rust/macros/lib.rs - module (line 33) stdout ----
> rustc-LLVM ERROR: Global variable '_ZN8rust_out13__module_init13__module_init20__MY_KERNEL_MODULE_017h5d79189564b41e07E' has an invalid section specifier '.modinfo': mach-o section specifier requires a segment and section separated by a comma.
> Couldn't compile the test.
>
> Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Applied to `rust-next` -- thanks!
Given the `cfg_attr`, I think this should not change/break anything
non-macOS we have, so I think it should be safe to apply.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-23 22:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-10 14:51 [PATCH v2] rust: macros: fix `make rusttest` build on macOS Tamir Duberstein
2025-03-23 22:38 ` Miguel Ojeda
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.