[cfe-dev] COM ABI support?

Reid Kleckner rnk at google.com
Thu Jul 11 07:05:25 PDT 2013


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130711/cf556988/attachment.html>


More information about the cfe-dev mailing list