[cfe-dev] COM ABI support?
Stephen Lin
swlin at post.harvard.edu
Thu Jul 11 07:09:09 PDT 2013
On Thu, Jul 11, 2013 at 7:05 AM, Reid Kleckner <rnk at google.com> wrote:
> On Thu, Jul 11, 2013 at 9:45 AM, Stephen Lin <swlin at post.harvard.edu> wrote:
>>
>> > I was about to answer the same thing, but hesitated. I know COM avoids
>> > use virtual inheritance, and I think I've heard somebody say it's for
>> > portability.
>> >
>> > But the vtable ABI isn't standardized either, is it? Do all compilers
>> > just happen to implement it the same way?
>> >
>>
>> All compilers that allow C++ to implement COM objects must implement
>> virtual tables (but not, for example, name mangling) in the same way
>> for COM ABI compatibility; I was wondering if Clang did so already or
>> not.
>
>
> Personally, I've never tried and I don't have any test code for this handy.
> Some things that are probably broken that would affect COM:
>
> - Record layout. Warren has a patch for this. One of the big things is the
> alignment of all the non-vfptr fields. These appear to be laid out as
> though there is a parent struct with a vfptr and then an anonymous struct
> containing all the fields. If the object doesn't contain any fields with
> more than pointer alignment, this shouldn't matter.
>
> - Virtual method calls with multiple inheritance. Timur has a patch for
> this. The big change is that there are fewer thunks because the 'this'
> pointer on entry is adjusted to point at the vfptr used to perform the
> dispatch. If you don't implement multiple interfaces, this shouldn't
> matter.
>
> - Outside the scope of COM, things like virtual inheritance and virtual
> destructors are broken still.
>
> Those are some pretty big caveats, so I assume COM interop is broken until
> tested.
Thanks for the color.
Just curious, where do we stand with straight Windows C ABI support?
It seems like, given straight C ABI support, COM interop would be
relatively easy just by reverse engineering the C headers generated by
Microsoft's IDL compiler, right?
I could be wrong and misunderstanding the complexity (also, just
knowing how it works doesn't imply knowing an easy way to implement it
within the structure of Clang's codebase, I understand.)
Stephen
More information about the cfe-dev
mailing list