-
Bug
-
Resolution: Won't Do
-
P2: Important
-
None
-
6.4, 6.5.0 Beta1
-
None
-
Linux
I'm experiencing problem with C++ exception catching when building Qt applications for WASM using CMake instead of QMake. Attempting to throw and catch an exception then triggers the following error in debug builds (of both Qt and the application):
Application exit (4844008 - Exception catching is disabled, this exception cannot be caught. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.)
Exception throwing and catching seem to work fine with QMake, provided that the following is added to the project:
QMAKE_CXXFLAGS += -fexceptions QMAKE_LFLAGS += -s DISABLE_EXCEPTION_CATCHING=0
Likely cause
The generated lib/cmake/Qt6/Qt6Targets.cmake file seem to explicitly define DISABLE_EXCEPTION_CATCHING=1 for all CMake targets. This is problematic, since it makes it impossible to enable exception support for a target.
Proposed fix
Update Qt6Targets.cmake to either define DISABLE_EXCEPTION_CATCHING=0 or remove the parameter altogether to allow manual enabling (or disabling) of exceptions from CMake projects. It seems like qtbase/cmake/QtWasmHelpers.cmake is somehow involved in this.