From 2e26cad8bc42d3e064277784ed5113a529eea3b6 Mon Sep 17 00:00:00 2001 From: berkenar1 <73941606+berkenar1@users.noreply.github.com> Date: Thu, 26 Feb 2026 12:46:04 +0300 Subject: [PATCH] added zen-browser port --- www/zen-browser/.cargo/config.toml.disabled | 107 ++++++++ www/zen-browser/Makefile | 174 +++++++++++++ www/zen-browser/Makefile.options | 15 ++ www/zen-browser/distinfo | 3 + www/zen-browser/files/PATCHES.md | 240 ++++++++++++++++++ www/zen-browser/files/README-FREEBSD.md | 67 +++++ www/zen-browser/files/README.md | 128 ++++++++++ www/zen-browser/files/byteswap.h | 24 ++ www/zen-browser/files/check_patches.sh | 101 ++++++++ www/zen-browser/files/endian.h | 11 + www/zen-browser/files/malloc.h | 43 ++++ www/zen-browser/files/mozconfig | 29 +++ ...rowser_extensions_newtab_mach__commands.py | 17 ++ ...edia_webrtc_libwebrtc__overrides_moz.build | 11 + .../files/patch-memory_build_Fallback.cpp | 14 + .../files/patch-memory_build_mozjemalloc.cpp | 27 ++ .../files/patch-memory_build_mozmemory.h | 17 ++ .../patch-memory_build_mozmemory__wrap.cpp | 16 ++ .../files/patch-memory_mozalloc_mozalloc.cpp | 20 ++ .../files/patch-memory_mozalloc_mozalloc.h | 16 ++ .../files/patch-python_sites_mach.txt | 10 + ...top__capture_linux_wayland__egl__dmabuf.cc | 19 ++ ...y_libwebrtc_third__party_pffft_src_pffft.c | 10 + .../patch-third_party_libwebrtc_BUILD.gn | 11 + ...arty_libwebrtc_build_config_BUILDCONFIG.gn | 141 ++++++++++ www/zen-browser/files/test_malloc_wrapper.c | 111 ++++++++ www/zen-browser/pkg-descr | 19 ++ www/zen-browser/pkg-plist | 0 28 files changed, 1401 insertions(+) create mode 100644 www/zen-browser/.cargo/config.toml.disabled create mode 100644 www/zen-browser/Makefile create mode 100644 www/zen-browser/Makefile.options create mode 100644 www/zen-browser/distinfo create mode 100644 www/zen-browser/files/PATCHES.md create mode 100644 www/zen-browser/files/README-FREEBSD.md create mode 100644 www/zen-browser/files/README.md create mode 100644 www/zen-browser/files/byteswap.h create mode 100755 www/zen-browser/files/check_patches.sh create mode 100644 www/zen-browser/files/endian.h create mode 100644 www/zen-browser/files/malloc.h create mode 100644 www/zen-browser/files/mozconfig create mode 100644 www/zen-browser/files/patch-browser_extensions_newtab_mach__commands.py create mode 100644 www/zen-browser/files/patch-dom_media_webrtc_libwebrtc__overrides_moz.build create mode 100644 www/zen-browser/files/patch-memory_build_Fallback.cpp create mode 100644 www/zen-browser/files/patch-memory_build_mozjemalloc.cpp create mode 100644 www/zen-browser/files/patch-memory_build_mozmemory.h create mode 100644 www/zen-browser/files/patch-memory_build_mozmemory__wrap.cpp create mode 100644 www/zen-browser/files/patch-memory_mozalloc_mozalloc.cpp create mode 100644 www/zen-browser/files/patch-memory_mozalloc_mozalloc.h create mode 100644 www/zen-browser/files/patch-python_sites_mach.txt create mode 100644 www/zen-browser/files/patch-third__party_libwebrtc_modules_desktop__capture_linux_wayland__egl__dmabuf.cc create mode 100644 www/zen-browser/files/patch-third__party_libwebrtc_third__party_pffft_src_pffft.c create mode 100644 www/zen-browser/files/patch-third_party_libwebrtc_BUILD.gn create mode 100644 www/zen-browser/files/patch-third_party_libwebrtc_build_config_BUILDCONFIG.gn create mode 100644 www/zen-browser/files/test_malloc_wrapper.c create mode 100644 www/zen-browser/pkg-descr create mode 100644 www/zen-browser/pkg-plist diff --git a/www/zen-browser/.cargo/config.toml.disabled b/www/zen-browser/.cargo/config.toml.disabled new file mode 100644 index 000000000000..77912728b708 --- /dev/null +++ b/www/zen-browser/.cargo/config.toml.disabled @@ -0,0 +1,107 @@ +[source.cargo] +directory = '/home/berke/workdir/www/zen-browser/work/cargo-crates' +[source.crates-io] +replace-with = 'cargo' +[patch.'https://github.com/mozilla/midir.git'] +midir = { path = '/home/berke/workdir/www/zen-browser/work/midir-37ad39de3382c2aad0758dab49ba545331a2257d' } +[patch.'https://github.com/mozilla/neqo'] +mtu = { path = '/home/berke/workdir/www/zen-browser/work/neqo-0.16.1/mtu' } +neqo-bin = { path = '/home/berke/workdir/www/zen-browser/work/neqo-0.16.1/neqo-bin' } +neqo-common = { path = '/home/berke/workdir/www/zen-browser/work/neqo-0.16.1/neqo-common' } +neqo-crypto = { path = '/home/berke/workdir/www/zen-browser/work/neqo-0.16.1/neqo-crypto' } +neqo-http3 = { path = '/home/berke/workdir/www/zen-browser/work/neqo-0.16.1/neqo-http3' } +neqo-qpack = { path = '/home/berke/workdir/www/zen-browser/work/neqo-0.16.1/neqo-qpack' } +neqo-transport = { path = '/home/berke/workdir/www/zen-browser/work/neqo-0.16.1/neqo-transport' } +neqo-udp = { path = '/home/berke/workdir/www/zen-browser/work/neqo-0.16.1/neqo-udp' } +[patch.'https://github.com/mozilla/audioipc'] +audioipc2 = { path = '/home/berke/workdir/www/zen-browser/work/audioipc-82fe7fa7e3aaa35468137239a0e4c2f867457214/audioipc' } +audioipc2-client = { path = '/home/berke/workdir/www/zen-browser/work/audioipc-82fe7fa7e3aaa35468137239a0e4c2f867457214/client' } +audioipc2-server = { path = '/home/berke/workdir/www/zen-browser/work/audioipc-82fe7fa7e3aaa35468137239a0e4c2f867457214/server' } +[patch.'https://github.com/FirefoxGraphics/aa-stroke'] +aa-stroke = { path = '/home/berke/workdir/www/zen-browser/work/aa-stroke-a821fa621c2def48e90c82774b4c6563b5a8ea4a' } +[patch.'https://github.com/glandium/rust-objc'] +objc = { path = '/home/berke/workdir/www/zen-browser/work/rust-objc-4de89f5aa9851ceca4d40e7ac1e2759410c04324' } +[patch.'https://github.com/beurdouche/mls-platform-api'] +mls-platform-api = { path = '/home/berke/workdir/www/zen-browser/work/mls-platform-api-5d88241b9765cae3669aba21f0946bd3700f7db1' } +[patch.'https://github.com/rust-lang/rust-bindgen'] +bindgen = { path = '/home/berke/workdir/www/zen-browser/work/rust-bindgen-9366e0af8da529c958b4cd4fcbe492d951c86f5c/bindgen' } +[patch.'https://github.com/mozilla/cubeb-pulse-rs'] +cubeb-pulse = { path = '/home/berke/workdir/www/zen-browser/work/cubeb-pulse-rs-4e3ea4bbc582705a4e7d9220679525283c035a7e' } +pulse = { path = '/home/berke/workdir/www/zen-browser/work/cubeb-pulse-rs-4e3ea4bbc582705a4e7d9220679525283c035a7e/pulse-rs' } +pulse-ffi = { path = '/home/berke/workdir/www/zen-browser/work/cubeb-pulse-rs-4e3ea4bbc582705a4e7d9220679525283c035a7e/pulse-ffi' } +[patch.'https://github.com/mozilla/cubeb-coreaudio-rs'] +coreaudio-sys-utils = { path = '/home/berke/workdir/www/zen-browser/work/cubeb-coreaudio-rs-7b996ab09d0a57a2345cd1c4509f0a8491cd3d66/coreaudio-sys-utils' } +cubeb-coreaudio = { path = '/home/berke/workdir/www/zen-browser/work/cubeb-coreaudio-rs-7b996ab09d0a57a2345cd1c4509f0a8491cd3d66' } +[patch.'https://github.com/franziskuskiefer/cose-rust'] +cose = { path = '/home/berke/workdir/www/zen-browser/work/cose-rust-43c22248d136c8b38fe42ea709d08da6355cf04b' } +[patch.'https://github.com/hsivonen/any_all_workaround'] +any_all_workaround = { path = '/home/berke/workdir/www/zen-browser/work/any_all_workaround-7fb1b7034c9f172aade21ee1c8554e8d8a48af80' } +[patch.'https://github.com/erichdongubler-contrib/hashlink'] +hashlink = { path = '/home/berke/workdir/www/zen-browser/work/hashlink-76dc47a12af5829c1e8bf4834e38b410dec2aeff' } +[patch.'https://github.com/mozilla/application-services'] +context_id = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/context_id' } +error-support = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/error' } +error-support-macros = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/error/macros' } +filter_adult = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/filter_adult' } +firefox-versioning = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/firefox-versioning' } +init_rust_components = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/init_rust_components' } +interrupt-support = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/interrupt' } +jwcrypto = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/jwcrypto' } +logins = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/logins' } +nss = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/rc_crypto/nss' } +nss_build_common = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/rc_crypto/nss/nss_build_common' } +nss_sys = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/rc_crypto/nss/nss_sys' } +payload-support = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/payload' } +rc_crypto = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/rc_crypto' } +relevancy = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/relevancy' } +remote_settings = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/remote_settings' } +search = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/search' } +sql-support = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/sql' } +suggest = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/suggest' } +sync-guid = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/guid' } +sync15 = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/sync15' } +tabs = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/tabs' } +tracing-support = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/tracing' } +types = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/support/types' } +viaduct = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/viaduct' } +webext-storage = { path = '/home/berke/workdir/www/zen-browser/work/application-services-cd04a4d1a74294ab08434d7a5a8152d25d25e53c/components/webext-storage' } +[patch.'https://github.com/hsivonen/chardetng_c'] +chardetng_c = { path = '/home/berke/workdir/www/zen-browser/work/chardetng_c-2f0aba284677d098de14f91ffe5a9e5b9a4922c2' } +[patch.'https://github.com/FirefoxGraphics/wpf-gpu-raster'] +wpf-gpu-raster = { path = '/home/berke/workdir/www/zen-browser/work/wpf-gpu-raster-99979da091fd58fba8477e7fcdf5ec0727102916' } +[patch.'https://github.com/hsivonen/chardetng'] +chardetng = { path = '/home/berke/workdir/www/zen-browser/work/chardetng-a07d20273ce36146adaf76bd667dd57bd7b3508b' } +[patch.'https://github.com/beurdouche/nss-gk-api'] +nss-gk-api = { path = '/home/berke/workdir/www/zen-browser/work/nss-gk-api-e48a946811ffd64abc78de3ee284957d8d1c0d63' } +[patch.'https://github.com/jfkthame/mapped_hyph.git'] +mapped_hyph = { path = '/home/berke/workdir/www/zen-browser/work/mapped_hyph-eff105f6ad7ec9b79816cfc1985a28e5340ad14b' } +[patch.'https://github.com/glandium/allocator-api2'] +allocator-api2 = { path = '/home/berke/workdir/www/zen-browser/work/allocator-api2-ad5f3d56a5a4519eff52af4ff85293431466ef5c' } +[patch.'https://github.com/martinthomson/ohttp.git'] +bhttp = { path = '/home/berke/workdir/www/zen-browser/work/ohttp-bf6a983845cc0b540effb3a615e92d914dfcfd0b/bhttp' } +ohttp = { path = '/home/berke/workdir/www/zen-browser/work/ohttp-bf6a983845cc0b540effb3a615e92d914dfcfd0b/ohttp' } +[patch.'https://github.com/beurdouche/mls-rs'] +mls-rs = { path = '/home/berke/workdir/www/zen-browser/work/mls-rs-b747d7efb85a776b97ad8afa8d1b32893fa5efa3/mls-rs' } +mls-rs-codec = { path = '/home/berke/workdir/www/zen-browser/work/mls-rs-b747d7efb85a776b97ad8afa8d1b32893fa5efa3/mls-rs-codec' } +mls-rs-codec-derive = { path = '/home/berke/workdir/www/zen-browser/work/mls-rs-b747d7efb85a776b97ad8afa8d1b32893fa5efa3/mls-rs-codec-derive' } +mls-rs-core = { path = '/home/berke/workdir/www/zen-browser/work/mls-rs-b747d7efb85a776b97ad8afa8d1b32893fa5efa3/mls-rs-core' } +mls-rs-crypto-hpke = { path = '/home/berke/workdir/www/zen-browser/work/mls-rs-b747d7efb85a776b97ad8afa8d1b32893fa5efa3/mls-rs-crypto-hpke' } +mls-rs-crypto-nss = { path = '/home/berke/workdir/www/zen-browser/work/mls-rs-b747d7efb85a776b97ad8afa8d1b32893fa5efa3/mls-rs-crypto-nss' } +mls-rs-crypto-traits = { path = '/home/berke/workdir/www/zen-browser/work/mls-rs-b747d7efb85a776b97ad8afa8d1b32893fa5efa3/mls-rs-crypto-traits' } +mls-rs-identity-x509 = { path = '/home/berke/workdir/www/zen-browser/work/mls-rs-b747d7efb85a776b97ad8afa8d1b32893fa5efa3/mls-rs-identity-x509' } +mls-rs-provider-sqlite = { path = '/home/berke/workdir/www/zen-browser/work/mls-rs-b747d7efb85a776b97ad8afa8d1b32893fa5efa3/mls-rs-provider-sqlite' } +[patch.'https://github.com/servo/unicode-bidi'] +unicode-bidi = { path = '/home/berke/workdir/www/zen-browser/work/unicode-bidi-ca612daf1c08c53abe07327cb3e6ef6e0a760f0c' } +[patch.'https://github.com/servo/rust-cssparser'] +cssparser = { path = '/home/berke/workdir/www/zen-browser/work/rust-cssparser-958a3f098acb92ddacdce18a7ef2c4a87ac3326f' } +cssparser-macros = { path = '/home/berke/workdir/www/zen-browser/work/rust-cssparser-958a3f098acb92ddacdce18a7ef2c4a87ac3326f/macros' } +[patch.'https://github.com/gfx-rs/wgpu'] +naga = { path = '/home/berke/workdir/www/zen-browser/work/wgpu-6beea7c20df563883848933f70cdd0ea99fc7144/naga' } +wgpu-core = { path = '/home/berke/workdir/www/zen-browser/work/wgpu-6beea7c20df563883848933f70cdd0ea99fc7144/wgpu-core' } +wgpu-core-deps-apple = { path = '/home/berke/workdir/www/zen-browser/work/wgpu-6beea7c20df563883848933f70cdd0ea99fc7144/wgpu-core/platform-deps/apple' } +wgpu-core-deps-windows-linux-android = { path = '/home/berke/workdir/www/zen-browser/work/wgpu-6beea7c20df563883848933f70cdd0ea99fc7144/wgpu-core/platform-deps/windows-linux-android' } +wgpu-hal = { path = '/home/berke/workdir/www/zen-browser/work/wgpu-6beea7c20df563883848933f70cdd0ea99fc7144/wgpu-hal' } +wgpu-types = { path = '/home/berke/workdir/www/zen-browser/work/wgpu-6beea7c20df563883848933f70cdd0ea99fc7144/wgpu-types' } +[patch.'https://github.com/mozilla/mp4parse-rust'] +mp4parse = { path = '/home/berke/workdir/www/zen-browser/work/mp4parse-rust-f955be5d2a04a631c0f1777d6f35370ea1a99e2d/mp4parse' } +mp4parse_capi = { path = '/home/berke/workdir/www/zen-browser/work/mp4parse-rust-f955be5d2a04a631c0f1777d6f35370ea1a99e2d/mp4parse_capi' } diff --git a/www/zen-browser/Makefile b/www/zen-browser/Makefile new file mode 100644 index 000000000000..9165227e4273 --- /dev/null +++ b/www/zen-browser/Makefile @@ -0,0 +1,174 @@ +PORTNAME= zen-browser +DISTVERSION= 1.18.5b +CATEGORIES= www wayland +MASTER_SITES= https://github.com/zen-browser/desktop/releases/download/${DISTVERSION}/ +DISTFILES= zen.source.tar.zst + +MAINTAINER= berke.nar@proton.me +COMMENT= Zen Browser - Firefox-based privacy-focused browser +WWW= https://zen-browser.app + +LICENSE= MPL20 + +BUILD_DEPENDS= rust>=1.0:lang/rust \ + nspr>=4.32:devel/nspr \ + nss>=3.118:security/nss \ + libevent>=2.1.8:devel/libevent \ + harfbuzz>=10.1.0:print/harfbuzz \ + graphite2>=1.3.14:graphics/graphite2 \ + png>=1.6.45:graphics/png \ + dav1d>=1.0.0:multimedia/dav1d \ + libvpx>=1.15.0:multimedia/libvpx \ + ${PYTHON_PKGNAMEPREFIX}sqlite3>0:databases/py-sqlite3@${PY_FLAVOR} \ + v4l_compat>0:multimedia/v4l_compat \ + nasm:devel/nasm \ + yasm:devel/yasm \ + zip:archivers/zip \ + ${LOCALBASE}/share/wasi-sysroot/lib/wasm32-wasi/libc++abi.a:devel/wasi-libcxx20 \ + ${LOCALBASE}/share/wasi-sysroot/lib/wasm32-wasi/libc.a:devel/wasi-libc@20 \ + wasi-compiler-rt20>0:devel/wasi-compiler-rt20 + +LIB_DEPENDS= libsndio.so:audio/sndio + +USES= tar:zst gmake python:3.11,build compiler:c17-lang \ + desktop-file-utils gl gnome localbase:ldflags pkgconfig + +BINARY_ALIAS+= python3=${PYTHON_CMD} + +USE_GECKO= gecko +USE_MOZILLA= -sqlite +USE_GL= gl +USE_GNOME= cairo gdkpixbuf2 gtk30 + +WRKSRC= ${WRKDIR} +BUILD_WRKSRC= ${WRKSRC}/obj-x86_64-unknown-freebsd15.0 + +# Zen Browser is built on Firefox, so the compiled binary is named "firefox" +MOZILLA= firefox +MOZILLA_BIN= firefox-bin +ELF_FEATURES= +wxneeded:dist/bin/firefox +wxneeded:dist/bin/firefox-bin + +WASI_SYSROOT= ${LOCALBASE}/share/wasi-sysroot + +LDFLAGS+= -lpthread + +CONFIGURE_ENV+= RUSTC=${LOCALBASE}/bin/rustc \ + CARGO=${LOCALBASE}/bin/cargo \ + WASI_SYSROOT=${WASI_SYSROOT} \ + MOZCONFIG=${WRKSRC}/.mozconfig \ + LIBS="-lpthread" \ + PIP_NO_INDEX=1 + +MAKE_ENV+= RUSTC=${LOCALBASE}/bin/rustc \ + CARGO=${LOCALBASE}/bin/cargo \ + RUSTUP_HOME=/nonexistent \ + CARGO_HOME=/nonexistent \ + MOZCONFIG=${WRKSRC}/.mozconfig \ + LIBS="-lpthread" \ + PIP_NO_INDEX=1 \ + PATH=${LOCALBASE}/bin:${LOCALBASE}/sbin:/bin:/sbin:/usr/bin:/usr/sbin + +post-extract: + @if [ -f ${WRKSRC}/media/libcubeb/src/cubeb_alsa.c ]; then \ + ${SED} -i '' '1s/^/#include \n/' ${WRKSRC}/media/libcubeb/src/cubeb_alsa.c; \ + fi +# Add FreeBSD support to all libwebrtc moz.build files (they only have OpenBSD) + @${ECHO} "Adding FreeBSD to libwebrtc moz.build files..." + @${FIND} ${WRKSRC}/third_party/libwebrtc -name 'moz.build' \ + -exec ${SED} -i '' \ + -e 's|CONFIG\["OS_TARGET"\] == "OpenBSD"|CONFIG["OS_TARGET"] == "OpenBSD" or CONFIG["OS_TARGET"] == "FreeBSD"|g' \ + {} \; + +do-configure: + @${RM} ${WRKSRC}/.mozconfig +# Application and Zen branding + @${ECHO} "ac_add_options --enable-application=browser" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --with-branding=browser/branding/release" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --enable-release" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --disable-updater" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --disable-tests" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --disable-debug" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --disable-debug-symbols" >> ${WRKSRC}/.mozconfig +# Build toolchain + @${ECHO} "ac_add_options --enable-linker=lld" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --with-libclang-path=${LOCALBASE}/llvm${LLVM_VERSION}/lib" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --with-wasi-sysroot=${WASI_SYSROOT}" >> ${WRKSRC}/.mozconfig +# System libraries + @${ECHO} "ac_add_options --with-system-nspr" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --with-system-nss" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --with-system-libevent" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --with-system-jpeg=${LOCALBASE}" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --with-system-png" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --with-system-libvpx" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --with-system-webp" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --with-system-pixman" >> ${WRKSRC}/.mozconfig +# Audio/media + @${ECHO} "ac_add_options --enable-sndio" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --enable-webrtc" >> ${WRKSRC}/.mozconfig + @${ECHO} "ac_add_options --enable-jemalloc" >> ${WRKSRC}/.mozconfig +# Exports + @${ECHO} "export LDFLAGS='${LDFLAGS}'" >> ${WRKSRC}/.mozconfig + @${ECHO} "export LIBS='-lpthread'" >> ${WRKSRC}/.mozconfig + @${ECHO} "mk_add_options MOZ_MAKE_FLAGS='-j${MAKE_JOBS_NUMBER}'" >> ${WRKSRC}/.mozconfig + @${ECHO} "mk_add_options MOZ_OBJDIR=${BUILD_WRKSRC}" >> ${WRKSRC}/.mozconfig + cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} ${PYTHON_CMD} ${WRKSRC}/mach configure + +do-build: + cd ${WRKSRC} && \ + ${SED} -e '/#ifndef/,/#endif/d' \ + -e 's/@REPLACE_NAME@/vendored-sources/g' \ + -e 's|@top_srcdir@|${WRKSRC}|g' \ + -e 's|@VENDORED_DIRECTORY@|third_party/rust|g' \ + .cargo/config.toml.in > .cargo/config.toml && \ + ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${WRKSRC}/mach build + +MOZILLA_OBJDIR= ${BUILD_WRKSRC} +DISTDIR_BUILD= ${MOZILLA_OBJDIR}/dist/bin + +do-install: + ${MKDIR} ${STAGEDIR}${PREFIX}/lib/${PORTNAME} +# Copy dist/bin, resolving symlinks to real files (-L follows symlinks) + cd ${DISTDIR_BUILD} && \ + ${CP} -RLp . ${STAGEDIR}${PREFIX}/lib/${PORTNAME} +# Remove any remaining dangling symlinks + @${FIND} ${STAGEDIR}${PREFIX}/lib/${PORTNAME} -type l ! -exec test -e {} \; -delete 2>/dev/null || true +# Remove empty directories left over from build tree + @${FIND} ${STAGEDIR}${PREFIX}/lib/${PORTNAME} -type d -empty -delete 2>/dev/null || true +# Fix permissions on executables and shared libraries + ${CHMOD} +x ${STAGEDIR}${PREFIX}/lib/${PORTNAME}/${MOZILLA} + ${CHMOD} +x ${STAGEDIR}${PREFIX}/lib/${PORTNAME}/${MOZILLA_BIN} + ${CHMOD} +x ${STAGEDIR}${PREFIX}/lib/${PORTNAME}/plugin-container + -${CHMOD} +x ${STAGEDIR}${PREFIX}/lib/${PORTNAME}/pingsender + -${CHMOD} +x ${STAGEDIR}${PREFIX}/lib/${PORTNAME}/glxtest + -${CHMOD} +x ${STAGEDIR}${PREFIX}/lib/${PORTNAME}/vaapitest + ${FIND} ${STAGEDIR}${PREFIX}/lib/${PORTNAME} -name '*.so' -exec ${CHMOD} +x {} \; +# Create wrapper script + ${MKDIR} ${STAGEDIR}${PREFIX}/bin + @${ECHO} '#!/bin/sh' > ${STAGEDIR}${PREFIX}/bin/${PORTNAME} + @${ECHO} 'export LD_LIBRARY_PATH=${PREFIX}/lib/${PORTNAME}' >> ${STAGEDIR}${PREFIX}/bin/${PORTNAME} + @${ECHO} 'exec ${PREFIX}/lib/${PORTNAME}/${MOZILLA} "$$@"' >> ${STAGEDIR}${PREFIX}/bin/${PORTNAME} + ${CHMOD} +x ${STAGEDIR}${PREFIX}/bin/${PORTNAME} +# Install .desktop file + ${MKDIR} ${STAGEDIR}${PREFIX}/share/applications + @${ECHO} '[Desktop Entry]' > ${STAGEDIR}${PREFIX}/share/applications/${PORTNAME}.desktop + @${ECHO} 'Type=Application' >> ${STAGEDIR}${PREFIX}/share/applications/${PORTNAME}.desktop + @${ECHO} 'Name=Zen Browser' >> ${STAGEDIR}${PREFIX}/share/applications/${PORTNAME}.desktop + @${ECHO} 'Comment=Web Browser' >> ${STAGEDIR}${PREFIX}/share/applications/${PORTNAME}.desktop + @${ECHO} 'Exec=${PORTNAME} %u' >> ${STAGEDIR}${PREFIX}/share/applications/${PORTNAME}.desktop + @${ECHO} 'Icon=${PORTNAME}' >> ${STAGEDIR}${PREFIX}/share/applications/${PORTNAME}.desktop + @${ECHO} 'Terminal=false' >> ${STAGEDIR}${PREFIX}/share/applications/${PORTNAME}.desktop + @${ECHO} 'Categories=Network;WebBrowser;' >> ${STAGEDIR}${PREFIX}/share/applications/${PORTNAME}.desktop + @${ECHO} 'MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;' >> ${STAGEDIR}${PREFIX}/share/applications/${PORTNAME}.desktop + @${ECHO} 'StartupNotify=true' >> ${STAGEDIR}${PREFIX}/share/applications/${PORTNAME}.desktop + @${ECHO} 'StartupWMClass=zen-browser' >> ${STAGEDIR}${PREFIX}/share/applications/${PORTNAME}.desktop +# Install icon + ${MKDIR} ${STAGEDIR}${PREFIX}/share/pixmaps + if [ -f ${DISTDIR_BUILD}/browser/chrome/icons/default/default128.png ]; then \ + ${CP} ${DISTDIR_BUILD}/browser/chrome/icons/default/default128.png \ + ${STAGEDIR}${PREFIX}/share/pixmaps/${PORTNAME}.png; \ + elif [ -f ${DISTDIR_BUILD}/browser/chrome/icons/default/default48.png ]; then \ + ${CP} ${DISTDIR_BUILD}/browser/chrome/icons/default/default48.png \ + ${STAGEDIR}${PREFIX}/share/pixmaps/${PORTNAME}.png; \ + fi + +.include diff --git a/www/zen-browser/Makefile.options b/www/zen-browser/Makefile.options new file mode 100644 index 000000000000..d5a417480eb3 --- /dev/null +++ b/www/zen-browser/Makefile.options @@ -0,0 +1,15 @@ +# -*- makefile-bsdmake -*- + +OPTIONS_DEFINE+= CANBERRA DBUS DEBUG FFMPEG \ + LIBPROXY LTO OPTIMIZED_CFLAGS PROFILE TEST + +OPTIONS_DEFAULT+= DBUS FFMPEG OPTIMIZED_CFLAGS PROFILE \ + ${OPTIONS_GROUP_AUDIO:NALSA} + +OPTIONS_GROUP+= AUDIO +OPTIONS_GROUP_AUDIO= ALSA JACK PULSEAUDIO SNDIO + +AUDIO_DESC?= Extra cubeb audio backends (OSS is always available) +CANBERRA_DESC?= Sound theme alerts +LIBPROXY_DESC?= Proxy support via libproxy +LIGHTNING_DESC?= Calendar extension diff --git a/www/zen-browser/distinfo b/www/zen-browser/distinfo new file mode 100644 index 000000000000..6d20c7d19b94 --- /dev/null +++ b/www/zen-browser/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1770497509 +SHA256 (zen.source.tar.zst) = e14afc1a552e187becffcb55274a60c452b1fd027e40cc70d9c9d85283372660 +SIZE (zen.source.tar.zst) = 931480184 diff --git a/www/zen-browser/files/PATCHES.md b/www/zen-browser/files/PATCHES.md new file mode 100644 index 000000000000..82dda0038394 --- /dev/null +++ b/www/zen-browser/files/PATCHES.md @@ -0,0 +1,240 @@ +# Memory Allocation Patch Reference + +This document provides a detailed reference for each memory allocation patch in the FreeBSD Zen Browser port. + +## Patch Overview + +| Patch File | Target | Purpose | +|------------|--------|---------| +| `patch-memory_build_Fallback.cpp` | `memory/build/Fallback.cpp` | Include malloc_np.h and define HAVE_MEMALIGN | +| `patch-memory_build_mozjemalloc.cpp` | `memory/build/mozjemalloc.cpp` | Remove noexcept(true) and disable RTLD_DEEPBIND | +| `patch-memory_build_mozmemory.h` | `memory/build/mozmemory.h` | Conditional noexcept removal | +| `patch-memory_build_mozmemory__wrap.cpp` | `memory/build/mozmemory_wrap.cpp` | Adapt wrapper declarations | +| `patch-memory_mozalloc_mozalloc.cpp` | `memory/mozalloc/mozalloc.cpp` | Provide memalign() for non-jemalloc builds | +| `patch-memory_mozalloc_mozalloc.h` | `memory/mozalloc/mozalloc.h` | Remove noexcept from mozalloc API | + +## Detailed Patch Analysis + +### patch-memory_build_Fallback.cpp + +**Purpose:** Enable the fallback memory allocator to work on FreeBSD + +**Changes:** +```cpp ++#ifdef __FreeBSD__ ++# include ++# define HAVE_MEMALIGN 1 ++#endif +``` + +**Rationale:** +- Includes FreeBSD's non-portable malloc extensions (`malloc_np.h`) +- Defines `HAVE_MEMALIGN` to indicate memalign is available (via our wrapper) +- Used when system allocator is preferred over jemalloc + +### patch-memory_build_mozjemalloc.cpp + +**Purpose:** Adapt Mozilla's jemalloc for FreeBSD + +**Changes:** +1. Remove `noexcept(true)` from malloc declarations: +```cpp ++#if defined(__FreeBSD__) ++#define NOTHROW_MALLOC_DECL(...) \ ++ MOZ_MEMORY_API MACRO_CALL(GENERIC_MALLOC_DECL, (, __VA_ARGS__)) ++#else + #define NOTHROW_MALLOC_DECL(...) \ + MOZ_MEMORY_API MACRO_CALL(GENERIC_MALLOC_DECL, (noexcept(true), __VA_ARGS__)) ++#endif +``` + +2. Disable RTLD_DEEPBIND usage: +```cpp +-#elif defined(RTLD_DEEPBIND) ++#elif defined(RTLD_DEEPBIND) && !defined(__FreeBSD__) +``` + +**Rationale:** +- FreeBSD's C++ ABI handles exception specifications differently +- `noexcept(true)` can cause ABI compatibility issues +- `RTLD_DEEPBIND` is not available on FreeBSD +- These changes allow jemalloc to compile without ABI mismatches + +### patch-memory_build_mozmemory.h + +**Purpose:** Adapt memory API declarations for FreeBSD + +**Changes:** +```cpp ++#if defined(__FreeBSD__) ++#define NOTHROW_MALLOC_DECL(name, return_type, ...) \ ++ MOZ_JEMALLOC_API return_type name(__VA_ARGS__); ++#else + #define NOTHROW_MALLOC_DECL(name, return_type, ...) \ + MOZ_JEMALLOC_API return_type name(__VA_ARGS__) noexcept(true); ++#endif +``` + +**Rationale:** +- Removes `noexcept(true)` from public API declarations on FreeBSD +- Ensures API declarations match implementation (from mozjemalloc.cpp) +- Prevents linker errors due to name mangling differences + +### patch-memory_build_mozmemory__wrap.cpp + +**Purpose:** Adapt memory function wrappers for FreeBSD + +**Changes:** +```cpp ++#if defined(__FreeBSD__) ++#define NOTHROW_MALLOC_DECL(name, return_type, ...) \ ++ MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__); ++#else + #define NOTHROW_MALLOC_DECL(name, return_type, ...) \ + MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__) noexcept(true); ++#endif +``` + +**Rationale:** +- Wrapper functions use `_impl` suffix internally +- Must match exception specifications with actual implementations +- Prevents wrapper/implementation ABI mismatches + +### patch-memory_mozalloc_mozalloc.cpp + +**Purpose:** Provide memalign() for builds without jemalloc + +**Changes:** +```cpp ++# if defined(__FreeBSD__) ++# include ++extern "C" void* memalign(size_t boundary, size_t size) { ++ void* ptr = nullptr; ++ if (posix_memalign(&ptr, boundary, size) != 0) { ++ return nullptr; ++ } ++ return ptr; ++} ++# endif +``` + +**Rationale:** +- When `MOZ_MEMORY` is not defined (jemalloc disabled), need system memalign +- FreeBSD doesn't have native memalign(), so we provide a wrapper +- Uses `posix_memalign()` which is POSIX standard and available on FreeBSD +- Includes `malloc_np.h` for other memory functions needed by mozalloc + +### patch-memory_mozalloc_mozalloc.h + +**Purpose:** Adapt mozalloc API declarations for FreeBSD + +**Changes:** +```cpp ++# if defined(__FreeBSD__) ++# define NOTHROW_MALLOC_DECL(name, return_type, ...) \ ++ MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__); ++# else + # define NOTHROW_MALLOC_DECL(name, return_type, ...) \ + MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__) noexcept(true); ++# endif +``` + +**Rationale:** +- Ensures mozalloc header declarations match implementation +- Removes `noexcept(true)` to match FreeBSD ABI requirements +- Used by code that includes mozalloc.h + +## Patch Application Order + +Patches are applied in filename alphabetical order by the Makefile: + +1. Fallback.cpp - Sets up fallback allocator +2. mozjemalloc.cpp - Core jemalloc implementation +3. mozmemory.h - API declarations +4. mozmemory_wrap.cpp - Wrapper implementations +5. mozalloc_mozalloc.cpp - Alternative allocator implementation +6. mozalloc_mozalloc.h - Alternative allocator API + +The order generally doesn't matter since patches target different files, but this ordering is logical (core → API → wrappers → alternatives). + +## Testing Patch Application + +Use the provided verification script: + +```bash +cd files +./verify_patches.sh +``` + +This checks: +- Proper patch format (unified diff) +- No build artifacts in patches +- Presence of diff hunks + +## Common Issues and Solutions + +### Issue: Patch Fails to Apply + +**Symptom:** `patch: malformed patch at line N` + +**Solution:** +- Check that patch has proper `---` and `+++` headers +- Ensure patch is in unified diff format (`diff -u` or `git diff`) +- Verify line endings are Unix-style (LF, not CRLF) +- Check context lines match the source file + +### Issue: Build Errors After Patching + +**Symptom:** Compilation fails with undefined symbols + +**Solution:** +- Ensure wrapper headers (malloc.h, etc.) are in place +- Verify `CPPFLAGS += -I${FILESDIR}` in Makefile +- Check that all memory patches are applied +- Confirm FreeBSD system has malloc_np.h + +### Issue: Runtime Memory Corruption + +**Symptom:** Segfaults or malloc errors during execution + +**Solution:** +- Verify memalign() wrapper correctly implements alignment +- Check that malloc_usable_size() is from malloc_np.h +- Test with `test_malloc_wrapper.c` +- Run with malloc debugging: `MALLOC_OPTIONS=AJ ./zen-bin` + +## Version Compatibility + +These patches are designed for: +- FreeBSD 13.x and later +- Mozilla/Gecko-based browsers (Firefox 100+) +- Zen Browser 1.17.x + +Adjustments may be needed for: +- Older FreeBSD versions (pre-13.0) +- Significantly different Mozilla versions +- Other BSD variants (OpenBSD, NetBSD, DragonflyBSD) + +## Contributing Patches + +When creating new memory-related patches: + +1. **Identify the issue** - Understand what fails and why +2. **Minimal changes** - Only modify what's necessary +3. **Test thoroughly** - Build and run tests +4. **Document** - Explain the rationale +5. **Follow format** - Use unified diff with `-p0` format + +Example patch creation: +```bash +cd work/ +cp path/to/file.cpp path/to/file.cpp.orig +# Edit file.cpp +diff -u path/to/file.cpp.orig path/to/file.cpp > ../files/patch-path_to_file.cpp +``` + +## See Also + +- [MEMORY_ALLOCATION.md](../MEMORY_ALLOCATION.md) - High-level architecture +- [README.md](README.md) - Wrapper headers documentation +- [FreeBSD Porter's Handbook](https://docs.freebsd.org/en/books/porters-handbook/) diff --git a/www/zen-browser/files/README-FREEBSD.md b/www/zen-browser/files/README-FREEBSD.md new file mode 100644 index 000000000000..8d594984fc36 --- /dev/null +++ b/www/zen-browser/files/README-FREEBSD.md @@ -0,0 +1,67 @@ +# FreeBSD Port & Build Notes ✅ + +**Configure phase summary:** + +- Uses Mozilla's Python-based configure system (`configure.py`) and branding script `browser/branding/unofficial/configure.sh`. +- Git-based version control detected; no cross-compilation in observed run. +- Rust is required at configure-time (not only at build-time). + +**Mach command mapping (FreeBSD port equivalents):** + +| mach command | Purpose | FreeBSD port target | +|---|---|---| +| `mach configure` | Run configuration | `do-configure` | +| `mach build` | Compile the browser | `do-build` | +| `mach install` | Install binaries | `do-install` | +| `mach package` | Create distribution package | Post-build packaging | + +**Key configuration options observed:** + +- Audio backends: **ALSA, JACK, PulseAudio, sndio (BSD)**, OSS +- WebRTC support: `--enable-webrtc` +- WASM sandboxing control: `--without-wasm-sandboxed-libraries` +- Telemetry toggle: `--disable-telemetry` +- LTO/PGO optimization flags and Rust/LLVM integration options +- Supports `--with-system-*` for system libraries (zlib, icu, nspr, av1, libvpx, etc.) + +**Critical findings:** + +- The project uses Mozilla's mach architecture (same as Firefox) — port logic maps cleanly to mach actions. +- Rust must be available during configuration as well as build. +- System library flags (`--with-system-*`) are respected and useful for port packaging. +- A FreeBSD-native audio backend (`sndio`) is already supported. + +**System dependency mapping:** + +| Requirement | Minimum / Note | FreeBSD Port | Purpose | +|---|---:|---|---| +| Git | Any | `devel/git` | Version control, submodules | +| Python | 3.x | `lang/python311` | Mach build scripts, automation | +| Node.js | 21+ | `www/node21` | npm dependency management | +| Rust | Latest | `lang/rust` | Compilation of Rust components | +| sccache | Optional | `devel/sccache` | Build artifact caching | + +**Extended build requirements (from Firefox patterns):** + +- `nspr>=4.32` (`devel/nspr`) +- `nss>=3.118` (`security/nss`) +- `icu>=76.1` (`devel/icu`) +- `libevent>=2.1.8` (`devel/libevent`) +- `harfbuzz>=10.1.0` (`print/harfbuzz`) +- `graphite2>=1.3.14` (`graphics/graphite2`) +- `png>=1.6.45` (`graphics/png`) +- `dav1d>=1.0.0` (`multimedia/dav1d`) +- `libvpx>=1.15.0` (`multimedia/libvpx`) +- `sqlite3` (`databases/sqlite3`) +- `nasm`, `yasm` (assemblers) +- `zip` (packaging) + +**Audio backend options (port notes):** + +- `--enable-sndio`: FreeBSD-native audio (recommended for ports) +- `--enable-alsa`: Linux-only; requires compatibility patches on FreeBSD +- `--disable-pulseaudio`: Useful to avoid optional network audio dependency + +--- + +*This file was added automatically to document observed configuration output and FreeBSD port notes. If you prefer the content merged into `files/README.md`, tell me and I will try again to patch it in place.* \ No newline at end of file diff --git a/www/zen-browser/files/README.md b/www/zen-browser/files/README.md new file mode 100644 index 000000000000..880f4b303e7a --- /dev/null +++ b/www/zen-browser/files/README.md @@ -0,0 +1,128 @@ +# FreeBSD Compatibility Wrappers for Mozilla/Zen Browser + +## Overview + +This directory contains compatibility wrappers and patches to enable Mozilla Firefox/Zen Browser code (which targets glibc) to compile and run on FreeBSD (which uses BSD libc). + +## Memory Allocation Compatibility + +### The Problem + +Mozilla's code (originally developed for Linux/glibc) uses memory allocation functions and conventions that differ from FreeBSD's libc: + +1. **`memalign()` function**: + - glibc provides `memalign(alignment, size)` + - FreeBSD only provides the POSIX `posix_memalign(ptr, alignment, size)` interface + +2. **`malloc_usable_size()` function**: + - glibc: Available in `` + - FreeBSD: Available in `` (non-portable extensions) + +3. **C++ ABI differences**: + - `noexcept(true)` specifier not compatible with FreeBSD's C++ ABI in certain contexts + +### The Solution: Wrapper Headers + +We use preprocessor include path priority (`CPPFLAGS += -I${FILESDIR}`) to inject compatibility wrappers: + +#### `malloc.h` - Memory Allocation Wrapper +- Includes FreeBSD's `` to get `malloc_usable_size()` +- Provides inline `memalign()` wrapper that calls `posix_memalign()` +- Enables Mozilla code to use glibc-style APIs seamlessly + +#### `endian.h` - Endianness Wrapper +- Redirects glibc's `` to BSD's `` + +#### `byteswap.h` - Byte Swapping Wrapper +- Maps glibc's `bswap_16/32/64` to BSD's `bswap16/32/64` +- Handles OpenBSD's `swap*` variants as well + +## Mozilla Memory Subsystem Patches + +### Core Memory Patches + +1. **`patch-memory_build_mozjemalloc.cpp`** + - Removes `noexcept(true)` from malloc declarations on FreeBSD + - Disables `RTLD_DEEPBIND` usage (not available on FreeBSD) + +2. **`patch-memory_build_mozmemory.h`** + - Conditionally removes `noexcept(true)` from memory API declarations + +3. **`patch-memory_build_mozmemory__wrap.cpp`** + - Adapts memory wrapper to FreeBSD's C++ ABI + +4. **`patch-memory_build_Fallback.cpp`** + - Includes `` on FreeBSD + - Defines `HAVE_MEMALIGN` to use our wrapper + +5. **`patch-memory_mozalloc_mozalloc.cpp`** + - Provides `memalign()` wrapper for non-jemalloc builds + - Includes `` for malloc_usable_size + +6. **`patch-memory_mozalloc_mozalloc.h`** + - Removes `noexcept(true)` from mozalloc API on FreeBSD + +### Why Multiple Patches? + +Mozilla has multiple memory allocator configurations: +- **jemalloc enabled** (default): Uses Mozilla's jemalloc +- **jemalloc disabled**: Falls back to system allocator +- **Static runtime**: Different symbol resolution + +Each configuration needs FreeBSD-specific adaptations. + +## Build System Integration + +The Makefile enables these wrappers via: + +```make +CPPFLAGS += -I${FILESDIR} +``` + +This ensures our wrapper headers are found **before** system headers, allowing us to intercept and adapt glibc-specific includes. + +## Testing + +### Unit Test + +A test program is provided in `test_malloc_wrapper.c` to verify the wrappers work correctly. + +**On FreeBSD:** +```bash +cd files +cc -I. test_malloc_wrapper.c -o test_malloc_wrapper +./test_malloc_wrapper +``` + +**On Linux (for comparison):** +```bash +cd files +cc test_malloc_wrapper.c -o test_malloc_wrapper +./test_malloc_wrapper +``` + +The test verifies: +1. `memalign()` works with various alignment values (8, 16, 32, 64, 128, 256 bytes) +2. Returned pointers are properly aligned +3. `malloc_usable_size()` returns reasonable values +4. Allocated memory is readable and writable + +### Integration Testing + +After applying these patches: +1. Mozilla's jemalloc should build with FreeBSD compatibility +2. Memory allocation functions work transparently +3. No runtime memory corruption or leaks + +You can verify the build with: +```bash +make clean +make configure +make build +``` + +## References + +- FreeBSD malloc_np.h: Non-portable malloc extensions +- Mozilla jemalloc: memory/build/ +- POSIX memalign: https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_memalign.html diff --git a/www/zen-browser/files/byteswap.h b/www/zen-browser/files/byteswap.h new file mode 100644 index 000000000000..2a40948a4ecf --- /dev/null +++ b/www/zen-browser/files/byteswap.h @@ -0,0 +1,24 @@ +/* + * glibc byteswap.h compatibility wrapper for FreeBSD + * + * Provides glibc-style byte swapping function names (bswap_16, bswap_32, bswap_64) + * by mapping them to FreeBSD's native functions (bswap16, bswap32, bswap64) + * or OpenBSD's swap* functions. + */ + +#ifndef _BYTESWAP_H +#define _BYTESWAP_H + +#include + +#ifdef __OpenBSD__ +#define bswap_16(x) swap16(x) +#define bswap_32(x) swap32(x) +#define bswap_64(x) swap64(x) +#else +/* FreeBSD, NetBSD, and other BSD variants use bswap* naming */ +#define bswap_16(x) bswap16(x) +#define bswap_32(x) bswap32(x) +#define bswap_64(x) bswap64(x) +#endif +#endif /* _BYTESWAP_H */ diff --git a/www/zen-browser/files/check_patches.sh b/www/zen-browser/files/check_patches.sh new file mode 100755 index 000000000000..ec6166ae136c --- /dev/null +++ b/www/zen-browser/files/check_patches.sh @@ -0,0 +1,101 @@ +#!/bin/sh +# +# check_patches.sh - Check if FreeBSD patches are applied to the source tree +# +# Usage: ./check_patches.sh [work_directory] +# +# Returns: +# 0 - All patches need to be applied (none applied yet) +# 1 - Some or all patches already applied +# + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +WORK_DIR="${1:-$(dirname "$SCRIPT_DIR")/work}" + +if [ ! -d "$WORK_DIR" ]; then + echo "ERROR: Work directory not found: $WORK_DIR" + echo "Usage: $0 [work_directory]" + exit 2 +fi + +echo "=== FreeBSD Patch Status Check ===" +echo "Patch directory: $SCRIPT_DIR" +echo "Work directory: $WORK_DIR" +echo "" + +APPLIED=0 +NOT_APPLIED=0 +FAILED=0 + +for patch in "$SCRIPT_DIR"/patch-*; do + [ -f "$patch" ] || continue + + patch_name="$(basename "$patch")" + + # Extract the target file path from the patch header + # Unified diff format: --- path/to/file.orig or --- a/path/to/file + target_file=$(grep -m1 '^--- ' "$patch" | sed -E 's/^--- (a\/)?//; s/\.orig.*//; s/[[:space:]].*//') + + if [ -z "$target_file" ]; then + echo "⚠️ $patch_name: Cannot determine target file" + FAILED=$((FAILED + 1)) + continue + fi + + full_path="$WORK_DIR/$target_file" + + if [ ! -f "$full_path" ]; then + echo "❓ $patch_name: Target file not found: $target_file" + FAILED=$((FAILED + 1)) + continue + fi + + # Check if .orig file exists (indicates patch was applied by FreeBSD ports) + if [ -f "${full_path}.orig" ]; then + echo "✅ $patch_name: APPLIED (${target_file}.orig exists)" + APPLIED=$((APPLIED + 1)) + continue + fi + + # Try to apply the patch in dry-run mode + # If it applies cleanly, the patch hasn't been applied yet + # If it fails or reverses, the patch is already applied + result=$(patch -d "$WORK_DIR" -p0 --dry-run < "$patch" 2>&1) + exit_code=$? + + if echo "$result" | grep -q "Reversed (or previously applied)"; then + echo "✅ $patch_name: APPLIED (patch reversed/already applied)" + APPLIED=$((APPLIED + 1)) + elif echo "$result" | grep -q "FAILED\|malformed\|can't find file"; then + echo "⚠️ $patch_name: FAILED to check - $target_file" + echo " Reason: $(echo "$result" | grep -E 'FAILED|malformed|can.t find' | head -1)" + FAILED=$((FAILED + 1)) + elif [ $exit_code -eq 0 ]; then + echo "❌ $patch_name: NOT APPLIED - $target_file" + NOT_APPLIED=$((NOT_APPLIED + 1)) + else + echo "⚠️ $patch_name: UNKNOWN status - $target_file" + FAILED=$((FAILED + 1)) + fi +done + +echo "" +echo "=== Summary ===" +echo "Applied: $APPLIED" +echo "Not Applied: $NOT_APPLIED" +echo "Failed/Unknown: $FAILED" +echo "" + +if [ $APPLIED -gt 0 ] && [ $NOT_APPLIED -eq 0 ]; then + echo "Status: All patches are already applied." + exit 1 +elif [ $NOT_APPLIED -gt 0 ] && [ $APPLIED -eq 0 ]; then + echo "Status: No patches applied yet. Ready to patch." + exit 0 +elif [ $APPLIED -gt 0 ] && [ $NOT_APPLIED -gt 0 ]; then + echo "Status: MIXED - Some patches applied, some not. Consider 'make clean' first." + exit 1 +else + echo "Status: Unable to determine patch status." + exit 2 +fi diff --git a/www/zen-browser/files/endian.h b/www/zen-browser/files/endian.h new file mode 100644 index 000000000000..e19ac7b15387 --- /dev/null +++ b/www/zen-browser/files/endian.h @@ -0,0 +1,11 @@ +/* + * glibc endian.h compatibility wrapper for FreeBSD + * + * glibc uses while BSD systems use + * This wrapper redirects to the BSD system header + */ + +#ifndef _ENDIAN_H +#define _ENDIAN_H +#include +#endif /* _ENDIAN_H */ diff --git a/www/zen-browser/files/malloc.h b/www/zen-browser/files/malloc.h new file mode 100644 index 000000000000..328002809a21 --- /dev/null +++ b/www/zen-browser/files/malloc.h @@ -0,0 +1,43 @@ +/* + * glibc malloc.h compatibility wrapper for FreeBSD + * + * This wrapper provides glibc-style memory allocation functions + * for FreeBSD's libc, enabling Mozilla/Firefox code to compile + * without modifications. + * + * Key differences handled: + * - memalign() -> posix_memalign() wrapper + * - malloc_usable_size() from malloc_np.h + */ + +#ifndef _MALLOC_H +#define _MALLOC_H + +#include + +#ifdef __FreeBSD__ +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * memalign() wrapper for FreeBSD + * glibc provides memalign() but FreeBSD only has posix_memalign() + * This wrapper translates the glibc interface to FreeBSD's POSIX interface + */ +inline void* memalign(size_t alignment, size_t size) { + void* ptr = NULL; + if (posix_memalign(&ptr, alignment, size) != 0) { + return NULL; + } + return ptr; +} + +#ifdef __cplusplus +} +#endif + +#endif /* __FreeBSD__ */ +#endif /* _MALLOC_H */ diff --git a/www/zen-browser/files/mozconfig b/www/zen-browser/files/mozconfig new file mode 100644 index 000000000000..f3ba77197cd1 --- /dev/null +++ b/www/zen-browser/files/mozconfig @@ -0,0 +1,29 @@ +# FreeBSD Zen Browser mozconfig +# This file ensures configuration options are properly applied + +ac_add_options --enable-application=browser +ac_add_options --enable-sndio +ac_add_options --enable-webrtc +ac_add_options --enable-release +ac_add_options --enable-jemalloc +ac_add_options --enable-linker=lld + +# System libraries +ac_add_options --with-system-icu +ac_add_options --with-system-nspr +ac_add_options --with-system-nss +ac_add_options --with-system-av1 +ac_add_options --with-system-libdrm +ac_add_options --with-system-pipewire + +# Disable features that may cause issues +ac_add_options --disable-tests +ac_add_options --disable-debug +ac_add_options --disable-updater + +# FreeBSD-specific: ensure pthread linking +export LDFLAGS="-lpthread ${LDFLAGS}" +export LIBS="-lpthread" + +# Optimize build +mk_add_options MOZ_MAKE_FLAGS="-j${MAKE_JOBS_NUMBER}" diff --git a/www/zen-browser/files/patch-browser_extensions_newtab_mach__commands.py b/www/zen-browser/files/patch-browser_extensions_newtab_mach__commands.py new file mode 100644 index 000000000000..95acf4596805 --- /dev/null +++ b/www/zen-browser/files/patch-browser_extensions_newtab_mach__commands.py @@ -0,0 +1,17 @@ +--- browser/extensions/newtab/mach_commands.py.orig 2025-02-06 00:00:00 UTC ++++ browser/extensions/newtab/mach_commands.py +@@ -38,8 +38,12 @@ sys.path.append( + ) + WEBEXT_METRICS_PATH = Path("browser", "extensions", "newtab", "webext-glue", "metrics") + sys.path.append(str(WEBEXT_METRICS_PATH.absolute())) +-import glean_utils +-from run_glean_parser import parse_with_options ++try: ++ import glean_utils ++ from run_glean_parser import parse_with_options ++except ImportError: ++ glean_utils = None ++ parse_with_options = None + + FIREFOX_L10N_REPO = "https://github.com/mozilla-l10n/firefox-l10n.git" + FLUENT_FILE = "newtab.ftl" diff --git a/www/zen-browser/files/patch-dom_media_webrtc_libwebrtc__overrides_moz.build b/www/zen-browser/files/patch-dom_media_webrtc_libwebrtc__overrides_moz.build new file mode 100644 index 000000000000..8437614b671e --- /dev/null +++ b/www/zen-browser/files/patch-dom_media_webrtc_libwebrtc__overrides_moz.build @@ -0,0 +1,11 @@ +--- dom/media/webrtc/libwebrtc_overrides/moz.build.orig 2026-02-07 00:00:00.000000000 +0000 ++++ dom/media/webrtc/libwebrtc_overrides/moz.build 2026-02-07 00:00:00.000000000 +0000 +@@ -49,7 +49,7 @@ + "call/call_basic_stats.cc", + ] + +-if CONFIG["OS_TARGET"] == "OpenBSD": ++if CONFIG["OS_TARGET"] in ("OpenBSD", "FreeBSD"): + CXXFLAGS += CONFIG["MOZ_X11_CFLAGS"] + UNIFIED_SOURCES += [ + "modules/desktop_capture/linux/x11/x_error_trap.cc", diff --git a/www/zen-browser/files/patch-memory_build_Fallback.cpp b/www/zen-browser/files/patch-memory_build_Fallback.cpp new file mode 100644 index 000000000000..72e83dcbe7de --- /dev/null +++ b/www/zen-browser/files/patch-memory_build_Fallback.cpp @@ -0,0 +1,14 @@ +--- memory/build/Fallback.cpp.orig 2025-01-01 00:00:00.000000000 +0000 ++++ memory/build/Fallback.cpp 2025-01-01 00:00:00.000000000 +0000 +@@ -6,6 +6,11 @@ + + #include "mozmemory.h" + #include "mozjemalloc.h" ++#ifdef __FreeBSD__ ++# include ++# define HAVE_MEMALIGN 1 ++#endif ++ + #include + + #ifndef HAVE_MEMALIGN diff --git a/www/zen-browser/files/patch-memory_build_mozjemalloc.cpp b/www/zen-browser/files/patch-memory_build_mozjemalloc.cpp new file mode 100644 index 000000000000..f41f503e7eb3 --- /dev/null +++ b/www/zen-browser/files/patch-memory_build_mozjemalloc.cpp @@ -0,0 +1,27 @@ +--- memory/build/mozjemalloc.cpp.orig 2025-01-01 00:00:00.000000000 +0000 ++++ memory/build/mozjemalloc.cpp 2025-01-01 00:00:00.000000000 +0000 +@@ -5103,8 +5103,14 @@ + ##__VA_ARGS__) + #endif + ++#if defined(__FreeBSD__) ++#define NOTHROW_MALLOC_DECL(...) \ ++ MOZ_MEMORY_API MACRO_CALL(GENERIC_MALLOC_DECL, (, __VA_ARGS__)) ++#else + #define NOTHROW_MALLOC_DECL(...) \ + MOZ_MEMORY_API MACRO_CALL(GENERIC_MALLOC_DECL, (noexcept(true), __VA_ARGS__)) ++#endif ++ + #define MALLOC_DECL(...) \ + MOZ_MEMORY_API MACRO_CALL(GENERIC_MALLOC_DECL, (, __VA_ARGS__)) + #define MALLOC_FUNCS MALLOC_FUNCS_MALLOC +@@ -5139,7 +5145,7 @@ + MOZ_EXPORT void* (*__realloc_hook)(void*, size_t) = realloc_impl; + MOZ_EXPORT void* (*__memalign_hook)(size_t, size_t) = memalign_impl; + } + +-#elif defined(RTLD_DEEPBIND) ++#elif defined(RTLD_DEEPBIND) && !defined(__FreeBSD__) + // XXX On systems that support RTLD_GROUP or DF_1_GROUP, do their + // implementations permit similar inconsistencies? Should STV_SINGLETON + // visibility be used for interposition where available? diff --git a/www/zen-browser/files/patch-memory_build_mozmemory.h b/www/zen-browser/files/patch-memory_build_mozmemory.h new file mode 100644 index 000000000000..8ad3a3ca915d --- /dev/null +++ b/www/zen-browser/files/patch-memory_build_mozmemory.h @@ -0,0 +1,17 @@ +--- memory/build/mozmemory.h.orig 2025-01-01 00:00:00.000000000 +0000 ++++ memory/build/mozmemory.h 2025-01-01 00:00:00.000000000 +0000 +@@ -67,8 +67,14 @@ + + #endif // MOZ_MEMORY + ++#if defined(__FreeBSD__) ++#define NOTHROW_MALLOC_DECL(name, return_type, ...) \ ++ MOZ_JEMALLOC_API return_type name(__VA_ARGS__); ++#else + #define NOTHROW_MALLOC_DECL(name, return_type, ...) \ + MOZ_JEMALLOC_API return_type name(__VA_ARGS__) noexcept(true); ++#endif ++ + #define MALLOC_DECL(name, return_type, ...) \ + MOZ_JEMALLOC_API return_type name(__VA_ARGS__); + #define MALLOC_FUNCS MALLOC_FUNCS_ARENA diff --git a/www/zen-browser/files/patch-memory_build_mozmemory__wrap.cpp b/www/zen-browser/files/patch-memory_build_mozmemory__wrap.cpp new file mode 100644 index 000000000000..e4fe692a0acc --- /dev/null +++ b/www/zen-browser/files/patch-memory_build_mozmemory__wrap.cpp @@ -0,0 +1,16 @@ +--- memory/build/mozmemory_wrap.cpp.orig 2025-01-01 00:00:00.000000000 +0000 ++++ memory/build/mozmemory_wrap.cpp 2025-01-01 00:00:00.000000000 +0000 +@@ -10,8 +10,14 @@ + // Declare malloc implementation functions with the right return and + // argument types. ++#if defined(__FreeBSD__) ++#define NOTHROW_MALLOC_DECL(name, return_type, ...) \ ++ MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__); ++#else + #define NOTHROW_MALLOC_DECL(name, return_type, ...) \ + MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__) noexcept(true); ++#endif ++ + #define MALLOC_DECL(name, return_type, ...) \ + MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__); + #define MALLOC_FUNCS MALLOC_FUNCS_MALLOC diff --git a/www/zen-browser/files/patch-memory_mozalloc_mozalloc.cpp b/www/zen-browser/files/patch-memory_mozalloc_mozalloc.cpp new file mode 100644 index 000000000000..a836c16d44ef --- /dev/null +++ b/www/zen-browser/files/patch-memory_mozalloc_mozalloc.cpp @@ -0,0 +1,20 @@ +--- memory/mozalloc/mozalloc.cpp.orig 2025-01-01 00:00:00.000000000 +0000 ++++ memory/mozalloc/mozalloc.cpp 2025-01-01 00:00:00.000000000 +0000 +@@ -17,6 +17,17 @@ + # include + # endif // if defined(XP_UNIX) + ++# if defined(__FreeBSD__) ++# include ++extern "C" void* memalign(size_t boundary, size_t size) { ++ void* ptr = nullptr; ++ if (posix_memalign(&ptr, boundary, size) != 0) { ++ return nullptr; ++ } ++ return ptr; ++} ++# endif ++ + # define malloc_impl malloc + # define calloc_impl calloc + # define realloc_impl realloc diff --git a/www/zen-browser/files/patch-memory_mozalloc_mozalloc.h b/www/zen-browser/files/patch-memory_mozalloc_mozalloc.h new file mode 100644 index 000000000000..b8447462c852 --- /dev/null +++ b/www/zen-browser/files/patch-memory_mozalloc_mozalloc.h @@ -0,0 +1,16 @@ +--- memory/mozalloc/mozalloc.h.orig 2025-01-01 00:00:00.000000000 +0000 ++++ memory/mozalloc/mozalloc.h 2025-01-01 00:00:00.000000000 +0000 +@@ -33,8 +33,14 @@ + // something like a malloc.h wrapper and allow the use of the functions without + // a _impl suffix. In the meanwhile, this is enough to get by for C++ code. ++# if defined(__FreeBSD__) ++# define NOTHROW_MALLOC_DECL(name, return_type, ...) \ ++ MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__); ++# else + # define NOTHROW_MALLOC_DECL(name, return_type, ...) \ + MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__) noexcept(true); ++# endif ++ + # define MALLOC_DECL(name, return_type, ...) \ + MOZ_MEMORY_API return_type name##_impl(__VA_ARGS__); + # include "malloc_decls.h" diff --git a/www/zen-browser/files/patch-python_sites_mach.txt b/www/zen-browser/files/patch-python_sites_mach.txt new file mode 100644 index 000000000000..4dba386b8492 --- /dev/null +++ b/www/zen-browser/files/patch-python_sites_mach.txt @@ -0,0 +1,10 @@ +--- python/sites/mach.txt.orig 2025-02-05 13:02:40.597621000 +0100 ++++ python/sites/mach.txt +@@ -57,8 +57,7 @@ + pth:xpcom/idl-parser + # glean-sdk may not be installable if a wheel isn't available + # and it has to be built from source. +-pypi-optional:glean-sdk==66.2.0:telemetry will not be collected + pypi-optional:orjson>=3.10:json operations will be slower in various tools + # Mach gracefully handles the case where `psutil` is unavailable. + # We aren't (yet) able to pin packages in automation, so we have to diff --git a/www/zen-browser/files/patch-third__party_libwebrtc_modules_desktop__capture_linux_wayland__egl__dmabuf.cc b/www/zen-browser/files/patch-third__party_libwebrtc_modules_desktop__capture_linux_wayland__egl__dmabuf.cc new file mode 100644 index 000000000000..fffcc1f59950 --- /dev/null +++ b/www/zen-browser/files/patch-third__party_libwebrtc_modules_desktop__capture_linux_wayland__egl__dmabuf.cc @@ -0,0 +1,19 @@ +commit f53507857647459d4a48935901f80f27a5ae58a9 +Author: Christoph Moench-Tegeder + + avoid linux-only includes + +diff --git a/third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.cc b/third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.cc +index 821fdfb487b7..e000c1c104fe 100644 +--- third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.cc ++++ third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.cc +@@ -15,7 +15,9 @@ + #include + #include + #include ++#if !defined(__FreeBSD__) + #include ++#endif + #include + #include + #include diff --git a/www/zen-browser/files/patch-third__party_libwebrtc_third__party_pffft_src_pffft.c b/www/zen-browser/files/patch-third__party_libwebrtc_third__party_pffft_src_pffft.c new file mode 100644 index 000000000000..465d6b7f01c7 --- /dev/null +++ b/www/zen-browser/files/patch-third__party_libwebrtc_third__party_pffft_src_pffft.c @@ -0,0 +1,10 @@ +--- third_party/libwebrtc/third_party/pffft/src/pffft.c.orig 2022-02-10 18:57:48 UTC ++++ third_party/libwebrtc/third_party/pffft/src/pffft.c +@@ -100,6 +100,7 @@ + Altivec support macros + */ + #if !defined(PFFFT_SIMD_DISABLE) && (defined(__ppc__) || defined(__ppc64__)) ++#include + typedef vector float v4sf; + # define SIMD_SZ 4 + # define VZERO() ((vector float) vec_splat_u8(0)) diff --git a/www/zen-browser/files/patch-third_party_libwebrtc_BUILD.gn b/www/zen-browser/files/patch-third_party_libwebrtc_BUILD.gn new file mode 100644 index 000000000000..deb9a02a32da --- /dev/null +++ b/www/zen-browser/files/patch-third_party_libwebrtc_BUILD.gn @@ -0,0 +1,11 @@ +--- third_party/libwebrtc/BUILD.gn.orig 2025-02-05 13:02:40.597621000 +0100 ++++ third_party/libwebrtc/BUILD.gn +@@ -256,7 +256,7 @@ + target_gen_dir, + ] + } +- if (is_posix || is_fuchsia) { ++ if (is_posix || is_fuchsia || is_bsd) { + defines += [ "WEBRTC_POSIX" ] + } + if (is_ios) { diff --git a/www/zen-browser/files/patch-third_party_libwebrtc_build_config_BUILDCONFIG.gn b/www/zen-browser/files/patch-third_party_libwebrtc_build_config_BUILDCONFIG.gn new file mode 100644 index 000000000000..c7b59bbd1f86 --- /dev/null +++ b/www/zen-browser/files/patch-third_party_libwebrtc_build_config_BUILDCONFIG.gn @@ -0,0 +1,141 @@ +commit e8a3b91abdc00edd7633aabbe5e63bfc0d0825e4 +Author: Christoph Moench-Tegeder + + enable pipewire on bsd + +diff --git a/third_party/chromium/build/config/BUILDCONFIG.gn b/third_party/chromium/build/config/BUILDCONFIG.gn +index 4bb38fe31ff2..b10eb19f521a 100644 +--- third_party/chromium/build/config/BUILDCONFIG.gn ++++ third_party/chromium/build/config/BUILDCONFIG.gn +@@ -137,6 +137,7 @@ declare_args() { + + # Set to true when compiling with the Clang compiler. + is_clang = current_os != "linux" || current_os == "openbsd" || ++ current_os == "freebsd" || + (current_cpu != "s390x" && current_cpu != "s390" && + current_cpu != "ppc64" && current_cpu != "ppc" && + current_cpu != "mips" && current_cpu != "mips64" && +@@ -206,7 +207,7 @@ if (host_toolchain == "") { + # TODO(dpranke): Add some sort of assert here that verifies that + # no toolchain omitted host_toolchain from its toolchain_args(). + +- if (host_os == "linux" || host_os == "openbsd") { ++ if (host_os == "linux" || host_os == "openbsd" || host_os == "freebsd") { + if (target_os != "linux") { + host_toolchain = "//chromium/build/toolchain/linux:clang_$host_cpu" + } else if (is_clang) { +@@ -246,7 +247,7 @@ if (target_os == "android") { + # Targeting android on Mac is best-effort and not guaranteed to work. + #assert(host_os == "linux", "Android builds are only supported on Linux.") + _default_toolchain = "//chromium/build/toolchain/android:android_clang_$target_cpu" +-} else if (target_os == "chromeos" || target_os == "linux" || target_os == "openbsd") { ++} else if (target_os == "chromeos" || target_os == "linux" || target_os == "openbsd" || target_os == "freebsd") { + # See comments in build/toolchain/cros/BUILD.gn about board compiles. + if (is_clang) { + _default_toolchain = "//chromium/build/toolchain/linux:clang_$target_cpu" +@@ -314,7 +315,7 @@ is_chromeos = current_os == "chromeos" + is_fuchsia = current_os == "fuchsia" + is_ios = current_os == "ios" + is_linux = current_os == "linux" +-is_bsd = current_os == "openbsd" ++is_bsd = current_os == "openbsd" || current_os == "freebsd" + is_mac = current_os == "mac" + is_nacl = current_os == "nacl" + is_wasm = current_os == "emscripten" +diff --git a/third_party/libwebrtc/BUILD.gn b/third_party/libwebrtc/BUILD.gn +index ac8569efaa40..5d6c5953491c 100644 +--- third_party/libwebrtc/BUILD.gn ++++ third_party/libwebrtc/BUILD.gn +@@ -111,7 +111,7 @@ if (!build_with_chromium && !build_with_mozilla) { + "tools_webrtc/perf:webrtc_dashboard_upload", + ] + } +- if ((is_linux || is_chromeos) && rtc_use_pipewire) { ++ if ((is_linux || is_chromeos || is_bsd) && rtc_use_pipewire) { + deps += [ "modules/desktop_capture:shared_screencast_stream_test" ] + } + } +diff --git a/third_party/libwebrtc/modules/desktop_capture/BUILD.gn b/third_party/libwebrtc/modules/desktop_capture/BUILD.gn +index 5c843cfc2b6a..0ed9f98a964f 100644 +--- third_party/libwebrtc/modules/desktop_capture/BUILD.gn ++++ third_party/libwebrtc/modules/desktop_capture/BUILD.gn +@@ -76,7 +76,7 @@ if (rtc_include_tests) { + "window_finder_unittest.cc", + ] + +- if ((is_linux || is_chromeos) && rtc_use_pipewire) { ++ if ((is_linux || is_chromeos || is_bsd) && rtc_use_pipewire) { + configs += [ "../portal:gio" ] + } + +@@ -88,7 +88,7 @@ if (rtc_include_tests) { + } + } + +- if ((is_linux || is_chromeos) && rtc_use_pipewire) { ++ if ((is_linux || is_chromeos || is_bsd) && rtc_use_pipewire) { + rtc_test("shared_screencast_stream_test") { + testonly = true + +@@ -148,7 +148,7 @@ if (rtc_include_tests) { + "test_utils_unittest.cc", + ] + +- if ((is_linux || is_chromeos) && rtc_use_pipewire) { ++ if ((is_linux || is_chromeos || is_bsd) && rtc_use_pipewire) { + configs += [ "../portal:gio" ] + } + +@@ -215,7 +215,7 @@ if (rtc_include_tests) { + "screen_drawer.h", + ] + +- if (is_linux || is_chromeos) { ++ if (is_linux || is_chromeos || is_bsd) { + sources += [ "screen_drawer_linux.cc" ] + libs = [ "X11" ] + } +@@ -254,7 +254,7 @@ if (rtc_include_tests) { + "mock_desktop_capturer_callback.h", + ] + +- if ((is_linux || is_chromeos) && rtc_use_pipewire) { ++ if ((is_linux || is_chromeos || us_bsd) && rtc_use_pipewire) { + configs += [ "../portal:gio" ] + } + +@@ -267,7 +267,7 @@ if (rtc_include_tests) { + } + + # TODO(bugs.webrtc.org/14187): remove when all users are gone +-if ((is_linux || is_chromeos) && rtc_use_pipewire) { ++if ((is_linux || is_chromeos || is_bsd) && rtc_use_pipewire) { + config("pipewire_config") { + configs = [ "../portal:pipewire_config" ] + } +diff --git a/third_party/libwebrtc/modules/portal/BUILD.gn b/third_party/libwebrtc/modules/portal/BUILD.gn +index 70b4739ad0c4..99ab95d441f3 100644 +--- third_party/libwebrtc/modules/portal/BUILD.gn ++++ third_party/libwebrtc/modules/portal/BUILD.gn +@@ -10,7 +10,7 @@ import("//chromium/build/config/linux/pkg_config.gni") + import("//tools/generate_stubs/rules.gni") + import("../../webrtc.gni") + +-if ((is_linux || is_chromeos) && rtc_use_pipewire) { ++if ((is_linux || is_chromeos || is_bsd) && rtc_use_pipewire) { + if (!build_with_mozilla) { + pkg_config("gio") { + packages = [ +diff --git a/third_party/libwebrtc/webrtc.gni b/third_party/libwebrtc/webrtc.gni +index 1e87de20e545..77a8a55d8659 100644 +--- third_party/libwebrtc/webrtc.gni ++++ third_party/libwebrtc/webrtc.gni +@@ -151,7 +151,7 @@ declare_args() { + # By default it's only enabled on desktop Linux (excludes ChromeOS) and + # only when using the sysroot as PipeWire is not available in older and + # supported Ubuntu and Debian distributions. +- rtc_use_pipewire = is_linux && use_sysroot ++ rtc_use_pipewire = (is_linux || is_bsd) && use_sysroot + + # Set this to link PipeWire and required libraries directly instead of using the dlopen. + rtc_link_pipewire = false diff --git a/www/zen-browser/files/test_malloc_wrapper.c b/www/zen-browser/files/test_malloc_wrapper.c new file mode 100644 index 000000000000..57c019ec2d0d --- /dev/null +++ b/www/zen-browser/files/test_malloc_wrapper.c @@ -0,0 +1,111 @@ +/* + * Test program to verify glibc compatibility wrappers for FreeBSD + * + * This test should be run on FreeBSD with: + * cc -I. test_malloc_wrapper.c -o test_malloc_wrapper + * ./test_malloc_wrapper + * + * On Linux, this test uses native glibc functions for comparison. + */ + +#include +#include +#include +#include +#include + +#ifdef __FreeBSD__ +/* On FreeBSD, use our compatibility wrapper */ +#include "malloc.h" +#else +/* On Linux/glibc, use native headers */ +#include +#endif + +int main(void) { + printf("Testing memory allocation functions...\n"); + +#ifdef __FreeBSD__ + printf("Running on FreeBSD with compatibility wrapper\n\n"); +#else + printf("Running on Linux with native glibc (for comparison)\n\n"); +#endif + + /* Test 1: memalign() */ + printf("Test 1: memalign() wrapper\n"); + void* aligned_ptr = memalign(64, 1024); + if (aligned_ptr == NULL) { + fprintf(stderr, "FAIL: memalign returned NULL\n"); + return 1; + } + + /* Check alignment */ + if (((uintptr_t)aligned_ptr % 64) != 0) { + fprintf(stderr, "FAIL: pointer not properly aligned (expected 64-byte alignment)\n"); + free(aligned_ptr); + return 1; + } + printf(" PASS: memalign(64, 1024) returned properly aligned pointer: %p\n", aligned_ptr); + + /* Write to the memory to ensure it's usable */ + memset(aligned_ptr, 0xAB, 1024); + printf(" PASS: Memory is writable\n"); + + /* Test 2: malloc_usable_size() */ + printf("\nTest 2: malloc_usable_size()\n"); + size_t usable = malloc_usable_size(aligned_ptr); + printf(" malloc_usable_size() returned: %zu bytes\n", usable); + if (usable < 1024) { + fprintf(stderr, "FAIL: usable size (%zu) less than requested (1024)\n", usable); + free(aligned_ptr); + return 1; + } + printf(" PASS: Usable size is at least as large as requested\n"); + + free(aligned_ptr); + + /* Test 3: malloc_usable_size() with regular malloc */ + printf("\nTest 3: malloc_usable_size() with regular malloc\n"); + void* regular_ptr = malloc(512); + if (regular_ptr == NULL) { + fprintf(stderr, "FAIL: malloc returned NULL\n"); + return 1; + } + + usable = malloc_usable_size(regular_ptr); + printf(" malloc_usable_size(malloc(512)) returned: %zu bytes\n", usable); + if (usable < 512) { + fprintf(stderr, "FAIL: usable size (%zu) less than requested (512)\n", usable); + free(regular_ptr); + return 1; + } + printf(" PASS: Usable size is valid\n"); + + free(regular_ptr); + + /* Test 4: Multiple memalign calls with different alignments */ + printf("\nTest 4: Various alignment values\n"); + size_t alignments[] = {8, 16, 32, 64, 128, 256}; + size_t num_alignments = sizeof(alignments) / sizeof(alignments[0]); + + for (size_t i = 0; i < num_alignments; i++) { + void* ptr = memalign(alignments[i], 100); + if (ptr == NULL) { + fprintf(stderr, "FAIL: memalign(%zu, 100) returned NULL\n", alignments[i]); + return 1; + } + if (((uintptr_t)ptr % alignments[i]) != 0) { + fprintf(stderr, "FAIL: memalign(%zu) not properly aligned\n", alignments[i]); + free(ptr); + return 1; + } + free(ptr); + } + printf(" PASS: All alignment values work correctly\n"); + + printf("\n=================================\n"); + printf("All tests PASSED!\n"); + printf("=================================\n"); + + return 0; +} diff --git a/www/zen-browser/pkg-descr b/www/zen-browser/pkg-descr new file mode 100644 index 000000000000..7c101261bf7d --- /dev/null +++ b/www/zen-browser/pkg-descr @@ -0,0 +1,19 @@ +Zen Browser is a high-performance, privacy-focused web browser built on +Firefox's Gecko engine. It combines the stability and compatibility of Firefox +with enhanced privacy controls, improved user experience, and performance +optimizations. + +Key Features: + +- Privacy First: Telemetry disabled by default, enhanced tracking protection +- Performance: Optimized compilation with modern C++ toolchain and Rust +- Firefox Compatible: Uses the same Gecko engine for excellent web compatibility +- WebRTC Support: Full real-time communication support for video/audio +- Cross-Platform: Runs on Windows, macOS, Linux, and FreeBSD +- Active Development: Regular updates with latest security patches + +Zen Browser prioritizes user privacy and control while maintaining full web +compatibility. It includes built-in privacy features, secure defaults, and +advanced customization options for power users. + +For more information and documentation, visit https://zen-browser.app diff --git a/www/zen-browser/pkg-plist b/www/zen-browser/pkg-plist new file mode 100644 index 000000000000..e69de29bb2d1 -- 2.52.0