summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@gmail.com>2025-02-10 09:51:07 -0500
committerMiguel Ojeda <ojeda@kernel.org>2025-03-23 22:14:32 +0100
commita0b539ad369fe434fe488faf92d4ae770a27a90f (patch)
tree78f09dccc364e9c2d230c2606d5ff2e63dbaff65 /rust
parent2a571248dfa9d1ebac9db4564472b3dec157c99f (diff)
rust: macros: fix `make rusttest` build on macOS
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> Link: https://lore.kernel.org/r/20250210-macros-section-v2-1-3bb9ff44b969@gmail.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'rust')
-rw-r--r--rust/macros/module.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/rust/macros/module.rs b/rust/macros/module.rs
index 46f20682a7a9..8ab4e1f3eb45 100644
--- a/rust/macros/module.rs
+++ b/rust/macros/module.rs
@@ -56,7 +56,7 @@ impl<'a> ModInfoBuilder<'a> {
"
{cfg}
#[doc(hidden)]
- #[link_section = \".modinfo\"]
+ #[cfg_attr(not(target_os = \"macos\"), link_section = \".modinfo\")]
#[used]
pub static __{module}_{counter}: [u8; {length}] = *{string};
",