зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1853840 - Move sandboxed soundtouch out of libxul and reenable sandbox. r=firefox-build-system-reviewers,shravanrn,media-playback-reviewers,padenot,ahochheiden
Differential Revision: https://phabricator.services.mozilla.com/D188648
This commit is contained in:
Родитель
1ec96570e0
Коммит
a980e9cd4f
|
@ -15,7 +15,9 @@
|
|||
# include "mozilla/rlbox/rlbox_wasm2c_tls.hpp"
|
||||
# include "wasm-rt.h"
|
||||
|
||||
# include "nsExceptionHandler.h"
|
||||
# ifndef WASM_RT_GROW_FAILED_CRASH
|
||||
# include "nsExceptionHandler.h"
|
||||
# endif
|
||||
|
||||
// The MingW compiler does not correctly handle static thread_local inline
|
||||
// members. We instead TLS storage via functions. This can be removed if the
|
||||
|
@ -33,8 +35,12 @@ void moz_wasm2c_trap_handler(wasm_rt_trap_t code) {
|
|||
// The below function is called if a malloc in sandboxed code returns null
|
||||
// This indicates that the sandbox has run out of memory.
|
||||
void moz_wasm2c_memgrow_failed() {
|
||||
# ifdef WASM_RT_GROW_FAILED_CRASH
|
||||
MOZ_CRASH("wasm2c memory grow failed");
|
||||
# else
|
||||
CrashReporter::AnnotateCrashReport(
|
||||
CrashReporter::Annotation::WasmLibrarySandboxMallocFailed, true);
|
||||
# endif
|
||||
}
|
||||
|
||||
// This function is called when mozalloc_handle_oom is called from within
|
||||
|
|
|
@ -179,7 +179,7 @@ endif
|
|||
|
||||
ifdef ENABLE_CLANG_PLUGIN
|
||||
# Only target rules use the clang plugin.
|
||||
$(filter %/target %/target-objects,$(filter-out config/export config/host build/unix/stdc++compat/% build/clang-plugin/%,$(compile_targets))) security/rlbox/pre-compile: build/clang-plugin/host build/clang-plugin/tests/target-objects
|
||||
$(filter %/target %/target-objects,$(filter-out config/export config/host build/unix/stdc++compat/% build/clang-plugin/%,$(compile_targets))) security/rlbox/pre-compile media/libsoundtouch/src/pre-compile: build/clang-plugin/host build/clang-plugin/tests/target-objects
|
||||
build/clang-plugin/tests/target-objects: build/clang-plugin/host
|
||||
# clang-plugin tests require js-confdefs.h on js standalone builds and mozilla-config.h on
|
||||
# other builds, because they are -include'd.
|
||||
|
@ -216,8 +216,9 @@ $(filter %/target,$(compile_targets)): build/unix/elfhack/host build/unix/elfhac
|
|||
endif
|
||||
|
||||
ifdef MOZ_USING_WASM_SANDBOXING
|
||||
security/rlbox/pre-compile: config/external/wasm2c_sandbox_compiler/host
|
||||
dom/media/ogg/target-objects extensions/spellcheck/hunspell/glue/target-objects gfx/thebes/target-objects parser/expat/target-objects parser/htmlparser/target-objects gfx/ots/src/target-objects dom/media/target-objects dom/media/mediasink/target-objects: security/rlbox/pre-compile
|
||||
security/rlbox/pre-compile media/libsoundtouch/src/pre-compile: config/external/wasm2c_sandbox_compiler/host
|
||||
dom/media/ogg/target-objects extensions/spellcheck/hunspell/glue/target-objects gfx/thebes/target-objects parser/expat/target-objects parser/htmlparser/target-objects gfx/ots/src/target-objects: security/rlbox/pre-compile
|
||||
dom/media/target-objects dom/media/mediasink/target-objects: media/libsoundtouch/src/pre-compile
|
||||
endif
|
||||
|
||||
# Most things are built during compile (target/host), but some things happen during export
|
||||
|
|
|
@ -17,7 +17,7 @@ EXPORTS += [
|
|||
]
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
"!/security/rlbox",
|
||||
"!/media/libsoundtouch/src",
|
||||
"/dom/media",
|
||||
]
|
||||
|
||||
|
|
|
@ -195,8 +195,6 @@ EXPORTS += [
|
|||
"PrincipalHandle.h",
|
||||
"QueueObject.h",
|
||||
"ReaderProxy.h",
|
||||
"RLBoxSoundTouch.h",
|
||||
"RLBoxSoundTouchTypes.h",
|
||||
"SeekJob.h",
|
||||
"SeekTarget.h",
|
||||
"SelfRef.h",
|
||||
|
@ -310,7 +308,6 @@ UNIFIED_SOURCES += [
|
|||
"MemoryBlockCache.cpp",
|
||||
"QueueObject.cpp",
|
||||
"ReaderProxy.cpp",
|
||||
"RLBoxSoundTouch.cpp",
|
||||
"SeekJob.cpp",
|
||||
"TimeUnits.cpp",
|
||||
"Tracing.cpp",
|
||||
|
@ -358,7 +355,7 @@ EXTRA_JS_MODULES.media += [
|
|||
]
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
"!/security/rlbox",
|
||||
"!/media/libsoundtouch/src",
|
||||
"/caps",
|
||||
"/docshell/base",
|
||||
"/dom/base",
|
||||
|
|
|
@ -76,7 +76,7 @@ diff -u /src/cpu_detect_x86.cpp /src/cpu_detect_x86.cpp
|
|||
diff -u /src/STTypes.h /src/STTypes.h
|
||||
--- /src/STTypes.h
|
||||
+++ /src/STTypes.h
|
||||
@@ -54,12 +54,17 @@
|
||||
@@ -54,11 +54,7 @@
|
||||
#define SOUNDTOUCH_ALIGN_POINTER_16(x) ( ( (ulongptr)(x) + 15 ) & ~(ulongptr)15 )
|
||||
|
||||
|
||||
|
@ -87,30 +87,8 @@ diff -u /src/STTypes.h /src/STTypes.h
|
|||
-#endif
|
||||
+#include "soundtouch_config.h"
|
||||
|
||||
+#if defined(WIN32)
|
||||
+#if defined(BUILDING_SOUNDTOUCH)
|
||||
+#define SOUNDTOUCH_API __declspec(dllexport)
|
||||
+#else
|
||||
+#define SOUNDTOUCH_API __declspec(dllimport)
|
||||
+#endif
|
||||
+#else
|
||||
+#define SOUNDTOUCH_API
|
||||
+#endif
|
||||
|
||||
namespace soundtouch
|
||||
{
|
||||
diff -u /src/SoundTouch.h /src/SoundTouch.h
|
||||
--- /src/SoundTouch.h
|
||||
+++ /src/SoundTouch.h
|
||||
@@ -141,7 +141,7 @@
|
||||
/// tempo/pitch/rate/samplerate settings.
|
||||
#define SETTING_NOMINAL_OUTPUT_SEQUENCE 7
|
||||
|
||||
-class SoundTouch : public FIFOProcessor
|
||||
+class SOUNDTOUCH_API SoundTouch : public FIFOProcessor
|
||||
{
|
||||
private:
|
||||
/// Rate transposer class instance
|
||||
diff -u /src/FIRFilter.cpp /src/FIRFilter.cpp
|
||||
--- /src/FIRFilter.cpp
|
||||
+++ /src/FIRFilter.cpp
|
||||
|
|
|
@ -69,7 +69,7 @@ vendoring:
|
|||
keep:
|
||||
- AUTHORS
|
||||
- clear-lf.sh
|
||||
- src/RLBoxSoundTouchFactory.*
|
||||
- src/RLBoxSoundTouch*
|
||||
- src/SoundTouchFactory.*
|
||||
- src/soundtouch_config.h
|
||||
- src/soundtouch_perms.h
|
||||
|
|
|
@ -10,11 +10,13 @@
|
|||
|
||||
// Load general firefox configuration of RLBox
|
||||
#include "mozilla/rlbox/rlbox_config.h"
|
||||
#undef RLBOX_WASM2C_MODULE_NAME
|
||||
#define RLBOX_WASM2C_MODULE_NAME soundtouch
|
||||
|
||||
#ifdef MOZ_WASM_SANDBOXING_SOUNDTOUCH
|
||||
// Include the generated header file so that we are able to resolve the symbols
|
||||
// in the wasm binary
|
||||
# include "rlbox.wasm.h"
|
||||
# include "soundtouch.wasm.h"
|
||||
# define RLBOX_USE_STATIC_CALLS() rlbox_wasm2c_sandbox_lookup_symbol
|
||||
# include "mozilla/rlbox/rlbox_wasm2c_sandbox.hpp"
|
||||
#else
|
||||
|
@ -29,24 +31,48 @@
|
|||
#define ST_NO_EXCEPTION_HANDLING 1
|
||||
#include "soundtouch/SoundTouchFactory.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(BUILDING_SOUNDTOUCH)
|
||||
#define RLBOX_SOUNDTOUCH_API __declspec(dllexport)
|
||||
#else
|
||||
#define RLBOX_SOUNDTOUCH_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define RLBOX_SOUNDTOUCH_API __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class RLBoxSoundTouch {
|
||||
public:
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
RLBoxSoundTouch();
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
~RLBoxSoundTouch();
|
||||
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
void setSampleRate(uint aRate);
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
void setChannels(uint aChannels);
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
void setPitch(double aPitch);
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
void setSetting(int aSettingId, int aValue);
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
void setTempo(double aTempo);
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
uint numChannels();
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
tainted_soundtouch<uint> numSamples();
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
tainted_soundtouch<uint> numUnprocessedSamples();
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
void setRate(double aRate);
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
void putSamples(const mozilla::AudioDataValue* aSamples, uint aNumSamples);
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
uint receiveSamples(mozilla::AudioDataValue* aOutput, uint aMaxSamples);
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
void flush();
|
||||
|
||||
private:
|
||||
|
@ -56,6 +82,7 @@ class RLBoxSoundTouch {
|
|||
uint mSampleBufferSize{1};
|
||||
tainted_soundtouch<soundtouch::SoundTouch*> mTimeStretcher{nullptr};
|
||||
|
||||
RLBOX_SOUNDTOUCH_API
|
||||
void resizeSampleBuffer(uint aNewSize);
|
||||
};
|
||||
|
|
@ -10,31 +10,19 @@
|
|||
|
||||
extern "C" {
|
||||
|
||||
SOUNDTOUCH_API
|
||||
void SetSampleRate(soundtouch::SoundTouch* mTimeStretcher, uint srate);
|
||||
SOUNDTOUCH_API
|
||||
void SetChannels(soundtouch::SoundTouch* mTimeStretcher, uint numChannels);
|
||||
SOUNDTOUCH_API
|
||||
void SetPitch(soundtouch::SoundTouch* mTimeStretcher, double newPitch);
|
||||
SOUNDTOUCH_API
|
||||
void SetSetting(soundtouch::SoundTouch* mTimeStretcher, int settingId,
|
||||
int value);
|
||||
SOUNDTOUCH_API
|
||||
void SetTempo(soundtouch::SoundTouch* mTimeStretcher, double newTempo);
|
||||
SOUNDTOUCH_API
|
||||
void SetRate(soundtouch::SoundTouch* mTimeStretcher, double newRate);
|
||||
SOUNDTOUCH_API
|
||||
uint NumChannels(soundtouch::SoundTouch* mTimeStretcher);
|
||||
SOUNDTOUCH_API
|
||||
uint NumSamples(soundtouch::SoundTouch* mTimeStretcher);
|
||||
SOUNDTOUCH_API
|
||||
uint NumUnprocessedSamples(soundtouch::SoundTouch* mTimeStretcher);
|
||||
SOUNDTOUCH_API
|
||||
void PutSamples(soundtouch::SoundTouch* mTimeStretcher,
|
||||
const soundtouch::SAMPLETYPE* samples, uint numSamples);
|
||||
SOUNDTOUCH_API
|
||||
uint ReceiveSamples(soundtouch::SoundTouch* mTimeStretcher,
|
||||
soundtouch::SAMPLETYPE* output, uint maxSamples);
|
||||
SOUNDTOUCH_API
|
||||
void Flush(soundtouch::SoundTouch* mTimeStretcher);
|
||||
}
|
||||
|
|
|
@ -49,16 +49,6 @@ typedef unsigned long ulong;
|
|||
|
||||
#include "soundtouch_config.h"
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(BUILDING_SOUNDTOUCH)
|
||||
#define SOUNDTOUCH_API __declspec(dllexport)
|
||||
#else
|
||||
#define SOUNDTOUCH_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define SOUNDTOUCH_API
|
||||
#endif
|
||||
|
||||
namespace soundtouch
|
||||
{
|
||||
/// Max allowed number of channels
|
||||
|
|
|
@ -165,7 +165,7 @@ namespace soundtouch
|
|||
#define SETTING_INITIAL_LATENCY 8
|
||||
|
||||
|
||||
class SOUNDTOUCH_API SoundTouch : public FIFOProcessor
|
||||
class SoundTouch : public FIFOProcessor
|
||||
{
|
||||
private:
|
||||
/// Rate transposer class instance
|
||||
|
|
|
@ -9,14 +9,12 @@
|
|||
extern "C" namespace soundtouch
|
||||
{
|
||||
|
||||
SOUNDTOUCH_API
|
||||
soundtouch::SoundTouch*
|
||||
createSoundTouchObj()
|
||||
{
|
||||
return new soundtouch::SoundTouch();
|
||||
}
|
||||
|
||||
SOUNDTOUCH_API
|
||||
void
|
||||
destroySoundTouchObj(soundtouch::SoundTouch* aObj)
|
||||
{
|
||||
|
|
|
@ -13,11 +13,9 @@
|
|||
|
||||
extern "C" namespace soundtouch
|
||||
{
|
||||
SOUNDTOUCH_API
|
||||
soundtouch::SoundTouch*
|
||||
createSoundTouchObj();
|
||||
|
||||
SOUNDTOUCH_API
|
||||
void
|
||||
destroySoundTouchObj(soundtouch::SoundTouch* aObj);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,10 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
include("sources.mozbuild")
|
||||
EXPORTS += [
|
||||
"RLBoxSoundTouch.h",
|
||||
"RLBoxSoundTouchTypes.h",
|
||||
]
|
||||
|
||||
EXPORTS.soundtouch += [
|
||||
'FIFOSamplePipe.h',
|
||||
|
@ -15,28 +18,89 @@ EXPORTS.soundtouch += [
|
|||
'STTypes.h',
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += soundtouch_sources
|
||||
|
||||
LOCAL_INCLUDES += ["!/security/rlbox"]
|
||||
|
||||
if CONFIG['INTEL_ARCHITECTURE']:
|
||||
if CONFIG['MOZ_SAMPLE_TYPE_FLOAT32']:
|
||||
SOURCES += ['sse_optimized.cpp']
|
||||
SOURCES['sse_optimized.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
else:
|
||||
SOURCES += ['mmx_optimized.cpp']
|
||||
SOURCES['mmx_optimized.cpp'].flags += CONFIG['MMX_FLAGS']
|
||||
LOCAL_INCLUDES += [
|
||||
"/third_party/simde/",
|
||||
"/third_party/wasm2c/wasm2c/",
|
||||
]
|
||||
|
||||
SOURCES += ["RLBoxSoundTouch.cpp"]
|
||||
# Some xpcom things are #included indirectly (but not actually used), and
|
||||
# it's simpler to set MOZILLA_INTERNAL_API to make it compile than to
|
||||
# disentangle the whole thing.
|
||||
SOURCES["RLBoxSoundTouch.cpp"].flags += ["-DMOZILLA_INTERNAL_API"]
|
||||
|
||||
if CONFIG["MOZ_WASM_SANDBOXING_SOUNDTOUCH"]:
|
||||
include("/security/rlbox/rlbox.mozbuild")
|
||||
|
||||
RLBoxLibrary("soundtouch")
|
||||
|
||||
DEFINES["WASM_RT_GROW_FAILED_CRASH"] = True
|
||||
|
||||
SOURCES += [
|
||||
"/config/external/rlbox_wasm2c_sandbox/rlbox_wasm2c_thread_locals.cpp",
|
||||
"/third_party/rlbox_wasm2c_sandbox/src/wasm2c_rt_mem.c",
|
||||
"/third_party/rlbox_wasm2c_sandbox/src/wasm2c_rt_minwasi.c",
|
||||
]
|
||||
if CONFIG['OS_ARCH'] != 'WINNT':
|
||||
OS_LIBS += ["m"]
|
||||
|
||||
if CONFIG["MOZ_SAMPLE_TYPE_FLOAT32"]:
|
||||
WASM_DEFINES["MOZ_SAMPLE_TYPE_FLOAT32"] = 1
|
||||
|
||||
WASM_SOURCES += ['sse_optimized.cpp']
|
||||
|
||||
WASM_DEFINES["SOUNDTOUCH_ALLOW_SSE"] = 1
|
||||
WASM_DEFINES["SOUNDTOUCH_WASM_SIMD"] = 1
|
||||
WASM_DEFINES["SIMDE_ENABLE_NATIVE_ALIASES"] = 1
|
||||
|
||||
soundtouch_sources = WASM_SOURCES
|
||||
soundtouch_defines = WASM_DEFINES
|
||||
|
||||
if CONFIG['OS_ARCH'] != 'WINNT':
|
||||
# GCC/Clang require permissions to be explicitly set for the soundtouch
|
||||
# header.
|
||||
CXXFLAGS += ['-include', SRCDIR + '/soundtouch_perms.h']
|
||||
else:
|
||||
# Windows need alloca renamed to _alloca
|
||||
DEFINES['alloca'] = '_alloca'
|
||||
SOURCES += ["/config/external/rlbox/rlbox_thread_locals.cpp"]
|
||||
if CONFIG['INTEL_ARCHITECTURE']:
|
||||
if CONFIG['MOZ_SAMPLE_TYPE_FLOAT32']:
|
||||
SOURCES += ['sse_optimized.cpp']
|
||||
SOURCES['sse_optimized.cpp'].flags += CONFIG['SSE2_FLAGS']
|
||||
else:
|
||||
SOURCES += ['mmx_optimized.cpp']
|
||||
SOURCES['mmx_optimized.cpp'].flags += CONFIG['MMX_FLAGS']
|
||||
|
||||
if CONFIG['OS_ARCH'] != 'WINNT':
|
||||
# GCC/Clang require permissions to be explicitly set for the soundtouch
|
||||
# header.
|
||||
CXXFLAGS += ['-include', SRCDIR + '/soundtouch_perms.h']
|
||||
else:
|
||||
# Windows need alloca renamed to _alloca
|
||||
DEFINES['alloca'] = '_alloca'
|
||||
|
||||
soundtouch_sources = UNIFIED_SOURCES
|
||||
soundtouch_defines = DEFINES
|
||||
|
||||
soundtouch_sources += [
|
||||
'AAFilter.cpp',
|
||||
'cpu_detect_x86.cpp',
|
||||
'FIFOSampleBuffer.cpp',
|
||||
'FIRFilter.cpp',
|
||||
'InterpolateCubic.cpp',
|
||||
'InterpolateLinear.cpp',
|
||||
'InterpolateShannon.cpp',
|
||||
'RateTransposer.cpp',
|
||||
'RLBoxSoundTouchFactory.cpp',
|
||||
'SoundTouch.cpp',
|
||||
'SoundTouchFactory.cpp',
|
||||
'TDStretch.cpp',
|
||||
]
|
||||
|
||||
for k, v in (
|
||||
('BUILDING_SOUNDTOUCH', 1),
|
||||
# Use abort() instead of exception in SoundTouch.
|
||||
('ST_NO_EXCEPTION_HANDLING', 1)
|
||||
):
|
||||
soundtouch_defines[k] = v
|
||||
|
||||
for k, v in soundtouch_defines:
|
||||
DEFINES[k] = v
|
||||
|
||||
# We allow warnings for third-party code that can be updated from upstream.
|
||||
AllowCompilerWarnings()
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
soundtouch_sources = [
|
||||
'AAFilter.cpp',
|
||||
'cpu_detect_x86.cpp',
|
||||
'FIFOSampleBuffer.cpp',
|
||||
'FIRFilter.cpp',
|
||||
'InterpolateCubic.cpp',
|
||||
'InterpolateLinear.cpp',
|
||||
'InterpolateShannon.cpp',
|
||||
'RateTransposer.cpp',
|
||||
'RLBoxSoundTouchFactory.cpp',
|
||||
'SoundTouch.cpp',
|
||||
'SoundTouchFactory.cpp',
|
||||
'TDStretch.cpp',
|
||||
]
|
||||
|
||||
soundtouch_defines = [
|
||||
('BUILDING_SOUNDTOUCH', 1),
|
||||
# Use abort() instead of exception in SoundTouch.
|
||||
('ST_NO_EXCEPTION_HANDLING', 1)
|
||||
]
|
|
@ -4,10 +4,9 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
WASM_SOURCES += [
|
||||
"/memory/mozalloc/mozalloc.cpp",
|
||||
"/third_party/rlbox_wasm2c_sandbox/c_src/wasm2c_sandbox_wrapper.c",
|
||||
]
|
||||
include("rlbox.mozbuild")
|
||||
|
||||
RLBoxLibrary("rlbox")
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
"/third_party/simde/",
|
||||
|
@ -18,50 +17,13 @@ EXPORTS += [
|
|||
"/third_party/wasm2c/wasm2c/wasm-rt.h",
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
"!rlbox.wasm.c",
|
||||
"/third_party/wasm2c/wasm2c/wasm-rt-impl.c",
|
||||
]
|
||||
|
||||
# Configuration for the wasm2c runtime used by RLBox
|
||||
|
||||
# Enable SIMD autovectorization
|
||||
WASM_CXXFLAGS += ["-msimd128"]
|
||||
|
||||
# Use a mmap style allocation
|
||||
DEFINES["WASM_RT_USE_MMAP"] = 1
|
||||
|
||||
# Don't use internal signal handler as Firefox already provides one
|
||||
DEFINES["WASM_RT_SKIP_SIGNAL_RECOVERY"] = 1
|
||||
|
||||
# We provide a custom trap handler that calls MOZ_CRASH
|
||||
DEFINES["WASM_RT_TRAP_HANDLER"] = "moz_wasm2c_trap_handler"
|
||||
|
||||
# Don't limit the nested call depth
|
||||
DEFINES["WASM_RT_USE_STACK_DEPTH_COUNT"] = 0
|
||||
|
||||
# Configure the wasm runtime to invoke a callback when a Wasm memory growth
|
||||
# fails inside the sandbox. This information is used to annotate crash reports.
|
||||
DEFINES["WASM_RT_GROW_FAILED_HANDLER"] = "moz_wasm2c_memgrow_failed"
|
||||
|
||||
|
||||
FINAL_LIBRARY = "xul"
|
||||
|
||||
# Allow compiler warnings both in wasm compiles (because they're third-party
|
||||
# libraries), and C compiles (because they're code generated by wasm2c).
|
||||
AllowCompilerWarnings()
|
||||
|
||||
SOURCES["!rlbox.wasm.c"].flags += [
|
||||
"-Wno-unused",
|
||||
]
|
||||
|
||||
WASM_DEFINES["MOZILLA_CLIENT"] = True
|
||||
WASM_DEFINES["_WASI_EMULATED_PROCESS_CLOCKS"] = True
|
||||
WASM_DEFINES["MOZ_IN_WASM_SANDBOX"] = True
|
||||
if CONFIG["ENABLE_CLANG_PLUGIN"]:
|
||||
WASM_DEFINES["MOZ_CLANG_PLUGIN"] = True
|
||||
|
||||
SANDBOXED_WASM_LIBRARY_NAME = "rlbox.wasm"
|
||||
|
||||
if CONFIG["MOZ_WASM_SANDBOXING_HUNSPELL"]:
|
||||
include("/extensions/spellcheck/hunspell/src/sources.mozbuild")
|
||||
|
@ -99,33 +61,3 @@ if CONFIG["MOZ_WASM_SANDBOXING_WOFF2"]:
|
|||
include("/modules/woff2/sources.mozbuild")
|
||||
WASM_SOURCES += ["/modules/woff2/" + s for s in woff2_sources]
|
||||
LOCAL_INCLUDES += ["/modules/woff2/include"]
|
||||
|
||||
if CONFIG["MOZ_WASM_SANDBOXING_SOUNDTOUCH"]:
|
||||
include("/media/libsoundtouch/src/sources.mozbuild")
|
||||
WASM_SOURCES += ["/media/libsoundtouch/src/" + s for s in soundtouch_sources]
|
||||
|
||||
# Only enable SIMD if Float32 is supported
|
||||
if CONFIG["MOZ_SAMPLE_TYPE_FLOAT32"]:
|
||||
WASM_DEFINES["MOZ_SAMPLE_TYPE_FLOAT32"] = 1
|
||||
|
||||
# Enable SoundTouch SSE optimized intrinsics
|
||||
WASM_SOURCES += ["/media/libsoundtouch/src/sse_optimized.cpp"]
|
||||
WASM_DEFINES["SOUNDTOUCH_ALLOW_SSE"] = 1
|
||||
|
||||
# Enables SIMD-everywhere to map SSE intrinsics to WASMSIMD intrinsics
|
||||
WASM_DEFINES["SOUNDTOUCH_WASM_SIMD"] = 1
|
||||
WASM_DEFINES["SIMDE_ENABLE_NATIVE_ALIASES"] = 1
|
||||
|
||||
for k, v in soundtouch_defines:
|
||||
WASM_DEFINES[k] = v
|
||||
|
||||
LOCAL_INCLUDES += ["/media/libsoundtouch"]
|
||||
|
||||
# Ideally we'd also list rlbox.wasm.h as an output, but that would put the
|
||||
# generation in export rather than pre-compile, and we prefer the latter.
|
||||
GeneratedFile(
|
||||
"rlbox.wasm.c",
|
||||
script="/config/wasm2c.py",
|
||||
entry_point="wasm2c",
|
||||
inputs=["!/dist/host/bin/wasm2c" + CONFIG["HOST_BIN_SUFFIX"], "!rlbox.wasm"],
|
||||
)
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
@template
|
||||
def RLBoxLibrary(name):
|
||||
WASM_SOURCES += [
|
||||
"/memory/mozalloc/mozalloc.cpp",
|
||||
"/third_party/rlbox_wasm2c_sandbox/c_src/wasm2c_sandbox_wrapper.c",
|
||||
]
|
||||
|
||||
SOURCES += [f"!{name}.wasm.c"]
|
||||
SOURCES += ["/third_party/wasm2c/wasm2c/wasm-rt-impl.c"]
|
||||
|
||||
# Configuration for the wasm2c runtime used by RLBox
|
||||
|
||||
# Enable SIMD autovectorization
|
||||
WASM_CXXFLAGS += ["-msimd128"]
|
||||
|
||||
# Use a mmap style allocation
|
||||
DEFINES["WASM_RT_USE_MMAP"] = 1
|
||||
|
||||
# Don't use internal signal handler as Firefox already provides one
|
||||
DEFINES["WASM_RT_SKIP_SIGNAL_RECOVERY"] = 1
|
||||
|
||||
# We provide a custom trap handler that calls MOZ_CRASH
|
||||
DEFINES["WASM_RT_TRAP_HANDLER"] = "moz_wasm2c_trap_handler"
|
||||
|
||||
# Don't limit the nested call depth
|
||||
DEFINES["WASM_RT_USE_STACK_DEPTH_COUNT"] = 0
|
||||
|
||||
# Configure the wasm runtime to invoke a callback when a Wasm memory growth
|
||||
# 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",
|
||||
]
|
||||
|
||||
WASM_DEFINES["_WASI_EMULATED_PROCESS_CLOCKS"] = True
|
||||
WASM_DEFINES["MOZ_IN_WASM_SANDBOX"] = True
|
||||
if CONFIG["ENABLE_CLANG_PLUGIN"]:
|
||||
WASM_DEFINES["MOZ_CLANG_PLUGIN"] = True
|
||||
|
||||
SANDBOXED_WASM_LIBRARY_NAME = f"{name}.wasm"
|
||||
|
||||
# Ideally we'd also list {name}.wasm.h as an output, but that would put the
|
||||
# generation in export rather than pre-compile, and we prefer the latter.
|
||||
GeneratedFile(
|
||||
f"{name}.wasm.c",
|
||||
script="/config/wasm2c.py",
|
||||
entry_point="wasm2c",
|
||||
inputs=["!/dist/host/bin/wasm2c" + CONFIG["HOST_BIN_SUFFIX"], f"!{name}.wasm"],
|
||||
)
|
|
@ -2585,7 +2585,7 @@ def wasm_sandboxing_libraries():
|
|||
@depends(dependable(wasm_sandboxing_libraries), build_project)
|
||||
def default_wasm_sandboxing_libraries(libraries, build_project):
|
||||
if build_project != "tools/rusttests":
|
||||
non_default_libs = {"soundtouch"}
|
||||
non_default_libs = {}
|
||||
|
||||
return tuple(l for l in libraries if l not in non_default_libs)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче