On Mon, Oct 21, 2024 at 06:35:31PM +0200, Paolo Bonzini wrote: > Date: Mon, 21 Oct 2024 18:35:31 +0200 > From: Paolo Bonzini <pbonz...@redhat.com> > Subject: [PATCH v2 06/13] rust: modernize link_section usage for ELF > platforms > X-Mailer: git-send-email 2.46.2 > > Some newer ABI implementations do not provide .ctors; and while > some linkers rewrite .ctors into .init_array, not all of them do. > Use the newer .init_array ABI, which works more reliably, and > apply it to all non-Apple, non-Windows platforms. > > This is similar to how the ctor crate operates; without this change, > "#[derive(Object)]" does not work on Fedora 41. > > Reviewed-by: Junjie Mao <junjie....@hotmail.com> > Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> > --- > rust/qemu-api-macros/src/lib.rs | 7 +++++-- > rust/qemu-api/src/definitions.rs | 14 ++++++++++---- > 2 files changed, 15 insertions(+), 6 deletions(-) > > diff --git a/rust/qemu-api-macros/src/lib.rs b/rust/qemu-api-macros/src/lib.rs > index 59aba592d9a..70e3f920460 100644 > --- a/rust/qemu-api-macros/src/lib.rs > +++ b/rust/qemu-api-macros/src/lib.rs > @@ -16,8 +16,11 @@ pub fn derive_object(input: TokenStream) -> TokenStream { > let expanded = quote! { > #[allow(non_upper_case_globals)] > #[used] > - #[cfg_attr(target_os = "linux", link_section = ".ctors")] > - #[cfg_attr(target_os = "macos", link_section = > "__DATA,__mod_init_func")] > + #[cfg_attr( > + not(any(target_vendor = "apple", target_os = "windows")),
EMM, "apple" vendor contains macOS, iOS and other variations of iOS. Do we need to consider other OSs besides macOS for now? And it seems that the Rust people don't like "target_vendor = 'apple'". (https://github.com/rust-lang/rust/issues/100343). :-) Otherwise, Reviewed-by: Zhao Liu <zhao1....@intel.com>