-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmozconfig.full.emscripten
More file actions
108 lines (101 loc) · 6.15 KB
/
Copy pathmozconfig.full.emscripten
File metadata and controls
108 lines (101 loc) · 6.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Full Gecko engine -> emscripten (browser wasm). Phase 2 (WIP).
# Release (GECKO_RELEASE=1) uses its own objdir so switching debug<->release does
# NOT reconfigure/rebuild a shared tree (LTO + the objdir would otherwise thrash).
if [ "${GECKO_RELEASE:-}" = "1" ]; then
mk_add_options MOZ_OBJDIR=$topsrcdir/../obj-full-emscripten-release
else
mk_add_options MOZ_OBJDIR=$topsrcdir/../obj-full-emscripten
fi
ac_add_options --enable-application=browser
ac_add_options --target=wasm32-unknown-emscripten
# wasm: no JIT codegen, no e10s child procs / no IPC. C++ THREADS are enabled via
# emscripten -pthread (Web Workers + shared wasm linear memory) in CFLAGS below:
# Gecko needs real concurrency (IPC IOThread pump, timer thread, stylo/worker
# pools, sync cross-thread dispatch); single-threaded proved impractical at
# NS_InitXPCOM. NOTE: keep --disable-shared-memory (that's the JS-visible
# SharedArrayBuffer+Atomics feature, NOT the C++ thread memory; enabling it broke
# the ArrayBuffer-union WebIDL codegen, and content SAB isn't needed to render).
ac_add_options --disable-jit
# Portable Baseline Interpreter: runs CacheIR inline caches in portable C++ with
# NO codegen, so it works on this JIT-less wasm target and is far faster than the
# plain bytecode interpreter (SpiderMonkey's slowest tier, our only option once
# all native-codegen tiers are off). Both options are needed: the base define
# compiles PBL + gates IsPortableBaselineInterpreterEnabled; -force makes it the
# default tier eagerly (warmup 0).
ac_add_options --enable-portable-baseline-interp
ac_add_options --enable-portable-baseline-interp-force
ac_add_options --disable-shared-memory
# Trim the surface for a first headless build.
ac_add_options --disable-tests
ac_add_options --disable-debug
# Explicit -O2 (was bare --enable-optimize -> MOZ_OPTIMIZE_FLAGS=-O ~= -O1). -O2
# gives the interpreter + engine substantially faster generated code, which
# matters because content wasm runs interpreted (GECKO_WASM_INTERP) and the
# engine itself is wasm; the extra build cost is a one-time recompile.
ac_add_options --enable-optimize=-O2
# Engine LTO is OPT-IN (GECKO_LTO=1) and deliberately NOT implied by RELEASE. The
# libxul LTO link needs >54 GiB under emscripten 6.0.1 and OOM-kills the standard CI
# runner (8 cores / 31 GiB) even as ThinLTO with a --thinlto-jobs cap AND 23 GiB swap
# -- the peak is the single-process whole-program combine, which job caps can't bound.
# So default RELEASE builds skip engine LTO and take the proven non-LTO link path (the
# libxul `-shared` link quickly SIGSEGVs in wasm-ld -> relink-engine-r.sh relinks `-r`),
# relying on wasm-opt -O3 (binaryen) for wasm-level optimization instead. Set GECKO_LTO=1
# (e.g. `make ... LTO=1`) ONLY on a big-RAM host (~64 GiB+) to get cross-module LTO back.
# Toggling the env var needs an explicit `make configure`; editing this file reconfigures.
if [ "${GECKO_LTO:-}" = "1" ]; then
ac_add_options --enable-lto=thin
fi
ac_add_options --disable-crashreporter
ac_add_options --disable-updater
ac_add_options --disable-backgroundtasks
ac_add_options --disable-webrtc
# RLBox sandboxing compiles libs with a wasi target; nonsensical when the whole
# engine is already wasm. Disable it.
ac_add_options --without-wasm-sandboxed-libraries
# js-ctypes is a JS->native-library FFI (libffi); meaningless in wasm (no dlopen
# of native libs) and emscripten has no ffi.h. Disable it.
ac_add_options --disable-ctypes
# bindgen needs libclang. Default to mach bootstrap's clang; override with
# $LIBCLANG_PATH (the canonical clang-sys var) e.g. for a distro/CI libclang.
ac_add_options --with-libclang-path=${LIBCLANG_PATH:-${MOZBUILD_STATE_PATH:-$HOME/.mozbuild}/clang/lib}
# Build Gecko's modern in-tree FreeType (2.14.3) for the headless gfx font
# backend instead of emscripten's ancient bundled port (-sUSE_FREETYPE = 2.6.0,
# missing FT_Done_MM_Var / variable fonts / COLRv1). tree_freetype is enabled
# for EMSCRIPTEN in toolkit/moz.configure; expose the headers globally so every
# dir resolves <ft2build.h> to the in-tree copy, and link the in-tree lib.
# -msimd128 enables WebAssembly fixed-width 128-bit SIMD: LLVM autovectorization +
# emscripten's SSE->wasm-simd intrinsic headers, so Gecko's SIMD paths (Skia, image/
# media decode, qcms, memcpy) emit real wasm SIMD instead of scalar fallbacks. Browser
# support is universal. This is a per-TU codegen flag -> forces a full engine rebuild.
# (Also required for the in-process wasm interpreter's v128 intrinsics + the -msse2
# mozglue SIMD.cpp paths; the scalar interp TU opts back out via -mno-simd128.)
export CFLAGS="-I$topsrcdir/modules/freetype2/include -pthread -msimd128"
export CXXFLAGS="-I$topsrcdir/modules/freetype2/include -pthread -msimd128"
export LDFLAGS="-pthread"
# Rust also needs wasm SIMD enabled: -msimd128 above only affects clang (C/C++); Rust's
# equivalent is the simd128 target-feature (off by default for wasm32-unknown-emscripten).
# This turns on LLVM autovectorization for ALL Rust (Stylo, WebRender, ...) and the
# core::arch::wasm32 fast paths in SIMD-aware crates (memchr, encoding_rs) + std (built
# from source via -Z build-std). Honored as the Gecko `RUSTFLAGS` configure option,
# additive to MOZ_RUST_DEFAULT_FLAGS.
export RUSTFLAGS="-Ctarget-feature=+simd128"
# When LTO is opted in (GECKO_LTO=1), cap ThinLTO backend parallelism: lld defaults to
# one codegen job per core, and parallel jobs over the 3.4GB libxul multiply peak RAM.
# (This bounds parallelism only; it does NOT fix the single-process combine peak, which
# is why LTO still needs a big-RAM host -- see the --enable-lto note above. Bump the job
# count if the host has RAM headroom.)
if [ "${GECKO_LTO:-}" = "1" ]; then
export LDFLAGS="$LDFLAGS -Wl,--thinlto-jobs=2"
fi
# Cache compiles with sccache WHEN AVAILABLE (verified to cache emcc + host clang).
# Gated on the binary existing -- a runner/CI without sccache (the GHA build does
# not install it) must still configure -- and uses whatever path it's found at.
# 40G holds a full debug-info libxul build without self-eviction.
if command -v sccache >/dev/null 2>&1; then
ac_add_options --with-ccache=$(command -v sccache)
mk_add_options "export SCCACHE_CACHE_SIZE=40G"
fi
CC=emcc
CXX=em++
HOST_CC=clang
HOST_CXX=clang++