llvm-mingw icon indicating copy to clipboard operation
llvm-mingw copied to clipboard

How to build a toolchain with SJLJ exceptions?

Open starg2 opened this issue 2 years ago • 1 comments

I'm trying to build a toolchain which uses SJLJ exceptions on i686 (instead of dwarf).

I tried reverting f9ce177 and recompiled everything. The resulting toolchain mostly works, except when I try to use LTO, the linker fails with undefined reference to _Unwind_Resume.

It looks like the toolchain forgets about -fsjlj-exceptions when LTO is requested. Is this a bug in Clang/LLVM? Or am I missing something?

starg2 avatar Apr 02 '22 23:04 starg2

I'm trying to build a toolchain which uses SJLJ exceptions on i686 (instead of dwarf).

I tried reverting f9ce177 and recompiled everything. The resulting toolchain mostly works, except when I try to use LTO, the linker fails with undefined reference to _Unwind_Resume.

It looks like the toolchain forgets about -fsjlj-exceptions when LTO is requested. Is this a bug in Clang/LLVM? Or am I missing something?

I guess it can be considered a bug or just a missing feature... I don't do much LTO compilation, so I guess I never noticed this while using nonstandard exception handling mechanisms.

When compiling with LTO, the compilation pass just stores LLVM IR in the object files. Some code generation options, like -fsjlj-exceptions, aren't persisted in the LLVM IR (where it would end up kept per translation unit - I don't think it'd support using different exception handling models for different object files in the same LTO compilation). So one would need to pass some code generation option like --exception-model=sjlj to the linker to pass to the LTO code generation step. I'm not offhand familiar with how to pass such options though.

mstorsjo avatar Apr 03 '22 20:04 mstorsjo