Closed Jascha-N closed 4 years ago
Yeah, not config-specific.
We generate empty vtables always so far. That's because nobody has stopped to figure out what the correct vtable layout is in complex cases, what is the order for the vtable methods (we need to look in the base class chain for that), etc... MSVC and gcc/clang generate different vtable layouts for method overloads, also, as far as I know.
So we generate a dummy pointer-sized member so classes have the correct layout.
We definitely keep track of virtual methods and could attempt to do it (in this case it'd be trivial), but we need to consider all the complex cases too IMO, or at least a way to test that the vtable layout we generate is correct.
@emilio If I were writing Rust bindings to a C++ library which hands out mostly abstract classes with pure virtual methods, would this mean I cannot rely on bindgen to correctly generate the vtables? I was not aware of this by looking at the bindgen book. Would I need resort to writing a C++ wrapper for each of these abstract classes instead, at least until bindgen can properly support them?
If I were writing Rust bindings to a C++ library which hands out mostly abstract classes with pure virtual methods, would this mean I cannot rely on bindgen to correctly generate the vtables? I was not aware of this by looking at the bindgen book. Would I need resort to writing a C++ wrapper for each of these abstract classes instead, at least until bindgen can properly support them?
Yeah, I think that's pretty much it. There's another issue where the difficulties of this are explained (#27).
I think figuring out what's the subset that works properly cross-platform (at least GCC / clang / MSVC) may not be hard, it just requires research and writing tests.
If someone is interested in giving it a shot I'm happy to mentor, but most of the information needed is probably available already from the vtable codegen code.
Let's close this as a dupe of https://github.com/rust-lang/rust-bindgen/issues/27. I think a basic implementation for where there are no overloads should be relatively easy.
bindgen
generates empty vtables when cross-compiling for ARM. I have made a reduced test-case, while leaving in the automatically generated Builder settings.clang
is not able to find the right gcc toolchain so the script manually passes the system include directories (which might be the wrong way to go about?).input.hpp
:Actual
output.rs
:Expected
output.rs
:Builder settings (pretty-printed debug):