Skip to content

Commit 73dc3b6

Browse files
s09gjpiat
authored andcommitted
Add WASM/Emscripten compiler flags to runtime_wrapper.bzl
Differential Revision: D95904580 Pull Request resolved: pytorch#18025
1 parent e128168 commit 73dc3b6

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

shim_et/xplat/executorch/build/runtime_wrapper.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ def _patch_build_mode_flags(kwargs):
123123
# @oss-disable: "fbsource//xplat/assistant/oacr/native/scripts:compiler_flag_O2": ["-O2"],
124124
})
125125

126+
# Add pthread flags for Emscripten/WASM builds with threading support.
127+
# Required when linking into WASM binaries that use -sUSE_PTHREADS=1.
128+
# Without these flags, wasm-ld fails with:
129+
# "error: --shared-memory is disallowed by <file>.o because it was not
130+
# compiled with 'atomics' or 'bulk-memory' features."
131+
kwargs["compiler_flags"] = kwargs["compiler_flags"] + select({
132+
"DEFAULT": [],
133+
# @oss-disable: "ovr_config//runtime:wasm-emscripten": ["-pthread", "-matomics", "-mbulk-memory"],
134+
})
135+
126136
return kwargs
127137

128138
def _has_pytorch_dep(dep_list):

0 commit comments

Comments
 (0)