Skip to content

WebAssembly Exception Handling-based Support #1882

@Nekto89

Description

@Nekto89

Hi. I wanted to try to use oneTBB with "-fwasm-exceptions" but got compilation error.
https://emscripten.org/docs/porting/exceptions.html#webassembly-exception-handling-based-support

clang++: error: invalid argument '-fwasm-exceptions' not allowed with '-enable-emscripten-cxx-exceptions'
gmake[2]: *** [src/tbbmalloc/CMakeFiles/tbbmalloc.dir/build.make:77: src/tbbmalloc/CMakeFiles/tbbmalloc.dir/backend.cpp.o] Error 1

Is it possible to remove hard-coded "-fexceptions" from cmake/compilers/Clang.cmake ?

I was able to at least compile+link oneTBB tests and examples after small change

--- a/cmake/compilers/Clang.cmake
+++ b/cmake/compilers/Clang.cmake
@@ -14,8 +14,7 @@
 
 if (EMSCRIPTEN)
     set(TBB_EMSCRIPTEN 1)
-    set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -fexceptions)
-    set(TBB_TEST_LINK_FLAGS  ${TBB_COMMON_LINK_FLAGS} -fexceptions -sINITIAL_MEMORY=65536000 -sALLOW_MEMORY_GROWTH=1 -sMALLOC=mimalloc -sEXIT_RUNTIME=1)
+    set(TBB_TEST_LINK_FLAGS  ${TBB_COMMON_LINK_FLAGS} -sINITIAL_MEMORY=65536000 -sALLOW_MEMORY_GROWTH=1 -sMALLOC=mimalloc -sEXIT_RUNTIME=1)
     if (NOT EMSCRIPTEN_WITHOUT_PTHREAD)
         set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "-pthread")
     endif()
emcmake cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DTBB_STRICT=OFF -DTBB_DISABLE_HWLOC_AUTOMATIC_SEARCH=ON -DBUILD_SHARED_LIBS=OFF -DTBB_EXAMPLES=ON -DTBB_TEST=ON -DCMAKE_CXX_FLAGS="-fwasm-exceptions -sSUPPORT_LONGJMP=wasm" -DCMAKE_EXE_LINKER_FLAGS="-fwasm-exceptions"

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions