Skip to content

Commit a0b539a

Browse files
tamirdojeda
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 2a57124 commit a0b539a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

rust/macros/module.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'a> ModInfoBuilder<'a> {
5656
"
5757
{cfg}
5858
#[doc(hidden)]
59-
#[link_section = \".modinfo\"]
59+
#[cfg_attr(not(target_os = \"macos\"), link_section = \".modinfo\")]
6060
#[used]
6161
pub static __{module}_{counter}: [u8; {length}] = *{string};
6262
",

0 commit comments

Comments
 (0)