Skip to content

Commit

Permalink
Fix skwasm target in wasm_debug_unopt build. (#162100)
Browse files Browse the repository at this point in the history
Fixes a couple issues in the skwasm build rules:
* `DEMANGLE_SUPPORT` is deprecated in emscripten, so just remove it.
* `sSHARED_MEMORY=1` needs to be added to the cflags so that emscripten
appends the proper feature flags (`-matomics` and `-mbulk-memory`) when
doing the compile so that the flags match the linking step.
  • Loading branch information
eyebrowsoffire authored Jan 23, 2025
1 parent 8c4ad50 commit bfe31d6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions engine/src/build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ config("compiler") {
if (wasm_use_pthreads) {
cflags += [ "-pthread" ]
ldflags += [ "-pthread" ]
} if (wasm_shared_memory) {
cflags += [ "-sSHARED_MEMORY=1" ]
ldflags += [ "-sSHARED_MEMORY=1" ]
}
ldflags += [
"-s",
Expand Down
1 change: 1 addition & 0 deletions engine/src/build/toolchain/wasm.gni
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ declare_args() {
emsdk_dir = rebase_path("//flutter/prebuilts/emsdk")

wasm_use_pthreads = false
wasm_shared_memory = false
wasm_use_dwarf = false
}

Expand Down
2 changes: 0 additions & 2 deletions engine/src/flutter/lib/web_ui/skwasm/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ template("skwasm_variant") {
"-lexports.js",
"-sEXPORTED_FUNCTIONS=[stackAlloc]",
"-sEXPORTED_RUNTIME_METHODS=[addFunction,wasmExports,wasmMemory,stackAlloc]",
"-sSHARED_MEMORY=1",
"-sINCOMING_MODULE_JS_API=[instantiateWasm,noExitRuntime,mainScriptUrlOrBlob]",
"-sUSE_ES6_IMPORT_META=0",
"--js-library",
Expand Down Expand Up @@ -76,7 +75,6 @@ template("skwasm_variant") {

if (is_debug) {
ldflags += [
"-sDEMANGLE_SUPPORT=1",
"-sASSERTIONS=1",
"-sGL_ASSERTIONS=1",
]
Expand Down
1 change: 0 additions & 1 deletion engine/src/flutter/skia/modules/canvaskit/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ canvaskit_wasm_lib("canvaskit") {
if (is_debug) {
ldflags += [
"-O0",
"-sDEMANGLE_SUPPORT=1",
"-sASSERTIONS=1",
"-sGL_ASSERTIONS=1",
"-g3",
Expand Down
4 changes: 3 additions & 1 deletion engine/src/flutter/third_party/canvaskit/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ wasm_toolchain("skwasm_st") {
skia_use_no_png_encode = true
skia_use_libpng_encode = false

# skwasm_st is singlethreaded
# skwasm_st doesn't use pthreads, but does pass the shared memory flag in order
# to be compatible with the way app modules import the memory object.
wasm_use_pthreads = false
wasm_shared_memory = true
wasm_prioritize_size = true
}
}
Expand Down

0 comments on commit bfe31d6

Please sign in to comment.