mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 09:54:42 +00:00
Bug 1723623 - Relax platform checks for wasm sandboxing. r=firefox-build-system-reviewers,andi
- Don't encode any platform dependency in the frontend itself, as that's dealt with by configure. Do check that there's a wasm compiler setup, though (also dealth with by configure). - Allow to enable on any 64-bits platform when building with wasm2c instead of lucetc. Differential Revision: https://phabricator.services.mozilla.com/D121582
This commit is contained in:
parent
38d3014aac
commit
fa555a5b49
@ -17,10 +17,7 @@ structures.
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
from mozbuild.frontend.context import (
|
||||
ObjDirPath,
|
||||
SourcePath,
|
||||
)
|
||||
from mozbuild.frontend.context import ObjDirPath, SourcePath
|
||||
from mozpack.chrome.manifest import ManifestEntry
|
||||
|
||||
import mozpack.path as mozpath
|
||||
@ -131,11 +128,7 @@ class DirectoryTraversal(ContextDerived):
|
||||
class BaseConfigSubstitution(ContextDerived):
|
||||
"""Base class describing autogenerated files as part of config.status."""
|
||||
|
||||
__slots__ = (
|
||||
"input_path",
|
||||
"output_path",
|
||||
"relpath",
|
||||
)
|
||||
__slots__ = ("input_path", "output_path", "relpath")
|
||||
|
||||
def __init__(self, context):
|
||||
ContextDerived.__init__(self, context)
|
||||
@ -193,10 +186,7 @@ class ComputedFlags(ContextDerived):
|
||||
class XPIDLModule(ContextDerived):
|
||||
"""Describes an XPIDL module to be compiled."""
|
||||
|
||||
__slots__ = (
|
||||
"name",
|
||||
"idl_files",
|
||||
)
|
||||
__slots__ = ("name", "idl_files")
|
||||
|
||||
def __init__(self, context, name, idl_files):
|
||||
ContextDerived.__init__(self, context)
|
||||
@ -502,12 +492,7 @@ class BaseProgram(Linkable):
|
||||
|
||||
__slots__ = "program"
|
||||
|
||||
DICT_ATTRS = {
|
||||
"install_target",
|
||||
"KIND",
|
||||
"program",
|
||||
"relobjdir",
|
||||
}
|
||||
DICT_ATTRS = {"install_target", "KIND", "program", "relobjdir"}
|
||||
|
||||
def __init__(self, context, program, is_unit_test=False):
|
||||
Linkable.__init__(self, context)
|
||||
@ -639,11 +624,7 @@ class HostRustProgram(BaseRustProgram):
|
||||
|
||||
|
||||
class RustTests(ContextDerived):
|
||||
__slots__ = (
|
||||
"names",
|
||||
"features",
|
||||
"output_category",
|
||||
)
|
||||
__slots__ = ("names", "features", "output_category")
|
||||
|
||||
def __init__(self, context, names, features):
|
||||
ContextDerived.__init__(self, context)
|
||||
@ -655,12 +636,7 @@ class RustTests(ContextDerived):
|
||||
class BaseLibrary(Linkable):
|
||||
"""Generic context derived container object for libraries."""
|
||||
|
||||
__slots__ = (
|
||||
"basename",
|
||||
"lib_name",
|
||||
"import_name",
|
||||
"refs",
|
||||
)
|
||||
__slots__ = ("basename", "lib_name", "import_name", "refs")
|
||||
|
||||
def __init__(self, context, basename):
|
||||
Linkable.__init__(self, context)
|
||||
@ -698,10 +674,7 @@ class Library(BaseLibrary):
|
||||
class StaticLibrary(Library):
|
||||
"""Context derived container object for a static library"""
|
||||
|
||||
__slots__ = (
|
||||
"link_into",
|
||||
"no_expand_lib",
|
||||
)
|
||||
__slots__ = ("link_into", "no_expand_lib")
|
||||
|
||||
def __init__(
|
||||
self, context, basename, real_name=None, link_into=None, no_expand_lib=False
|
||||
@ -721,11 +694,9 @@ class SandboxedWasmLibrary(Library):
|
||||
def __init__(self, context, basename, real_name=None):
|
||||
Library.__init__(self, context, basename, real_name)
|
||||
|
||||
# TODO: WASM sandboxed libraries are in a weird place: they are
|
||||
# built in a different way, but they should share some code with
|
||||
# SharedLibrary. This is the minimal configuration needed to work
|
||||
# on the below platforms.
|
||||
assert context.config.substs["OS_TARGET"] in ("Linux", "Darwin")
|
||||
# Wasm libraries are not going to compile unless we have a compiler
|
||||
# for them.
|
||||
assert context.config.substs["WASM_CC"] and context.config.substs["WASM_CXX"]
|
||||
|
||||
self.lib_name = "%s%s%s" % (
|
||||
context.config.dll_prefix,
|
||||
@ -1083,10 +1054,7 @@ class LocalInclude(ContextDerived):
|
||||
class PerSourceFlag(ContextDerived):
|
||||
"""Describes compiler flags specified for individual source files."""
|
||||
|
||||
__slots__ = (
|
||||
"file_name",
|
||||
"flags",
|
||||
)
|
||||
__slots__ = ("file_name", "flags")
|
||||
|
||||
def __init__(self, context, file_name, flags):
|
||||
ContextDerived.__init__(self, context)
|
||||
@ -1114,10 +1082,7 @@ class JARManifest(ContextDerived):
|
||||
class BaseSources(ContextDerived):
|
||||
"""Base class for files to be compiled during the build."""
|
||||
|
||||
__slots__ = (
|
||||
"files",
|
||||
"canonical_suffix",
|
||||
)
|
||||
__slots__ = ("files", "canonical_suffix")
|
||||
|
||||
def __init__(self, context, files, canonical_suffix):
|
||||
ContextDerived.__init__(self, context)
|
||||
@ -1415,10 +1380,7 @@ class GeneratedFile(ContextDerived):
|
||||
class ChromeManifestEntry(ContextDerived):
|
||||
"""Represents a chrome.manifest entry."""
|
||||
|
||||
__slots__ = (
|
||||
"path",
|
||||
"entry",
|
||||
)
|
||||
__slots__ = ("path", "entry")
|
||||
|
||||
def __init__(self, context, manifest_path, entry):
|
||||
ContextDerived.__init__(self, context)
|
||||
|
@ -1415,7 +1415,9 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
|
||||
def test_wasm_sources(self):
|
||||
"""Test that WASM_SOURCES works properly."""
|
||||
reader = self.reader("wasm-sources", extra_substs={"OS_TARGET": "Linux"})
|
||||
reader = self.reader(
|
||||
"wasm-sources", extra_substs={"WASM_CC": "clang", "WASM_CXX": "clang++"}
|
||||
)
|
||||
objs = list(self.read_topsrcdir(reader))
|
||||
|
||||
# The second to last object is a linkable.
|
||||
@ -1833,7 +1835,10 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
self.read_topsrcdir(reader)
|
||||
|
||||
def test_wasm_compile_flags(self):
|
||||
reader = self.reader("wasm-compile-flags", extra_substs={"OS_TARGET": "Linux"})
|
||||
reader = self.reader(
|
||||
"wasm-compile-flags",
|
||||
extra_substs={"WASM_CC": "clang", "WASM_CXX": "clang++"},
|
||||
)
|
||||
flags = list(self.read_topsrcdir(reader))[2]
|
||||
self.assertIsInstance(flags, ComputedFlags)
|
||||
self.assertEqual(
|
||||
|
@ -2253,19 +2253,22 @@ with only_when(requires_wasm_sandboxing & compile_environment):
|
||||
set_config("LUCETC_TARGET", rust_target_triple)
|
||||
|
||||
|
||||
@depends("--with-wasm-sandboxed-libraries", target)
|
||||
def wasm_sandboxing(libraries, target):
|
||||
@depends("--with-wasm-sandboxed-libraries", target, lucetc)
|
||||
def wasm_sandboxing(libraries, target, lucetc):
|
||||
if not libraries:
|
||||
return
|
||||
|
||||
# Wasm sandboxing is only enabled on specific targets.
|
||||
if not (
|
||||
if lucetc and not (
|
||||
target.cpu in ("x86_64",)
|
||||
and (target.kernel == "Linux" and target.os != "Android")
|
||||
or target.kernel == "Darwin"
|
||||
):
|
||||
die("wasm sandboxing is only enabled on x86-64 Linux and Mac")
|
||||
|
||||
if not lucetc and target.bitness != 64:
|
||||
die("wasm sandboxing is only supported on 64-bits platforms")
|
||||
|
||||
return namespace(**{name: True for name in libraries})
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user