summaryrefslogtreecommitdiffstats
path: root/platform/web/detect.py
diff options
context:
space:
mode:
Diffstat (limited to 'platform/web/detect.py')
-rw-r--r--platform/web/detect.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/platform/web/detect.py b/platform/web/detect.py
index 043ddca65d..d306869889 100644
--- a/platform/web/detect.py
+++ b/platform/web/detect.py
@@ -41,6 +41,11 @@ def get_opts():
"dlink_enabled", "Enable WebAssembly dynamic linking (GDExtension support). Produces bigger binaries", False
),
BoolVariable("use_closure_compiler", "Use closure compiler to minimize JavaScript code", False),
+ BoolVariable(
+ "proxy_to_pthread",
+ "Use Emscripten PROXY_TO_PTHREAD option to run the main application code to a separate thread",
+ True,
+ ),
]
@@ -211,6 +216,10 @@ def configure(env: "Environment"):
env.Append(LINKFLAGS=["-Wl,-u,scalbnf"])
if env["dlink_enabled"]:
+ if env["proxy_to_pthread"]:
+ print("GDExtension support requires proxy_to_pthread=no, disabling")
+ env["proxy_to_pthread"] = False
+
if cc_semver < (3, 1, 14):
print("GDExtension support requires emscripten >= 3.1.14, detected: %s.%s.%s" % cc_semver)
sys.exit(255)
@@ -221,6 +230,16 @@ def configure(env: "Environment"):
env.Append(LINKFLAGS=["-fvisibility=hidden"])
env.extra_suffix = ".dlink" + env.extra_suffix
+ # Run the main application in a web worker
+ if env["proxy_to_pthread"]:
+ env.Append(LINKFLAGS=["-s", "PROXY_TO_PTHREAD=1"])
+ env.Append(CPPDEFINES=["PROXY_TO_PTHREAD_ENABLED"])
+ env.Append(LINKFLAGS=["-s", "EXPORTED_RUNTIME_METHODS=['_emscripten_proxy_main']"])
+ # https://github.com/emscripten-core/emscripten/issues/18034#issuecomment-1277561925
+ env.Append(LINKFLAGS=["-s", "TEXTDECODER=0"])
+ # BigInt support to pass object pointers between contexts
+ env.Append(LINKFLAGS=["-s", "WASM_BIGINT"])
+
# Reduce code size by generating less support code (e.g. skip NodeJS support).
env.Append(LINKFLAGS=["-s", "ENVIRONMENT=web,worker"])