[PATCH] D52840: Include Python binding tests in CMake rules

Ulrich Weigand via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 15 11:39:44 PDT 2018


uweigand added a comment.

In https://reviews.llvm.org/D52840#1265615, @mgorny wrote:

> The first one seems to indicate that your `libclang.so` is broken in release mode (optimization error?). The second one is correct (some of the tests test for errors, and apparently don't silence the messages).


Ok, thanks for the clarification on the second point.

As to the first issue, it turned out to be more complicated.  The wrong value results from this call in CursorVisitor::Visit

  switch (Visitor(Cursor, Parent, ClientData)) {

This is a callback routine passed in from the caller, which in the case of the Python bindings means that an FFI closure is being called.

Now, due to a historical quirk in the FFI ABI, return values of integral type smaller than the register word size must be passed as the special "ffi_arg" type when using FFI (either for calls or for closures).  It seems the Python 2.7 code that interfaces with FFI does not correctly respect this.  As a result, it seems that when the closure returns a 32-bit value, it is not properly extended and the high bits of the return register contain garbage.

But that violates our ABI, which requires extension to full register size.   And it seems the clang code, when built with optimization, does indeed rely on that ABI guarantee.

So there's a bug in Python (or depending on how you want to look at it, in libffi -- that part of the interface has also long been under-documented unfortunately), which hits on our platform.  I'll see if I can do anything about that, but for now we'll probably want to disable those tests on SystemZ.


Repository:
  rC Clang

https://reviews.llvm.org/D52840





More information about the cfe-commits mailing list