@@ -775,10 +775,12 @@ class Exceptions(IntEnum):
775775 - EMSCRIPTEN: Emscripten provides exception handling capability using JS
776776 emulation. This causes code size increase and performance degradation.
777777 - WASM_LEGACY: Wasm native exception handling support (legacy)
778+ - WASM: Wasm native exception handling support
778779 """
779780 NONE = auto ()
780781 EMSCRIPTEN = auto ()
781782 WASM_LEGACY = auto ()
783+ WASM = auto ()
782784
783785
784786class ExceptionLibrary (Library ):
@@ -793,7 +795,9 @@ def get_cflags(self):
793795 elif self .eh_mode == Exceptions .EMSCRIPTEN :
794796 cflags += ['-sDISABLE_EXCEPTION_CATCHING=0' ]
795797 elif self .eh_mode == Exceptions .WASM_LEGACY :
796- cflags += ['-fwasm-exceptions' ]
798+ cflags += ['-fwasm-exceptions' , '-sWASM_LEGACY_EXCEPTIONS' ]
799+ elif self .eh_mode == Exceptions .WASM :
800+ cflags += ['-fwasm-exceptions' , '-sWASM_LEGACY_EXCEPTIONS=0' ]
797801
798802 return cflags
799803
@@ -805,19 +809,25 @@ def get_base_name(self):
805809 name += '-noexcept'
806810 elif self .eh_mode == Exceptions .WASM_LEGACY :
807811 name += '-legacyexcept'
812+ elif self .eh_mode == Exceptions .WASM :
813+ name += '-wasmexcept'
808814 return name
809815
810816 @classmethod
811817 def variations (cls ):
812818 combos = super ().variations ()
813819 return ([dict (eh_mode = Exceptions .NONE , ** combo ) for combo in combos ] +
814820 [dict (eh_mode = Exceptions .EMSCRIPTEN , ** combo ) for combo in combos ] +
815- [dict (eh_mode = Exceptions .WASM_LEGACY , ** combo ) for combo in combos ])
821+ [dict (eh_mode = Exceptions .WASM_LEGACY , ** combo ) for combo in combos ] +
822+ [dict (eh_mode = Exceptions .WASM , ** combo ) for combo in combos ])
816823
817824 @classmethod
818825 def get_default_variation (cls , ** kwargs ):
819826 if settings .WASM_EXCEPTIONS :
820- eh_mode = Exceptions .WASM_LEGACY
827+ if settings .WASM_LEGACY_EXCEPTIONS :
828+ eh_mode = Exceptions .WASM_LEGACY
829+ else :
830+ eh_mode = Exceptions .WASM
821831 elif settings .DISABLE_EXCEPTION_CATCHING == 1 :
822832 eh_mode = Exceptions .NONE
823833 else :
@@ -838,6 +848,12 @@ def get_cflags(self):
838848 '-sDISABLE_EXCEPTION_THROWING=0' ]
839849 elif self .eh_mode == Exceptions .WASM_LEGACY :
840850 cflags += ['-sSUPPORT_LONGJMP=wasm' ,
851+ '-sWASM_LEGACY_EXCEPTIONS' ,
852+ '-sDISABLE_EXCEPTION_THROWING' ,
853+ '-D__WASM_SJLJ__' ]
854+ elif self .eh_mode == Exceptions .WASM :
855+ cflags += ['-sSUPPORT_LONGJMP=wasm' ,
856+ '-sWASM_LEGACY_EXCEPTIONS=0' ,
841857 '-sDISABLE_EXCEPTION_THROWING' ,
842858 '-D__WASM_SJLJ__' ]
843859 return cflags
@@ -848,18 +864,24 @@ def get_base_name(self):
848864 # suffixes. Change the default to wasm exception later.
849865 if self .eh_mode == Exceptions .WASM_LEGACY :
850866 name += '-legacysjlj'
867+ elif self .eh_mode == Exceptions .WASM :
868+ name += '-wasmsjlj'
851869 return name
852870
853871 @classmethod
854872 def variations (cls ):
855873 combos = super ().variations ()
856874 return ([dict (eh_mode = Exceptions .EMSCRIPTEN , ** combo ) for combo in combos ] +
857- [dict (eh_mode = Exceptions .WASM_LEGACY , ** combo ) for combo in combos ])
875+ [dict (eh_mode = Exceptions .WASM_LEGACY , ** combo ) for combo in combos ] +
876+ [dict (eh_mode = Exceptions .WASM , ** combo ) for combo in combos ])
858877
859878 @classmethod
860879 def get_default_variation (cls , ** kwargs ):
861880 if settings .SUPPORT_LONGJMP == 'wasm' :
862- eh_mode = Exceptions .WASM_LEGACY
881+ if settings .WASM_LEGACY_EXCEPTIONS :
882+ eh_mode = Exceptions .WASM_LEGACY
883+ else :
884+ eh_mode = Exceptions .WASM
863885 else :
864886 eh_mode = Exceptions .EMSCRIPTEN
865887 return super ().get_default_variation (eh_mode = eh_mode , ** kwargs )
@@ -1600,7 +1622,7 @@ def get_files(self):
16001622 filenames += ['cxa_noexception.cpp' ]
16011623 elif self .eh_mode == Exceptions .EMSCRIPTEN :
16021624 filenames += ['cxa_exception_emscripten.cpp' ]
1603- elif self .eh_mode == Exceptions .WASM_LEGACY :
1625+ elif self .eh_mode in ( Exceptions .WASM_LEGACY , Exceptions . WASM ) :
16041626 filenames += [
16051627 'cxa_exception_storage.cpp' ,
16061628 'cxa_exception.cpp' ,
@@ -1654,7 +1676,7 @@ class libcxx(ExceptionLibrary, MTLibrary):
16541676
16551677 def get_cflags (self ):
16561678 cflags = super ().get_cflags ()
1657- if self .eh_mode == Exceptions .WASM_LEGACY :
1679+ if self .eh_mode in ( Exceptions .WASM_LEGACY , Exceptions . WASM ) :
16581680 cflags .append ('-D__WASM_EXCEPTIONS__' )
16591681 return cflags
16601682
@@ -1677,7 +1699,7 @@ def __init__(self, **kwargs):
16771699 super ().__init__ (** kwargs )
16781700
16791701 def can_use (self ):
1680- return super ().can_use () and self .eh_mode == Exceptions .WASM_LEGACY
1702+ return super ().can_use () and self .eh_mode in ( Exceptions .WASM_LEGACY , Exceptions . WASM )
16811703
16821704 def get_cflags (self ):
16831705 cflags = super ().get_cflags ()
@@ -1688,7 +1710,7 @@ def get_cflags(self):
16881710 cflags .append ('-D_LIBUNWIND_HAS_NO_EXCEPTIONS' )
16891711 elif self .eh_mode == Exceptions .EMSCRIPTEN :
16901712 cflags .append ('-D__EMSCRIPTEN_EXCEPTIONS__' )
1691- elif self .eh_mode == Exceptions .WASM_LEGACY :
1713+ elif self .eh_mode in ( Exceptions .WASM_LEGACY , Exceptions . WASM ) :
16921714 cflags .append ('-D__WASM_EXCEPTIONS__' )
16931715 return cflags
16941716
0 commit comments