Skip to content

Commit

Permalink
using -fexception instead of fwasm-exception (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerThorsten authored Sep 19, 2023
1 parent 243074a commit 163e6ec
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 22 deletions.
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,16 @@ target_link_libraries(pyjs PRIVATE ${PYTHON_UTIL_LIBS} pybind11::embed)
PUBLIC --std=c++17
PUBLIC -Wno-deprecated
PUBLIC "SHELL: --bind"
PUBLIC "SHELL: -fwasm-exceptions"
PUBLIC "SHELL: -fexceptions"
)

target_link_options(pyjs
PUBLIC --bind
PUBLIC -Wno-unused-command-line-argument
PUBLIC "SHELL: --bind"
PUBLIC "SHELL: -fwasm-exceptions"
PUBLIC "SHELL: -fexceptions"
#PUBLIC "SHELL:-s EXPORT_EXCEPTION_HANDLING_HELPERS"
#PUBLIC "SHELL:-s EXCEPTION_CATCHING_ALLOWED=['we only want to allow exception handling in side modules']"
)


Expand Down Expand Up @@ -213,7 +215,8 @@ target_compile_options(pyjs_runtime_browser
PUBLIC -Wno-deprecated
PUBLIC "SHELL: --bind"
PUBLIC "SHELL: -s ENVIRONMENT=${ENVIRONMENT}"
PUBLIC "SHELL: -fwasm-exceptions"
PUBLIC "SHELL: -fexceptions"
#PUBLIC "SHELL:-s EXPORT_EXCEPTION_HANDLING_HELPERS"
PUBLIC "SHELL: -s FORCE_FILESYSTEM"
PUBLIC "SHELL: -s LZ4=1"
PUBLIC "SHELL: -flto"
Expand All @@ -234,7 +237,8 @@ target_link_options(pyjs_runtime_browser
PUBLIC "SHELL: -s EXIT_RUNTIME=1"
PUBLIC "SHELL: -s WASM=1"
PUBLIC "SHELL: -s USE_PTHREADS=0"
PUBLIC "SHELL: -fwasm-exceptions"
PUBLIC "SHELL: -s ENVIRONMENT=${ENVIRONMENT}"
PUBLIC "SHELL: -fexceptions"
PUBLIC "SHELL: -s MAIN_MODULE=1"
PUBLIC "SHELL: -s ENVIRONMENT=${ENVIRONMENT}"
PUBLIC "SHELL: -s TOTAL_STACK=16mb"
Expand Down
7 changes: 5 additions & 2 deletions include/pyjs/post_js/fixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ if (!('wasmTable' in Module)) {
Module['wasmTable'] = wasmTable
}


Module['FS'] = FS
Module['FS'] = FS
Module['PATH'] = PATH
Module['LDSO'] = LDSO
Module['getDylinkMetadata'] = getDylinkMetadata
Module['loadDynamicLibrary'] = loadDynamicLibrary
45 changes: 30 additions & 15 deletions include/pyjs/pre_js/load_pkg.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ import shutil
import os
import sys
def check_wasm_magic_number(file_path: Path) -> bool:
WASM_BINARY_MAGIC = b"\\0asm"
with file_path.open(mode="rb") as file:
return file.read(4) == WASM_BINARY_MAGIC
target_dir = "${target_dir}"
if target_dir == "":
target_dir = sys.prefix
Expand All @@ -44,6 +51,11 @@ try:
shared_libs.append(f"{target_dir}/{file.name}")
tar.extractall(target_dir)
for file in shared_libs:
if not check_wasm_magic_number(Path(file)):
print(f" {file} is not a wasm file")
else:
print(f" {file} is a wasm file")
s = json.dumps(shared_libs)
except Exception as e:
print("ERROR",e)
Expand Down Expand Up @@ -84,7 +96,8 @@ Module["bootstrap_from_empack_packed_environment"] = async function
(
packages_json_url,
package_tarballs_root_url,
verbose = false
verbose = false,
skip_loading_shared_libs = true
) {


Expand Down Expand Up @@ -153,22 +166,24 @@ Module["bootstrap_from_empack_packed_environment"] = async function
// create array with size
let shared_libs = await Promise.all(packages.map(package => fetchAndUntar(package_tarballs_root_url, python_is_ready_promise, package)))

// instantiate all packages
for (let i = 0; i < packages.length; i++) {

// if we have any shared libraries, load them
if (shared_libs[i].length > 0) {
if(!skip_loading_shared_libs){
// instantiate all packages
for (let i = 0; i < packages.length; i++) {

for (let j = 0; j < shared_libs[i].length; j++) {
let sl = shared_libs[i][j];
// if we have any shared libraries, load them
if (shared_libs[i].length > 0) {

for (let j = 0; j < shared_libs[i].length; j++) {
let sl = shared_libs[i][j];
}
await Module._loadDynlibsFromPackage(
prefix,
python_version,
packages[i].name,
false,
shared_libs[i]
)
}
await Module._loadDynlibsFromPackage(
prefix,
python_version,
packages[i].name,
false,
shared_libs[i]
)
}
}
}
2 changes: 1 addition & 1 deletion src/js_timestamp.cpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define PYJS_JS_UTC_TIMESTAMP "2023-09-05 07:59:30.761501"
#define PYJS_JS_UTC_TIMESTAMP "2023-09-12 06:47:21.229070"

0 comments on commit 163e6ec

Please sign in to comment.