[cfe-dev] Purpose of -fno-objc-exceptions

John McCall via cfe-dev cfe-dev at lists.llvm.org
Wed Sep 20 19:40:02 PDT 2017


> On Sep 20, 2017, at 4:31 PM, Michael Eisel via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> I've found a 2% reduction in the size of my binary from using the -fno-objc-exceptions flag (I already use -fno-objc-arc-exceptions) for most of the files. I thought it might not be able to propagate an exception through methods in files compiled with this flag, but in my testing I found that that was not case. So I'm curious, what's the tradeoff? Why wouldn't clang just only enable exceptions for files that used "@try", "@finally", "@catch", or "@throw"?

Leaks and crashes.  Even if throwing an exception seems to work, the frames being unwound may have important cleanup actions that are no longer being executed.  For example, it's very important to destroy a __weak variable on the stack when unwinding a frame; not doing so is likely to corrupt the Objective-C runtime.

Also, whether unwinding works at all is very target-specific.

John.



More information about the cfe-dev mailing list