How to use SJLJ exceptions with clang ?

There support for SJLJ is in the sources but I can’t get clang to recognize any flag to make it actually use these exceptions.

Yaron

sjlj exceptions are only used on arm/darwin. So, no, you cannot enable
them via some flag.

Does it mean that iOS code uses sjlj exceptions? That seems weird and unexpected at a first glance! (at least for someone without ARM insights) Sorry for my ignorance: why are zero cost exceptions not possible on arm?

Bye,
Nicola

sjlj exceptions are only used on arm/darwin. So, no, you cannot enable
them via some flag.

Does it mean that iOS code uses sjlj exceptions?

That's correct.

That seems weird and unexpected at a first glance! (at least for someone without ARM insights) Sorry for my ignorance: why are zero cost exceptions not possible on arm?

I don't know. I can only hazard guesses. :-/

-bw

SjLj is the most space efficient. I am not promoting it though.
-Andy

And the slowest. :slight_smile:

-bw

At the time iOS was first developed, SjLj was the only exception handling mechanism supported by GCC for ARM. I think DWARF unwinding support for ARM may have been added to GCC right around the same time but it didn't arrive quite in time to be adopted for iOS. Changing it after the first release would have been a major ABI break, so we've been stuck with SjLj. Note that the new 64-bit iOS ABI does _not_ use SjLj.

I don't want to criticize Apple's design decisions, especially since this is an
issue from the old "hack on GCC" days, and I know that to
most of those questions you can't answer anyway, but: why don't let, say,
iOS 4-targeted binaries use the new ABI and stick legacy code on a different segment
on fat/universal binaries, and let Xcode do the linking magic? In the round of one
or maybe two years, nobody links to older SDKs anymore anyway. This question
of course applies to any iOS "new feature breaks ABI" issue...

Bye,
Nicola

P.S. Sorry if this question is OT on this list, being iOS specific, but it comes natural
from previous discussions.

For every such decision (in any organization), you must consider the costs and benefits. I suspect that the cost of switching over the ARM platform to DWARF EH wasn't worth the effort (which would have been large). And as Bob said, the SjLj EH is smaller, which is important to mobile devices.

-bw