Bug 1862248 [wpt PR 42868] - [FLEDGE] Add redirect WPT tests., a=testonly
[gecko.git] / security / rlbox / rlbox.mozbuild
blobbcb9d562e14d5ce795d74a1d7a7f2a77ee1d9bee
1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 @template
8 def RLBoxLibrary(name):
9     WASM_SOURCES += [
10         "/memory/mozalloc/mozalloc.cpp",
11         "/third_party/rlbox_wasm2c_sandbox/c_src/wasm2c_sandbox_wrapper.c",
12     ]
14     SOURCES += [f"!{name}.wasm.c"]
15     SOURCES += ["/third_party/wasm2c/wasm2c/wasm-rt-impl.c"]
17     # Configuration for the wasm2c runtime used by RLBox
19     # Enable SIMD autovectorization
20     if CONFIG["WASM_CC_VERSION"] and int(CONFIG["WASM_CC_VERSION"].split(".")[0]) >= 11:
21         WASM_CXXFLAGS += ["-msimd128"]
23     # Use a mmap style allocation
24     DEFINES["WASM_RT_USE_MMAP"] = 1
26     # Don't use internal signal handler as Firefox already provides one
27     DEFINES["WASM_RT_SKIP_SIGNAL_RECOVERY"] = 1
29     # We provide a custom trap handler that calls MOZ_CRASH
30     DEFINES["WASM_RT_TRAP_HANDLER"] = "moz_wasm2c_trap_handler"
32     # Don't limit the nested call depth
33     DEFINES["WASM_RT_USE_STACK_DEPTH_COUNT"] = 0
35     # Configure the wasm runtime to invoke a callback when a Wasm memory growth
36     # fails inside the sandbox. This information is used to annotate crash reports.
37     DEFINES["WASM_RT_GROW_FAILED_HANDLER"] = "moz_wasm2c_memgrow_failed"
39     SOURCES[f"!{name}.wasm.c"].flags += [
40         "-Wno-unused",
41     ]
43     WASM_DEFINES["MOZ_IN_WASM_SANDBOX"] = True
44     if CONFIG["ENABLE_CLANG_PLUGIN"]:
45         WASM_DEFINES["MOZ_CLANG_PLUGIN"] = True
47     SANDBOXED_WASM_LIBRARY_NAME = f"{name}.wasm"
49     # Ideally we'd also list {name}.wasm.h as an output, but that would put the
50     # generation in export rather than pre-compile, and we prefer the latter.
51     GeneratedFile(
52         f"{name}.wasm.c",
53         script="/config/wasm2c.py",
54         entry_point="wasm2c",
55         inputs=["!/dist/host/bin/wasm2c" + CONFIG["HOST_BIN_SUFFIX"], f"!{name}.wasm"],
56     )