Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

web: Build dlink main module with wasm-except

Fabio Alessandrellicb1dfbf265ca
diff --git a/platform/web/SCsub b/platform/web/SCsub
index 0798c4f26f4..c62c950cbce 100644
--- a/platform/web/SCsub
+++ b/platform/web/SCsub
@@ -78,6 +78,9 @@ if len(env["EXPORTED_FUNCTIONS"]):
if len(env["EXPORTED_RUNTIME_METHODS"]):
sys_env.Append(LINKFLAGS=["-sEXPORTED_RUNTIME_METHODS=" + repr(sorted(list(set(env["EXPORTED_RUNTIME_METHODS"]))))])
+# Wrap the JavaScript support code around a closure named Godot.
+sys_env.Append(LINKFLAGS=["-sMODULARIZE=1", "-sEXPORT_NAME='Godot'"])
+
build = []
build_targets = ["#bin/godot${PROGSUFFIX}.js", "#bin/godot${PROGSUFFIX}.wasm"]
if env["dlink_enabled"]:
@@ -88,12 +91,14 @@ if env["dlink_enabled"]:
# Configure it as a main module (dynamic linking support).
sys_env["CCFLAGS"].remove("-sSIDE_MODULE=2")
sys_env["LINKFLAGS"].remove("-sSIDE_MODULE=2")
- sys_env.Append(CCFLAGS=["-s", "MAIN_MODULE=1"])
- sys_env.Append(LINKFLAGS=["-s", "MAIN_MODULE=1"])
- sys_env.Append(LINKFLAGS=["-s", "EXPORT_ALL=1"])
- sys_env.Append(LINKFLAGS=["-s", "WARN_ON_UNDEFINED_SYMBOLS=0"])
+ sys_env.Append(CCFLAGS=["-sMAIN_MODULE=1"])
+ sys_env.Append(LINKFLAGS=["-sMAIN_MODULE=1"])
+ sys_env.Append(LINKFLAGS=["-sEXPORT_ALL=1"])
+ sys_env.Append(LINKFLAGS=["-sWARN_ON_UNDEFINED_SYMBOLS=0"])
sys_env["CCFLAGS"].remove("-fvisibility=hidden")
sys_env["LINKFLAGS"].remove("-fvisibility=hidden")
+ sys_env.Append(CCFLAGS=["-fwasm-exceptions"])
+ sys_env.Append(LINKFLAGS=["-fwasm-exceptions"])
# The main emscripten runtime, with exported standard libraries.
sys = sys_env.add_program(build_targets, ["web_runtime.cpp"])
diff --git a/platform/web/detect.py b/platform/web/detect.py
index 869f4971938..d680d481ff5 100644
--- a/platform/web/detect.py
+++ b/platform/web/detect.py
@@ -261,10 +261,6 @@ def configure(env: "SConsEnvironment"):
env.Append(LINKFLAGS=[f"-sDEFAULT_PTHREAD_STACK_SIZE={env['default_pthread_stack_size']}KB"])
env.Append(LINKFLAGS=["-sPTHREAD_POOL_SIZE=\"Module['emscriptenPoolSize']||8\""])
env.Append(LINKFLAGS=["-sMAXIMUM_MEMORY=2048MB"])
- if not env["dlink_enabled"]:
- # Workaround https://github.com/emscripten-core/emscripten/issues/21844#issuecomment-2116936414.
- # Not needed (and potentially dangerous) when dlink_enabled=yes, since we set EXPORT_ALL=1 in that case.
- env["EXPORTED_FUNCTIONS"] += ["__emscripten_thread_crashed"]
elif env["proxy_to_pthread"]:
print_warning('"threads=no" support requires "proxy_to_pthread=no", disabling proxy to pthread.')
@@ -286,8 +282,6 @@ def configure(env: "SConsEnvironment"):
env.Append(LINKFLAGS=["-fvisibility=hidden"])
env.extra_suffix = ".dlink" + env.extra_suffix
- env.Append(LINKFLAGS=["-sWASM_BIGINT"])
-
# Run the main application in a web worker
if env["proxy_to_pthread"]:
env.Append(LINKFLAGS=["-sPROXY_TO_PTHREAD=1"])
@@ -300,9 +294,6 @@ def configure(env: "SConsEnvironment"):
# Reduce code size by generating less support code (e.g. skip NodeJS support).
env.Append(LINKFLAGS=["-sENVIRONMENT=web,worker"])
- # Wrap the JavaScript support code around a closure named Godot.
- env.Append(LINKFLAGS=["-sMODULARIZE=1", "-sEXPORT_NAME='Godot'"])
-
# Force long jump mode to 'wasm'
env.Append(CCFLAGS=["-sSUPPORT_LONGJMP='wasm'"])
env.Append(LINKFLAGS=["-sSUPPORT_LONGJMP='wasm'"])