wasi-sdk
wasi-sdk copied to clipboard
compiling cpp module with --target=wasm32-wasi results in fatal error: 'setjmp.h' file not found
Compiling a simple module that touches std namespace will cause /opt/wasi-sdk/share/wasi-sysroot/include/c++/v1/setjmp.h:34:15: fatal error: 'setjmp.h' file not found
The same code works w/o using -fmodule and without import
foo.cpp:
module;
import <string>
export module foo;
I'm using the precompiles wasi sdk https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/wasi-sdk_11.0_amd64_ubuntu20.04.deb on ubunty 20.04. Installed with $ sudo apt install ./wasi-sdk_11.0_amd64_ubuntu20.04.deb $ sudo apt install libncurses5
x@pirin:~/setjmp_bug$ /opt/wasi-sdk/bin/clang++ -v -std=c++20 -fmodules --precompile -c foo.cpp -o foo.pcm
clang version 10.0.0 (https://github.com/llvm/llvm-project d32170dbd5b0d54436537b6b75beaf44324e0c28)
Target: wasm32-unknown-wasi
Thread model: posix
InstalledDir: /opt/wasi-sdk/bin
(in-process)
"/opt/wasi-sdk/bin/clang-10" -cc1 -triple wasm32-unknown-wasi -E -disable-free -disable-llvm-verifier -discard-value-names -main-file-name foo.cpp -mrelocation-model static -mthread-model posix -mframe-pointer=none -fno-rounding-math -masm-verbose -mconstructor-aliases -target-cpu generic -fvisibility hidden -dwarf-column-info -debugger-tuning=gdb -v -resource-dir /opt/wasi-sdk/lib/clang/10.0.0 -isysroot /opt/wasi-sdk/share/wasi-sysroot -internal-isystem /opt/wasi-sdk/share/wasi-sysroot/include/wasm32-wasi/c++/v1 -internal-isystem /opt/wasi-sdk/share/wasi-sysroot/include/c++/v1 -internal-isystem /opt/wasi-sdk/lib/clang/10.0.0/include -internal-isystem /opt/wasi-sdk/share/wasi-sysroot/include/wasm32-wasi -internal-isystem /opt/wasi-sdk/share/wasi-sysroot/include -std=c++20 -fdeprecated-macro -fdebug-compilation-dir /home/x/setjmp_bug -ferror-limit 19 -fmessage-length 0 -fgnuc-version=4.2.1 -fmodules -fimplicit-module-maps -fmodules-cache-path=/tmp/org.llvm.clang.x/ModuleCache -fmodules-validate-system-headers -fobjc-runtime=gnustep -fcxx-exceptions -fexceptions -fno-common -fdiagnostics-show-option -fcolor-diagnostics -o foo.pcm -x c++ foo.cpp
clang -cc1 version 10.0.0 based upon LLVM 10.0.0 default target wasm32-wasi
ignoring nonexistent directory "/opt/wasi-sdk/share/wasi-sysroot/include/wasm32-wasi/c++/v1"
ignoring nonexistent directory "/opt/wasi-sdk/share/wasi-sysroot/include/wasm32-wasi"
#include "..." search starts here:
#include <...> search starts here:
/opt/wasi-sdk/share/wasi-sysroot/include/c++/v1
/opt/wasi-sdk/lib/clang/10.0.0/include
/opt/wasi-sdk/share/wasi-sysroot/include
End of search list.
clang -cc1 version 10.0.0 based upon LLVM 10.0.0 default target wasm32-wasi
ignoring nonexistent directory "/opt/wasi-sdk/share/wasi-sysroot/include/wasm32-wasi/c++/v1"
ignoring nonexistent directory "/opt/wasi-sdk/share/wasi-sysroot/include/wasm32-wasi"
#include "..." search starts here:
#include <...> search starts here:
/opt/wasi-sdk/share/wasi-sysroot/include/c++/v1
/opt/wasi-sdk/lib/clang/10.0.0/include
/opt/wasi-sdk/share/wasi-sysroot/include
End of search list.
While building module 'std' imported from foo.cpp:2:
In file included from
2 errors generated.
The wask-sdk does not support setjmp or other non-local control flow concepts (such as C++ exceptions) yet because WebAssembly does not yet support such things.
There are several proposals in the works that would enable these things, and if/when they get to certain point in the process wask-sdk/wask-libc will add support for setjmp.
Apologies, on re-reading this does look like something that could probably be fixed. Most likely the correct solution is to patch libc++ headers to avoid including c++/v1/setjmp.h. We should also probably remove that file from the SDK
I was about to answer to your reply. Correct, I'm not trying to use set jump or exceptions. The code just fails to compile when using modules and std imports. It compiles with only modules use or std imports but not with both. I tried to supply setjmp.h from somewhere else but it brings more issues. cheers!
Hello, I am face to the same issue, just FYI : At least \wasi-sdk-12\wasi-sysroot\include\c++\v1\module.modulemap export some module like thread, csignal, setjmp_h, csetjmp, atomic, barrier, future, latch and semaphore which is not supported in WAsm/WASI
Thks, Ghis
https://github.com/WebAssembly/WASI/issues/490
https://github.com/WebAssembly/exception-handling/issues/179