diff --git a/config/wasm2c.py b/config/wasm2c.py index 572e015adad0..32afc0a196ab 100644 --- a/config/wasm2c.py +++ b/config/wasm2c.py @@ -6,9 +6,9 @@ import os import subprocess -def wasm2c(output, wasm2c_bin, wasm_lib): +def wasm2c(output, wasm2c_bin, wasm_lib, *flags): output.close() module_name = os.path.basename(os.path.splitext(wasm_lib)[0]) return subprocess.run( - [wasm2c_bin, "-n", module_name, "-o", output.name, wasm_lib] + [wasm2c_bin, "-n", module_name] + list(flags) + ["-o", output.name, wasm_lib] ).returncode diff --git a/security/rlbox/rlbox.mozbuild b/security/rlbox/rlbox.mozbuild index 5308595c44b8..8d2c85dcc211 100644 --- a/security/rlbox/rlbox.mozbuild +++ b/security/rlbox/rlbox.mozbuild @@ -12,7 +12,11 @@ def RLBoxLibrary(name, use_segue=True): "/third_party/rlbox_wasm2c_sandbox/c_src/wasm2c_sandbox_wrapper.c", ] - SOURCES += [f"!{name}.wasm.c"] + if CONFIG["DEVELOPER_OPTIONS"]: + wasm_sources = sorted(f"!{name}.wasm_{n}.c" for n in range(16)) + else: + wasm_sources = [f"!{name}.wasm.c"] + SOURCES += wasm_sources SOURCES += ["/third_party/wasm2c/wasm2c/wasm-rt-impl.c"] SOURCES += ["/third_party/wasm2c/wasm2c/wasm-rt-mem-impl.c"] @@ -38,9 +42,8 @@ def RLBoxLibrary(name, use_segue=True): # fails inside the sandbox. This information is used to annotate crash reports. DEFINES["WASM_RT_GROW_FAILED_HANDLER"] = "moz_wasm2c_memgrow_failed" - SOURCES[f"!{name}.wasm.c"].flags += [ - "-Wno-unused", - ] + for source in wasm_sources: + SOURCES[source].flags += ["-Wno-unused"] # Use Segue optimization. Since this requires passing the "-mfsgsbase", we # restrict this to compilers and architectures that support this flag. @@ -81,4 +84,5 @@ def RLBoxLibrary(name, use_segue=True): script="/config/wasm2c.py", entry_point="wasm2c", inputs=["!/dist/host/bin/wasm2c" + CONFIG["HOST_BIN_SUFFIX"], f"!{name}.wasm"], + flags=["--num-outputs", len(wasm_sources)] if len(wasm_sources) > 1 else [], )