WebAssembly/wasi-sdk

Error when trying to link code that throws a C++ exception

Keithcat1 opened this issue · 2 comments


C:\py>C:\wasi-sdk\bin\clang -v
clang version 14.0.4 (https://github.com/llvm/llvm-project 29f1039a7285a5c3a9c353d054140bf2556d4c4d)
Target: wasm32-unknown-wasi
Thread model: posix
InstalledDir: C:\wasi-sdk\bin

The following code gives a link error when comipiling it:

#include <exception>
int main() {
	throw std::exception();
}

Command:

C:\wasi-sdk\bin\clang++ exception.cpp

Error:

wasm-ld: error: C:\Users\keith\AppData\Local\Temp\exception-e0bcfd.o: undefined symbol: __cxa
_allocate_exception
wasm-ld: error: C:\Users\keith\AppData\Local\Temp\exception-e0bcfd.o: undefined symbol: __cxa
_throw
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

C++ exceptions are not yet supported. Work toward exception support is in progress.

Sorry. I missed that somehow.