Merge branch 'firefox' into 'master'

Partially Port Firefox

See merge request redox-os/redox!1845
This commit is contained in:
Jeremy Soller 2026-01-27 06:05:27 -07:00
commit e66e8344e2
4 changed files with 398 additions and 22 deletions

View File

@ -1,5 +1,25 @@
#TODO missing script for building
# TODO: Using patched mozjs from servo, maybe move patcehs into to upstream patches?
[source]
tar = "https://ftp.mozilla.org/pub/nspr/releases/v4.9.6/src/nspr-4.9.6.tar.gz"
# tar = "https://ftp.mozilla.org/pub/nspr/releases/v4.9.6/src/nspr-4.9.6.tar.gz"
git = "https://github.com/willnode/mozjs"
branch = "redox"
shallow_clone = true
[build]
template = "custom"
script = """
export HOST_CC="cc"
export CC="$GNU_TARGET-gcc"
export CXX="$GNU_TARGET-g++"
export LDFLAGS="-shared"
export CFLAGS="-fPIC"
COOKBOOK_CONFIGURE_FLAGS+=(
--enable-optimize
--disable-debug
--enable-64bit
--with-pthreads
ac_cv_path_LD="$LD"
)
COOKBOOK_MAKE_JOBS=1
COOKBOOK_CONFIGURE="$COOKBOOK_SOURCE/mozjs-sys/mozjs/nsprpub/configure"
cookbook_configure
"""

View File

@ -1,3 +1,24 @@
mk_add_options MOZ_OBJDIR=COOKBOOK_BUILD
ac_add_options --target=TARGET
ac_add_options --disable-debug
ac_add_options --disable-tests
ac_add_options --target="{TARGET}"
ac_add_options --enable-bootstrap
ac_add_options --disable-audio-backends
ac_add_options --disable-crashreporter
ac_add_options --disable-updater
ac_add_options --disable-dbus
ac_add_options --disable-gecko-profiler
ac_add_options --disable-profiling
ac_add_options --disable-dmd # dark matter detector
ac_add_options --without-wasm-sandboxed-libraries # need clang wasi
# TODO: cairo-gtk3-x11-wayland or separate cairo-gtk3-wayland-only
ac_add_options --enable-default-toolkit=cairo-gtk3-x11-only
ac_add_options --enable-bootstrap=-clang # only use our clang
ac_add_options --enable-optimize
ac_add_options --with-system-nspr
ac_add_options --with-gl-provider=EGL
export MOZ_REQUIRE_SIGNING=
export MOZ_TELEMETRY_REPORTING=
export CC="TARGET_CC"
export CXX="TARGET_CXX"

View File

@ -1,31 +1,71 @@
#TODO missing script for mach: https://firefox-source-docs.mozilla.org/setup/linux_build.html
#TODO patches for quinn-udp crate, switch into git fork
# mach: https://firefox-source-docs.mozilla.org/setup/linux_build.html
# dependencies: https://packages.gentoo.org/packages/www-client/firefox/dependencies
# feature flags: https://wiki.gentoo.org/wiki/Firefox#USE_flags
[source]
tar = "https://ftp.mozilla.org/pub/firefox/releases/115.13.0esr/source/firefox-115.13.0esr.source.tar.xz"
tar = "https://ftp.mozilla.org/pub/firefox/releases/140.7.0esr/source/firefox-140.7.0esr.source.tar.xz"
[build]
template = "custom"
dependencies = [
"fontconfig",
"atk",
"cairo",
# "fontconfig",
# "atk",
# "cairo",
"dbus",
"libffi",
"freetype2",
"gdk-pixbuf",
"glib",
# "libffi",
# "freetype2",
# "gdk-pixbuf",
# "glib",
"gtk3",
"pango",
"sqlite3",
"nss-nspr",
"startup-notification",
"zlib",
"ffmpeg6",
"expat",
"libepoxy",
"pipewire",
"libxkbcommon-x11",
"libice",
"mesa-x11",
"x11proto-kb",
"xcb-proto",
"xextproto",
"nspr",
"libxrandr",
"libsm",
# TODO: Should separate clang library and runtime
"llvm21.clang"
# "sqlite3",
# "nss-nspr",
# "startup-notification",
# "zlib",
# "ffmpeg6",
# "expat",
# "libepoxy",
# "pipewire",
]
dev-dependencies = [
"host:llvm21",
"host:llvm21.dev",
"host:llvm21.runtime",
"host:llvm21.clang",
]
script = """
DYNAMIC_INIT
export MOZCONFIG="${COOKBOOK_RECIPE}/mozconfig"
cat ${COOKBOOK_RECIPE}/mozconfig > mozconfig
sed -i "s|COOKBOOK_BUILD|${COOKBOOK_BUILD}|g" mozconfig
sed -i "s|TARGET_CC|${CC}|g" mozconfig
sed -i "s|TARGET_CXX|${CXX}|g" mozconfig
sed -i "s|TARGET|${TARGET}|g" mozconfig
export MOZCONFIG="${COOKBOOK_BUILD}/mozconfig"
export PYTHONDONTWRITEBYTECODE=1
unset CC_WRAPPER
if [[ -z "$CI" ]]; then export MACH_NO_TERMINAL_FOOTER=1; fi;
# clang-sys specifics
PREFIX_INCLUDE="$COOKBOOK_HOST_SYSROOT/$TARGET/include"
export CLANGFLAGS="-I $PREFIX_INCLUDE/c++/13.2.0 -I $PREFIX_INCLUDE/c++/13.2.0/$TARGET -I $PREFIX_INCLUDE/c++/13.2.0/backward"
export CLANGFLAGS="$CLANGFLAGS -I $PREFIX_INCLUDE -I $COOKBOOK_SYSROOT/lib/clang/21/include -D__redox__"
export BINDGEN_EXTRA_CLANG_ARGS_x86_64_unknown_redox="-target x86_64-unknown-redox -nostdinc $CLANGFLAGS"
export LLVM_CONFIG_PATH="$COOKBOOK_TOOLCHAIN/bin/llvm-config"
# Don't poison the stage1 compiler (host -> host)
unset AR AS CC CXX LD LDFLAGS NM OBJCOPY OBJDUMP RANLIB READELF RUSTFLAGS STRIP
(cd ${COOKBOOK_SOURCE} && ./mach build)
rsync -a ./dist ${COOKBOOK_STAGE}
"""

View File

@ -0,0 +1,295 @@
diff --color -ruwN source/build/moz.configure/init.configure source-new/build/moz.configure/init.configure
--- source/build/moz.configure/init.configure 2026-01-07 04:09:42.000000000 +0700
+++ source-new/build/moz.configure/init.configure 2026-01-27 12:48:28.508789372 +0700
@@ -511,6 +511,8 @@
canonical_os = canonical_kernel = "NetBSD"
elif os.startswith("openbsd"):
canonical_os = canonical_kernel = "OpenBSD"
+ elif os.startswith("redox"):
+ canonical_os = canonical_kernel = "Redox"
elif os.startswith("solaris"):
canonical_os = canonical_kernel = "SunOS"
elif os.startswith("wasi") and allow_wasi:
@@ -934,6 +936,14 @@
set_define("XP_FREEBSD", target_is_freebsd)
+@depends(target)
+def target_is_redox(target):
+ if target.kernel == "Redox":
+ return True
+
+
+set_define("XP_REDOX", target_is_redox)
+
@depends(target)
def target_is_solaris(target):
diff --color -ruwN source/mozglue/misc/PlatformMutex.h source-new/mozglue/misc/PlatformMutex.h
--- source/mozglue/misc/PlatformMutex.h 2026-01-07 04:09:50.000000000 +0700
+++ source-new/mozglue/misc/PlatformMutex.h 2026-01-27 13:12:16.262181670 +0700
@@ -48,7 +48,7 @@
PlatformData* platformData();
-#if !defined(XP_WIN) && !defined(__wasi__)
+#if !defined(XP_WIN) && !defined(__wasi__) && !defined(__redox__)
void* platformData_[sizeof(pthread_mutex_t) / sizeof(void*)];
static_assert(sizeof(pthread_mutex_t) / sizeof(void*) != 0 &&
sizeof(pthread_mutex_t) % sizeof(void*) == 0,
diff --color -ruwN source/python/mozbuild/mozbuild/configure/constants.py source-new/python/mozbuild/mozbuild/configure/constants.py
--- source/python/mozbuild/mozbuild/configure/constants.py 2026-01-07 04:09:50.000000000 +0700
+++ source-new/python/mozbuild/mozbuild/configure/constants.py 2026-01-27 09:16:48.349211711 +0700
@@ -40,6 +40,7 @@
"NetBSD",
"OpenBSD",
"OSX",
+ "Redox",
"SunOS",
"WINNT",
"WASI",
@@ -55,6 +56,7 @@
"Linux",
"NetBSD",
"OpenBSD",
+ "Redox",
"SunOS",
"WINNT",
"WASI",
@@ -146,6 +148,7 @@
"Linux": "__linux__",
"NetBSD": "__NetBSD__",
"OpenBSD": "__OpenBSD__",
+ "Redox": "__redox__",
"SunOS": "__sun__",
"WINNT": "_WIN32 || __CYGWIN__",
"WASI": "__wasi__",
diff --color -ruwN source/xpcom/build/BinaryPath.h source-new/xpcom/build/BinaryPath.h
--- source/xpcom/build/BinaryPath.h 2026-01-07 04:09:59.000000000 +0700
+++ source-new/xpcom/build/BinaryPath.h 2026-01-27 12:51:20.922621049 +0700
@@ -133,11 +133,15 @@
return rv;
}
-#elif defined(ANDROID)
+#elif defined(ANDROID) || defined(XP_REDOX)
static nsresult Get(char aResult[MAXPATHLEN]) {
// On Android, we use the MOZ_ANDROID_LIBDIR variable that is set by the
// Java bootstrap code.
+#if defined(XP_REDOX)
+ const char* libDir = getenv("MOZ_REDOX_LIBDIR");
+#else
const char* libDir = getenv("MOZ_ANDROID_LIBDIR");
+#endif
if (!libDir) {
return NS_ERROR_FAILURE;
}
diff --color -ruwN source/Cargo.lock source-new/Cargo.lock
--- source/Cargo.lock 2026-01-07 04:09:41.000000000 +0700
+++ source-new/Cargo.lock 2026-01-27 19:15:51.024103229 +0700
@@ -3724,6 +3724,16 @@
checksum = "348108ab3fba42ec82ff6e9564fc4ca0247bdccdc68dd8af9764bbc79c3c8ffb"
[[package]]
+name = "libredox"
+version = "0.1.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616"
+dependencies = [
+ "bitflags 2.9.0",
+ "libc",
+]
+
+[[package]]
name = "libsqlite3-sys"
version = "0.31.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -5586,11 +5596,23 @@
[[package]]
name = "redox_syscall"
-version = "0.5.999"
+version = "0.5.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
+dependencies = [
+ "bitflags 2.9.0",
+]
[[package]]
name = "redox_users"
-version = "0.4.999"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
+dependencies = [
+ "getrandom 0.2.999",
+ "libredox",
+ "thiserror 1.999.999",
+]
[[package]]
name = "regex"
diff --color -ruwN source/Cargo.toml source-new/Cargo.toml
--- source/Cargo.toml 2026-01-07 04:09:40.000000000 +0700
+++ source-new/Cargo.toml 2026-01-27 19:14:06.467281854 +0700
@@ -134,12 +134,6 @@
# Patch r-efi to an empty crate
r-efi = { path = "build/rust/r-efi" }
-# Patch redox_users to an empty crate
-redox_users = { path = "build/rust/redox_users" }
-
-# Patch redox_syscall to an empty crate
-redox_syscall = { path = "build/rust/redox_syscall" }
-
# Patch hermit-abi to an empty crate
hermit-abi = { path = "build/rust/hermit-abi" }
diff --color -ruwN source/ipc/chromium/src/base/platform_thread.h source-new/ipc/chromium/src/base/platform_thread.h
--- source/ipc/chromium/src/base/platform_thread.h 2026-01-07 04:09:45.000000000 +0700
+++ source-new/ipc/chromium/src/base/platform_thread.h 2026-01-27 18:12:57.887138642 +0700
@@ -24,7 +24,7 @@
#else
# include <pthread.h>
typedef pthread_t PlatformThreadHandle;
-# if defined(XP_LINUX) || defined(XP_OPENBSD) || defined(XP_SOLARIS) || \
+# if defined(XP_LINUX) || defined(XP_OPENBSD) || defined(XP_REDOX) || defined(XP_SOLARIS) || \
defined(__GLIBC__)
# include <unistd.h>
typedef pid_t PlatformThreadId;
diff --color -ruwN source/mozglue/misc/TimeStamp_posix.cpp source-new/mozglue/misc/TimeStamp_posix.cpp
--- source/mozglue/misc/TimeStamp_posix.cpp 2026-01-07 04:09:50.000000000 +0700
+++ source-new/mozglue/misc/TimeStamp_posix.cpp 2026-01-27 17:59:05.200260121 +0700
@@ -13,7 +13,10 @@
// obtained with this API; see TimeDuration::Resolution;
//
+
+#if !defined(__redox__)
#include <sys/syscall.h>
+#endif
#include <time.h>
#include <unistd.h>
#include <string.h>
diff --color -ruwN source/supply-chain/audits.toml source-new/supply-chain/audits.toml
--- source/supply-chain/audits.toml 2026-01-07 04:09:51.000000000 +0700
+++ source-new/supply-chain/audits.toml 2026-01-27 19:29:15.927403772 +0700
@@ -3235,6 +3235,11 @@
version = "0.2.6"
notes = "This crate uses unsafe block, but this doesn't have network and file access. I audited code."
+[[audits.libredox]]
+who = "Wildan M <willnode@wellosoft.net>"
+criteria = "safe-to-deploy"
+version = "0.1.12"
+
[[audits.libsqlite3-sys]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
@@ -4560,10 +4565,20 @@
delta = "1.10.1 -> 1.10.2"
[[audits.redox_syscall]]
+who = "Wildan M <willnode@wellosoft.net>"
+criteria = "safe-to-deploy"
+version = "0.5.18"
+
+[[audits.redox_syscall]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.2.13 -> 0.2.16"
+[[audits.redox_users]]
+who = "Wildan M <willnode@wellosoft.net>"
+criteria = "safe-to-deploy"
+version = "0.4.6"
+
[[audits.regex]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
@@ -4676,7 +4691,7 @@
the `regex` developers in the same repository.
This crate is explicitly designed for FFI use, and should not be used directly
-by Rust code. The exported `extern \"C\"` functions are not marked as `unsafe`,
+by Rust code. The exported `extern "C"` functions are not marked as `unsafe`,
meaning that it is technically incorrect to use them from within Rust code,
however they are reasonable to use from C code.
@@ -6463,7 +6478,7 @@
who = "Makoto Kato <m_kato@ga2.so-net.ne.jp>"
criteria = "safe-to-deploy"
version = "0.1.2"
-notes = "This crate is zero-copy version of \"From\". This has no unsafe code and uses no ambient capabilities."
+notes = 'This crate is zero-copy version of "From". This has no unsafe code and uses no ambient capabilities.'
[[audits.zerofrom]]
who = "Makoto Kato <m_kato@ga2.so-net.ne.jp>"
diff --color -ruwN source/supply-chain/imports.lock source-new/supply-chain/imports.lock
--- source/supply-chain/imports.lock 2026-01-07 04:09:52.000000000 +0700
+++ source-new/supply-chain/imports.lock 2026-01-27 19:29:15.929403788 +0700
@@ -1592,7 +1592,7 @@
criteria = "safe-to-deploy"
version = "1.6.0"
notes = """
-Grepped for \"unsafe\", \"crypt\", \"cipher\", \"fs\", \"net\" - there were no
+Grepped for "unsafe", "crypt", "cipher", "fs", "net" - there were no
hits except for 8 occurrences of `unsafe`. Additional `unsafe` review comments
can be found in https://crrev.com/c/5445719.
"""
@@ -1902,7 +1902,7 @@
* Using `unsafe` in a string:
```
- src/constfn.rs: \"unsafe\" => Qualifiers::Unsafe,
+ src/constfn.rs: "unsafe" => Qualifiers::Unsafe,
```
* Using `std::fs` in `build/build.rs` to write `${OUT_DIR}/version.expr`
@@ -2104,6 +2104,7 @@
user-id = 213776 # divviup-github-automation
start = "2020-09-28"
end = "2026-01-07"
+renew = false
[[audits.isrg.audits.base64]]
who = "Tim Geoghegan <timg@letsencrypt.org>"
diff --color -ruwN source/build/rust/redox_syscall/Cargo.toml source-new/build/rust/redox_syscall/Cargo.toml
--- source/build/rust/redox_syscall/Cargo.toml 2026-01-07 04:09:41.000000000 +0700
+++ source-new/build/rust/redox_syscall/Cargo.toml 1970-01-01 07:00:00.000000000 +0700
@@ -1,8 +0,0 @@
-[package]
-name = "redox_syscall"
-version = "0.5.999"
-edition = "2018"
-license = "MPL-2.0"
-
-[lib]
-path = "lib.rs"
diff --color -ruwN source/build/rust/redox_syscall/lib.rs source-new/build/rust/redox_syscall/lib.rs
--- source/build/rust/redox_syscall/lib.rs 2026-01-07 04:09:41.000000000 +0700
+++ source-new/build/rust/redox_syscall/lib.rs 1970-01-01 07:00:00.000000000 +0700
@@ -1,3 +0,0 @@
-/* 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/. */
diff --color -ruwN source/build/rust/redox_users/Cargo.toml source-new/build/rust/redox_users/Cargo.toml
--- source/build/rust/redox_users/Cargo.toml 2026-01-07 04:09:41.000000000 +0700
+++ source-new/build/rust/redox_users/Cargo.toml 1970-01-01 07:00:00.000000000 +0700
@@ -1,8 +0,0 @@
-[package]
-name = "redox_users"
-version = "0.4.999"
-edition = "2018"
-license = "MPL-2.0"
-
-[lib]
-path = "lib.rs"
diff --color -ruwN source/build/rust/redox_users/lib.rs source-new/build/rust/redox_users/lib.rs
--- source/build/rust/redox_users/lib.rs 2026-01-07 04:09:41.000000000 +0700
+++ source-new/build/rust/redox_users/lib.rs 1970-01-01 07:00:00.000000000 +0700
@@ -1,3 +0,0 @@
-/* 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/. */