Re: [PATCH v2] rust: macros: fix `make rusttest` build on macOS
From: Miguel Ojeda
Date: Sun Mar 23 2025 - 18:39:05 EST
On Mon, Feb 10, 2025 at 3:51 PM Tamir Duberstein <tamird@xxxxxxxxx> 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@xxxxxxxxx>
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