tpoechtrager/wclang

C++ exception support for x86

jwilk opened this issue · 3 comments

jwilk commented

Recent versions of clang (3.9 and later) support C++ exceptions even on x86. (Or at least that's what documentation says...)
I'd love if wclang supported them, too.

I am using 4.0 and 32-bit exceptions still do not work.

$ w32-clang++ -v
clang version 4.0.1 (tags/RELEASE_401/final)
Target: i686-w64-windows-gnu
Thread model: posix
InstalledDir: /usr/bin

$ WCLANG_FORCE_CXX_EXCEPTIONS=1 w32-clang++ -fexceptions test.cpp
/tmp/test-3607bb.o:(.text+0x124): undefined reference to `_Unwind_Resume'
/tmp/test-3607bb.o:(.eh_frame+0x63): undefined reference to `__gxx_personality_v0'
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)

#21

jwilk commented

On my system (Debian unstable, clang 4.0) I had a test program successfully built using this command line:

WCLANG_FORCE_CXX_EXCEPTIONS=1 w32-clang++ -fsjlj-exceptions test.cc

But when I run the compiled program it immediately crashed with null pointer dereference. :(

Here's the test program source:

int main(int argc, char **argv)
{
	try {
		throw 42;
	} catch (int x) {
		return x;
	}
}

Hi,
Clang 6.0 finally added support for i686 exceptions, the fsjlj flag must be added:

$ i686-w64-mingw32-clang++ --version
clang version 6.0.0 (tags/RELEASE_600/final)
Target: i686-w64-windows-gnu
$ WCLANG_FORCE_CXX_EXCEPTIONS=1 i686-w64-mingw32-clang++ -fsjlj-exceptions main.cxx
$ i686-w64-mingw32-wine a.exe 
caught
ddee