Skip to content

Commit 9258bed

Browse files
committed
Allow optional internal exception catching
1 parent 933c8bc commit 9258bed

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

7z-Src/CPP/7zip/7zip_gcc.mak

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ ifdef WASM_EXTRA_FS
4141
CFLAGS_BASE += -DWASM_EXTRA_FS
4242
endif # WASM_EXTRA_FS
4343

44+
ifdef WASM_EXCEPTION_CATCHING
45+
CFLAGS_BASE += -DWASM_EXCEPTION_CATCHING -sDISABLE_EXCEPTION_CATCHING=0
46+
endif # WASM_EXCEPTION_CATCHING
47+
4448
ifndef ST_MODE
4549
CFLAGS_BASE += -pthread
4650
endif # !ST_MODE
@@ -173,6 +177,10 @@ else
173177
LIB2 += -sEXPORTED_RUNTIME_METHODS='["callMain", "FS"]'
174178
endif # WASM_EXTRA_FS
175179

180+
ifdef WASM_EXCEPTION_CATCHING
181+
LIB2 += -sDISABLE_EXCEPTION_CATCHING=0
182+
endif # WASM_EXCEPTION_CATCHING
183+
176184
else
177185
LIB2 = -lpthread -ldl
178186
endif # EMSCRIPTEN

7z-Src/CPP/7zip/Bundles/Alone2/makefile.gcc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ ifdef EMSCRIPTEN
22
PROG = js7z.js
33
# ST_MODE = 1
44
# WASM_EXTRA_FS = 1
5+
# WASM_EXCEPTION_CATCHING = 1
56
else
67
PROG = 7zz
78
endif

7z-Src/CPP/7zip/UI/Console/Main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ static void ShowCopyrightAndHelp(CStdOutStream *so, bool needHelp)
339339
#ifdef WASM_EXTRA_FS
340340
*so << "+FS";
341341
#endif // WASM_EXTRA_FS
342+
#ifdef WASM_EXCEPTION_CATCHING
343+
*so << "+EC";
344+
#endif // WASM_EXCEPTION_CATCHING
342345
*so << "] build: https://github.com/GMH-Code/JS7z" << endl;
343346
#endif // __EMSCRIPTEN__
344347
// *so << "# CPUs: " << (UInt64)NWindows::NSystem::GetNumberOfProcessors() << endl;

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Some differences with JS7z include:
4444
- Safe; forces proper memory resets after each use
4545
- The runtime and threads/workers automatically quit upon completion
4646
- Asynchronous completion callbacks with exit statuses/reasons
47+
- Improved exception handling coverage (optional; increases build size)
4748
- Supports `PROXYFS` as well as `NODEFS` and `WORKERFS`, so you can chain operations between instances without needing to offload data
4849
- Minimal build variants
4950

@@ -219,7 +220,7 @@ In most cases, you will want to use a multi-threaded version, but you can fall b
219220
- Multi-thread mode works in nearly all modern browsers. It is extremely fast, runs in the background, and returns immediately.
220221
- Single-thread mode supports less common browsers, but is slower with certain tasks. It also can require a bit more work to use.
221222

222-
Warning: Calling `callMain()` in single-thread mode *currently* returns after the command is run, so long processes can hang the browser unless you run them in a Worker. You should still use `onExit(exitCode)` to detect a proper exit. The single-threaded version may also run in the same asynchronous way one day.
223+
Warning: Calling `callMain()` in single-thread mode *currently* returns after the command completes, so long processes can hang the browser unless you run them in a Worker. You should still use `onExit(exitCode)` to detect a proper exit. The single-threaded version may also run in the same asynchronous way one day.
223224

224225
You can detect multi-threaded shared memory support in the browser like this:
225226

@@ -260,6 +261,7 @@ You can insert extra parameters between `emmake make` and the rest of the comman
260261

261262
- To build in single-thread mode, insert `ST_MODE=1`.
262263
- To add support for mounting additional WebAssembly file systems (`NODEFS`, `WORKERFS` & `PROXYFS`), insert `WASM_EXTRA_FS=1`.
264+
- For extra exception catching during 7-Zip runs, insert `WASM_EXCEPTION_CATCHING=1`.
263265

264266
Usage of these compilation flags will be displayed in 7-Zip's output.
265267

0 commit comments

Comments
 (0)