Skip to content

Bindgen generates unnecessary padding inside nsIDocument on Windows #520

Closed
@upsuper

Description

@upsuper

On my machine, the generated nsIDocument is like this:

    #[repr(C)]
    #[derive(Debug)]
    pub struct nsIDocument {
        pub _base: root::nsINode,
        pub _base_1: root::mozilla::dom::DispatcherTrait,
        pub mDeprecationWarnedAbout: u64,
        pub mDocWarningWarnedAbout: u32,
        pub mSelectorCache: root::nsIDocument_SelectorCache,
        pub __bindgen_padding_0: [u64; 10usize],
        pub mReferrer: root::nsCString,
        pub mLastModified: ::nsstring::nsStringRepr,
        // ...
    }

I see no reason why there needs to be a 80byte padding.

This causes a mismatch between offset from C++ and from Rust (mReferrer's offset is 248 in C++ but 328 in Rust), which leads to servo/servo#15483 on Windows.

It seems that this doesn't happen on Mac or Linux, so --target=x86_64-pc-win32 is probably a necessary condition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions