This is an archive of the discontinued LLVM Phabricator instance.

[libcxxabi] Fix forced_unwind3.pass.cpp compilation error
ClosedPublic

Authored by aaronpuchert on Aug 29 2022, 11:05 AM.

Details

Summary

Under some circumstances there is no struct _Unwind_Exception, it's just
an alias to another struct. This would result in an error like this:

libcxxabi/test/forced_unwind3.pass.cpp:50:77: error: typedef '_Unwind_Exception' cannot be referenced with a struct specifier

static _Unwind_Reason_Code stop(int, _Unwind_Action actions, type, struct _Unwind_Exception*, struct _Unwind_Context*,
                                                                          ^

<...>/lib/clang/15.0.0/include/unwind.h:68:38: note: declared here
typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */

^

This seems to have been an issue since the test was first added in
D109856, except that it didn't surface with Clang 14 because the code
is filtered out by the preprocessor if __clang_major__ < 15.

Diff Detail

Event Timeline

aaronpuchert created this revision.Aug 29 2022, 11:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2022, 11:05 AM
aaronpuchert requested review of this revision.Aug 29 2022, 11:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2022, 11:05 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
mstorsjo accepted this revision.Aug 29 2022, 12:07 PM

LGTM (but apparently this needs a libc++abi code owner to sign off of the change too).

If you care to share, it'd be interesting to know under what circumstances you end up with no struct definition.

If you care to share, it'd be interesting to know under what circumstances you end up with no struct definition.

It came up when packaging the upcoming LLVM 15 for an armv7hl-suse-linux-gnueabihf target. In clang/lib/Headers/unwind.h we have this:

#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || \
                          defined(__ARM_DWARF_EH__) || defined(__SEH__))
struct _Unwind_Control_Block;
typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */
#else
struct _Unwind_Exception;
typedef struct _Unwind_Exception _Unwind_Exception;
#endif

Of course we have __arm__, and apparently neither __USING_SJLJ_EXCEPTIONS__, __ARM_DWARF_EH__, nor __SEH__. The latter is unsurprising, for the other two I can only hope they're right.

I didn't observe any test failure on aarch64, and I can't say yet whether it happens on arm6hl (or actually it seems we use armv6kz), because that has more serious issues right now.

If you care to share, it'd be interesting to know under what circumstances you end up with no struct definition.

It came up when packaging the upcoming LLVM 15 for an armv7hl-suse-linux-gnueabihf target. In clang/lib/Headers/unwind.h we have this:

#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) || \
                          defined(__ARM_DWARF_EH__) || defined(__SEH__))
struct _Unwind_Control_Block;
typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */
#else
struct _Unwind_Exception;
typedef struct _Unwind_Exception _Unwind_Exception;
#endif

Of course we have __arm__, and apparently neither __USING_SJLJ_EXCEPTIONS__, __ARM_DWARF_EH__, nor __SEH__. The latter is unsurprising, for the other two I can only hope they're right.

Right, ARM on ELF platforms (at least Linux) usually use the ARM EHABI format, which usually has got a separate, exceptional codepath throughout most unwinding routines. Thanks!

danielkiss accepted this revision.Aug 31 2022, 7:46 AM
ldionne accepted this revision.Sep 9 2022, 6:41 AM
This revision is now accepted and ready to land.Sep 9 2022, 6:41 AM