# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= firefox VERSION= 119.0.1 REVISION= 2 KEYWORDS= www VARIANTS= standard SDESC[standard]= Mozilla web browser HOMEPAGE= https://www.mozilla.org/en-US/firefox/ CONTACT= nobody DOWNLOAD_GROUPS= main SITES[main]= MOZILLA/firefox/releases/119.0.1/source DISTFILE[1]= firefox-119.0.1.source.tar.xz:main DF_INDEX= 1 SPKGS[standard]= single OPTIONS_AVAILABLE= MOLD OPTIONS_STANDARD= MOLD OPT_ON[linux]= MOLD BUILD_DEPENDS= autoconf213:single:standard cbindgen:single:standard clang:complete:standard dav1d:dev:standard evdev-proto:single:standard ffmpeg:dev:standard harfbuzz:dev:standard icu:dev:standard libcanberra:dev:standard libevent:dev:standard libnotify:dev:standard libproxy:dev:standard llvm:tools:standard nasm:primary:standard nodejs:primary:standard nss:dev:standard pciutils:dev:standard python-sqlite3:single:python_used rust:single:standard sccache:primary:standard yasm:single:standard zip:single:standard BUILDRUN_DEPENDS= dav1d:primary:standard dbus-glib:primary:standard ffmpeg:primary:standard harfbuzz:primary:standard icu:primary:standard libcanberra:primary:standard libdrm:primary:standard libevent:primary:standard libffi:primary:standard libnotify:primary:standard libproxy:primary:standard nss:primary:standard pciutils:primary:standard RUN_DEPENDS= icu:data:standard B_DEPS[linux]= alsa-lib:dev:standard BR_DEPS[linux]= sndio:single:standard alsa-lib:primary:standard BR_DEPS[netbsd]= sndio:single:standard USES= cpe desktop-utils:single gmake jpeg perl:build pkgconfig png python:v11,build zlib GNOME_COMPONENTS= gdkpixbuf gtk3 XORG_COMPONENTS= pixman xcb ice sm LICENSE= MPL:single LICENSE_TERMS= single:{{WRKSRC}}/toolkit/content/license.html LICENSE_FILE= MPL:stock LICENSE_SCHEME= solo CPE_VENDOR= mozilla FPC_EQUIVALENT= www/firefox MUST_CONFIGURE= yes CONFIGURE_OUTSOURCE= yes CONFIGURE_ENV= PYTHON3={{PYTHON_CMD}} SETUPTOOLS_USE_DISTUTILS=stdlib BINDGEN_CFLAGS="-I{{LOCALBASE}}/include" MAKE_ENV= PYTHON3={{PYTHON_CMD}} CXXSTDLIB="stdc++" QMAKE_ARGS= --enable-application=browser --enable-chrome-format=omni --enable-default-toolkit=cairo-gtk3 --enable-install-strip --enable-official-branding --enable-optimize --enable-release --enable-strip --enable-libproxy --enable-system-ffi --enable-system-pixman --disable-alsa --disable-debug --disable-debug-symbols --disable-dtrace --disable-jack --disable-profiling --disable-pulseaudio --disable-tests --disable-updater --disable-webrtc --disable-hardening --prefix="{{PREFIX}}" --with-intl-api --with-system-icu --with-system-jpeg --with-system-libevent --with-system-nspr --with-system-nss --with-system-png --with-system-zlib --without-wasm-sandboxed-libraries VAR_OPSYS[linux]= QMAKE_ARGS=--disable-elf-hack QMAKE_ARGS=--enable-audio-backends=sndio CONFIGURE_ENV=PKG_CONFIG_LIBDIR={{LOCALBASE}}/lib/pkgconfig VAR_OPSYS[netbsd]= QMAKE_ARGS=--enable-audio-backends=sndio VAR_OPSYS[midnightbsd]= MAKEFILE_LINE=CONFIGURE_TARGET=x86_64-raven-freebsd12.3 [MOLD].DESCRIPTION= Link Firefox with MOLD rather than ports linker [MOLD].BUILD_DEPENDS_ON= mold:primary:standard [MOLD].QMAKE_ARGS_ON= --enable-linker=mold post-patch: ${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ ${WRKSRC}/browser/app/nsBrowserApp.cpp ${REINPLACE_CMD} -e 's/%u/%U/' -e '/X-MultipleArgs/d' \ -e '/^Icon/s/=.*/=firefox/' \ ${WRKSRC}/taskcluster/docker/firefox-snap/firefox.desktop (cd ${WRKSRC}/gfx/angle/checkout/src/compiler/translator && \ ${REINPLACE_CMD} -e 's|||' \ InfoSink.h IntermNode.cpp) # disable SCTP ${REINPLACE_CMD} -e 's|MOZ_SCTP|MOZ_DISABLE_SCTP|' \ ${WRKSRC}/netwerk/moz.build # disable rust checksums ${REINPLACE_CMD} -e 's/"files":{[^}]*}/"files":{}/' \ ${WRKSRC}/third_party/rust/libc/.cargo-checksum.json # Fix midnight ${REINPLACE_CMD} -e "s|%%MBSD64_TGT%%|x86_64-raven-freebsd12.3|" \ ${WRKSRC}/build/autoconf/config.guess # Set mozilla options @${ECHO_CMD} "--=> Setting configuration <=--" @for arg in ${QMAKE_ARGS}; do \ ${ECHO_CMD} ".mozconfig << $$arg" ;\ ${ECHO_CMD} ac_add_options $$arg >> ${WRKSRC}/.mozconfig ;\ done @${ECHO_CMD} LDFLAGS=\"-lm -Wl,-rpath,${PREFIX}/lib/firefox\" \ >> ${WRKSRC}/.mozconfig post-install: ${MKDIR} ${STAGEDIR}${PREFIX}/share/pixmaps \ ${STAGEDIR}${PREFIX}/share/applications ${INSTALL_DATA} ${WRKSRC}/taskcluster/docker/firefox-snap/firefox.desktop \ ${STAGEDIR}${PREFIX}/share/applications/ (cd ${STAGEDIR}${PREFIX}/share/pixmaps &&\ ${LN} -s ../../lib/firefox/browser/chrome/icons/default/default48.png firefox.png) # Rewrite symlink to make it relative instead of absolute (cd ${STAGEDIR}${PREFIX}/bin &&\ ${RM} firefox &&\ ${LN} -s ../lib/firefox/firefox firefox) [FILE:527:descriptions/desc.single] Firefox is a full-featured standard-compliant web browser, built on the Mozilla codebase by thousands of contributors around the world. It is extensible through thousands of user-contributed extensions, and features: * Improved Security; * Improved Tabbed Browsing, with tab grouping; * Private Browsing; * Spell Checking; * Search Suggestions; * Session Restore; * Web Feeds (RSS); * Live Titles; * Integrated Search; * Live Bookmarks; * Pop-up Blocker; * Phishing Protection; * Themes; * Search Engine Manager. [FILE:108:distinfo] 48cc43cab060e97467e9a17617f511a177e7b91b7e77e408425351a2cbb07f70 524717896 firefox-119.0.1.source.tar.xz [FILE:999:manifests/plist.single] %%ONLY-LINUX%%lib/firefox/ Throbber-small.gif crashreporter crashreporter.ini libmozsandbox.so minidump-analyzer %%ONLY-LINUX%%lib/firefox/browser/crashreporter-override.ini bin/firefox lib/firefox/ application.ini dependentlibs.list firefox firefox-bin glxtest libgkcodecs.so libipcclientcerts.so liblgpllibs.so libmozavcodec.so libmozavutil.so libmozgtk.so libmozsqlite3.so libxul.so omni.ja pingsender platform.ini removed-files vaapitest lib/firefox/browser/omni.ja lib/firefox/browser/chrome/icons/default/ default128.png default16.png default32.png default48.png default64.png lib/firefox/browser/features/ formautofill@mozilla.org.xpi pictureinpicture@mozilla.org.xpi screenshots@mozilla.org.xpi webcompat-reporter@mozilla.org.xpi webcompat@mozilla.org.xpi lib/firefox/defaults/pref/channel-prefs.js lib/firefox/fonts/TwemojiMozilla.ttf lib/firefox/gmp-clearkey/0.1/ libclearkey.so manifest.json share/applications/firefox.desktop share/pixmaps/firefox.png [FILE:4626:patches/patch-addon-search] https://github.com/mozilla/addons/issues/708 https://github.com/mozilla/addons-frontend/issues/4610 diff --git browser/app/profile/firefox.js browser/app/profile/firefox.js index 621900f90fc1..401ef9074bd0 100644 --- browser/app/profile/firefox.js +++ browser/app/profile/firefox.js @@ -38,7 +38,7 @@ pref("extensions.postDownloadThirdPartyPrompt", true); // Preferences for AMO integration pref("extensions.getAddons.cache.enabled", true); pref("extensions.getAddons.get.url", "https://services.addons.mozilla.org/api/v4/addons/search/?guid=%IDS%&lang=%LOCALE%"); -pref("extensions.getAddons.search.browseURL", "https://addons.mozilla.org/%LOCALE%/firefox/search?q=%TERMS%&platform=%OS%&appver=%VERSION%"); +pref("extensions.getAddons.search.browseURL", "https://addons.mozilla.org/%LOCALE%/firefox/search?q=%TERMS%&platform=Linux&appver=%VERSION%"); pref("extensions.getAddons.link.url", "https://addons.mozilla.org/%LOCALE%/firefox/"); pref("extensions.getAddons.langpacks.url", "https://services.addons.mozilla.org/api/v4/addons/language-tools/?app=firefox&type=language&appversion=%VERSION%"); pref("extensions.getAddons.discovery.api_url", "https://services.addons.mozilla.org/api/v4/discovery/?lang=%LOCALE%&edition=%DISTRIBUTION%"); @@ -204,8 +204,8 @@ pref("app.update.langpack.enabled", true); // .. etc .. // pref("extensions.update.enabled", true); -pref("extensions.update.url", "https://versioncheck.addons.mozilla.org/update/VersionCheck.php?reqVersion=%REQ_VERSION%&id=%ITEM_ID%&version=%ITEM_VERSION%&maxAppVersion=%ITEM_MAXAPPVERSION%&status=%ITEM_STATUS%&appID=%APP_ID%&appVersion=%APP_VERSION%&appOS=%APP_OS%&appABI=%APP_ABI%&locale=%APP_LOCALE%¤tAppVersion=%CURRENT_APP_VERSION%&updateType=%UPDATE_TYPE%&compatMode=%COMPATIBILITY_MODE%"); -pref("extensions.update.background.url", "https://versioncheck-bg.addons.mozilla.org/update/VersionCheck.php?reqVersion=%REQ_VERSION%&id=%ITEM_ID%&version=%ITEM_VERSION%&maxAppVersion=%ITEM_MAXAPPVERSION%&status=%ITEM_STATUS%&appID=%APP_ID%&appVersion=%APP_VERSION%&appOS=%APP_OS%&appABI=%APP_ABI%&locale=%APP_LOCALE%¤tAppVersion=%CURRENT_APP_VERSION%&updateType=%UPDATE_TYPE%&compatMode=%COMPATIBILITY_MODE%"); +pref("extensions.update.url", "https://versioncheck.addons.mozilla.org/update/VersionCheck.php?reqVersion=%REQ_VERSION%&id=%ITEM_ID%&version=%ITEM_VERSION%&maxAppVersion=%ITEM_MAXAPPVERSION%&status=%ITEM_STATUS%&appID=%APP_ID%&appVersion=%APP_VERSION%&appOS=Linux&appABI=%APP_ABI%&locale=%APP_LOCALE%¤tAppVersion=%CURRENT_APP_VERSION%&updateType=%UPDATE_TYPE%&compatMode=%COMPATIBILITY_MODE%"); +pref("extensions.update.background.url", "https://versioncheck-bg.addons.mozilla.org/update/VersionCheck.php?reqVersion=%REQ_VERSION%&id=%ITEM_ID%&version=%ITEM_VERSION%&maxAppVersion=%ITEM_MAXAPPVERSION%&status=%ITEM_STATUS%&appID=%APP_ID%&appVersion=%APP_VERSION%&appOS=Linux&appABI=%APP_ABI%&locale=%APP_LOCALE%¤tAppVersion=%CURRENT_APP_VERSION%&updateType=%UPDATE_TYPE%&compatMode=%COMPATIBILITY_MODE%"); pref("extensions.update.interval", 86400); // Check for updates to Extensions and // Themes every day diff --git toolkit/mozapps/extensions/internal/AddonRepository.sys.mjs toolkit/mozapps/extensions/internal/AddonRepository.sys.mjs index f906f244b658..7bb2eb6697c6 100644 --- toolkit/mozapps/extensions/internal/AddonRepository.sys.mjs +++ toolkit/mozapps/extensions/internal/AddonRepository.sys.mjs @@ -596,7 +596,7 @@ export var AddonRepository = { addon.version = String(aEntry.current_version.version); if (Array.isArray(aEntry.current_version.files)) { for (let file of aEntry.current_version.files) { - if (file.platform == "all" || file.platform == lazy.PLATFORM) { + if (file.platform == "all" || file.platform == "linux" || file.platform == lazy.PLATFORM) { if (file.url) { addon.sourceURI = lazy.NetUtil.newURI(file.url); } diff --git toolkit/mozapps/extensions/internal/XPIDatabase.jsm toolkit/mozapps/extensions/internal/XPIDatabase.jsm index 03186dad43a4..4053fc6f2702 100644 --- toolkit/mozapps/extensions/internal/XPIDatabase.jsm +++ toolkit/mozapps/extensions/internal/XPIDatabase.jsm @@ -634,7 +634,7 @@ class AddonInternal { // Something is causing errors in here try { for (let platform of this.targetPlatforms) { - if (platform.os == Services.appinfo.OS) { + if (platform.os == "Linux" || platform.os == Services.appinfo.OS) { if (platform.abi) { needsABI = true; if (platform.abi === abi) { [FILE:642:patches/patch-browser_app_nsBrowserApp.cpp] diff --git browser/app/nsBrowserApp.cpp browser/app/nsBrowserApp.cpp index 87c2e16..a41f1d9 100644 --- browser/app/nsBrowserApp.cpp.orig 2023-06-08 22:09:31 UTC +++ browser/app/nsBrowserApp.cpp @@ -388,6 +388,9 @@ int main(int argc, char* argv[], char* e // Register an external module to report on otherwise uncatchable exceptions. CrashReporter::RegisterRuntimeExceptionModule(); + setenv("MOZ_GMP_PATH", "%%LOCALBASE%%/lib/browser_plugins/symlinks/gecko", 0); + setenv("MOZ_PLUGIN_PATH", "%%LOCALBASE%%/lib/browser_plugins/symlinks/gecko", 0); + #ifdef HAS_DLL_BLOCKLIST DllBlocklist_Initialize(gBlocklistInitFlags); #endif [FILE:2405:patches/patch-bug1504834_comment5] https://bugzilla.mozilla.org/show_bug.cgi?id=1504834#c5 https://bugzilla.mozilla.org/attachment.cgi?id=9028600 Rough progress patch diff --git gfx/2d/DrawTargetSkia.cpp gfx/2d/DrawTargetSkia.cpp index 6bbef8d..82b04ba 100644 --- gfx/2d/DrawTargetSkia.cpp.orig 2023-06-08 22:09:35 UTC +++ gfx/2d/DrawTargetSkia.cpp @@ -155,8 +155,7 @@ static IntRect CalculateSurfaceBounds(co return surfaceBounds.Intersect(bounds); } -static const int kARGBAlphaOffset = - SurfaceFormat::A8R8G8B8_UINT32 == SurfaceFormat::B8G8R8A8 ? 3 : 0; +static const int kARGBAlphaOffset = 0; static bool VerifyRGBXFormat(uint8_t* aData, const IntSize& aSize, const int32_t aStride, SurfaceFormat aFormat) { --- gfx/2d/Types.h.orig 2023-06-08 22:09:33 UTC +++ gfx/2d/Types.h @@ -92,15 +92,8 @@ enum class SurfaceFormat : int8_t { // The following values are endian-independent synonyms. The _UINT32 suffix // indicates that the name reflects the layout when viewed as a uint32_t // value. -#if MOZ_LITTLE_ENDIAN() A8R8G8B8_UINT32 = B8G8R8A8, // 0xAARRGGBB X8R8G8B8_UINT32 = B8G8R8X8, // 0x00RRGGBB -#elif MOZ_BIG_ENDIAN() - A8R8G8B8_UINT32 = A8R8G8B8, // 0xAARRGGBB - X8R8G8B8_UINT32 = X8R8G8B8, // 0x00RRGGBB -#else -# error "bad endianness" -#endif // The following values are OS and endian-independent synonyms. // --- gfx/skia/skia/modules/skcms/skcms.cc.orig 2023-06-08 22:09:35 UTC +++ gfx/skia/skia/modules/skcms/skcms.cc @@ -30,6 +30,8 @@ #include #include #endif +#else + #define SKCMS_PORTABLE #endif static bool runtime_cpu_detection = true; @@ -324,20 +326,28 @@ enum { static uint16_t read_big_u16(const uint8_t* ptr) { uint16_t be; memcpy(&be, ptr, sizeof(be)); -#if defined(_MSC_VER) - return _byteswap_ushort(be); +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + return be; #else + #if defined(_MSC_VER) + return _byteswap_ushort(be); + #else return __builtin_bswap16(be); + #endif #endif } static uint32_t read_big_u32(const uint8_t* ptr) { uint32_t be; memcpy(&be, ptr, sizeof(be)); -#if defined(_MSC_VER) - return _byteswap_ulong(be); +#if __BYTE_ORDER == __ORDER_BIG_ENDIAN__ + return be; #else + #if defined(_MSC_VER) + return _byteswap_ulong(be); + #else return __builtin_bswap32(be); + #endif #endif } [FILE:4240:patches/patch-bug1559213] commit 717bba28411c Author: Jory A. Pratt Date: Thu Jun 13 11:53:00 2019 -0700 Bug 1559213 - Allow to use system av1 libs instead of bundled. --- config/external/moz.build | 5 +++-- config/system-headers.mozbuild | 8 ++++++++ dom/media/platforms/moz.build | 5 +++++ toolkit/moz.configure | 19 ++++++++++++++++++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git config/external/moz.build config/external/moz.build index a0877c9d717e..5caa2036e0ec 100644 --- config/external/moz.build +++ config/external/moz.build @@ -45,8 +45,9 @@ if not CONFIG["MOZ_SYSTEM_LIBVPX"]: external_dirs += ["media/libvpx"] if CONFIG["MOZ_AV1"]: - external_dirs += ["media/libaom"] - external_dirs += ["media/libdav1d"] + if not CONFIG["MOZ_SYSTEM_AV1"]: + external_dirs += ["media/libaom"] + external_dirs += ["media/libdav1d"] if not CONFIG["MOZ_SYSTEM_PNG"]: external_dirs += ["media/libpng"] diff --git config/system-headers.mozbuild config/system-headers.mozbuild index d9489c8f15e4..4d2f15e18c1c 100644 --- config/system-headers.mozbuild +++ config/system-headers.mozbuild @@ -1291,6 +1291,14 @@ if CONFIG['MOZ_ENABLE_LIBPROXY']: 'proxy.h', ] +if CONFIG['MOZ_SYSTEM_AV1']: + system_headers += [ + 'aom/aom_decoder.h', + 'aom/aomdx.h', + 'aom/aom_image.h', + 'dav1d/dav1d.h', + ] + if CONFIG['MOZ_SYSTEM_LIBVPX']: system_headers += [ 'vpx_mem/vpx_mem.h', diff --git dom/media/platforms/moz.build dom/media/platforms/moz.build index c71f22a22eee..efbd523b1225 100644 --- dom/media/platforms/moz.build +++ dom/media/platforms/moz.build @@ -80,6 +80,11 @@ if CONFIG["MOZ_AV1"]: "agnostic/AOMDecoder.cpp", "agnostic/DAV1DDecoder.cpp", ] + if CONFIG['MOZ_SYSTEM_AV1']: + CXXFLAGS += CONFIG['MOZ_SYSTEM_LIBAOM_CFLAGS'] + OS_LIBS += CONFIG['MOZ_SYSTEM_LIBAOM_LIBS'] + CXXFLAGS += CONFIG['MOZ_SYSTEM_LIBDAV1D_CFLAGS'] + OS_LIBS += CONFIG['MOZ_SYSTEM_LIBDAV1D_LIBS'] if CONFIG["MOZ_OMX"]: EXPORTS += [ diff --git media/ffvpx/libavcodec/moz.build media/ffvpx/libavcodec/moz.build index 5675c28234a1..56344e5e4c98 100644 --- media/ffvpx/libavcodec/moz.build +++ media/ffvpx/libavcodec/moz.build @@ -109,10 +109,14 @@ if not CONFIG['MOZ_FFVPX_AUDIOONLY']: 'vp9recon.c', 'vpx_rac.c', ] - USE_LIBS += [ - 'dav1d', - 'media_libdav1d_asm', - ] + if CONFIG["MOZ_SYSTEM_AV1"]: + CFLAGS += CONFIG['MOZ_SYSTEM_LIBDAV1D_CFLAGS'] + OS_LIBS += CONFIG['MOZ_SYSTEM_LIBDAV1D_LIBS'] + else: + USE_LIBS += [ + 'dav1d', + 'media_libdav1d_asm', + ] if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": LOCAL_INCLUDES += ['/media/mozva'] SOURCES += [ diff --git toolkit/moz.configure toolkit/moz.configure index 2e56fa46ce59..23e30935c4bc 100644 --- toolkit/moz.configure +++ toolkit/moz.configure @@ -745,7 +745,23 @@ def av1(value): return True -@depends(target, when=av1 & compile_environment) +option("--with-system-av1", + help="Use system av1 (located with pkgconfig)") + +system_libaom_info = pkg_check_modules("MOZ_SYSTEM_LIBAOM", "aom >= 1.0.0", + when="--with-system-av1") + +system_libdav1d_info = pkg_check_modules("MOZ_SYSTEM_LIBDAV1D", "dav1d >= 0.1.1", + when="--with-system-av1") + +@depends(system_libaom_info, system_libdav1d_info) +def system_av1(system_libaom_info, system_libdav1d_info): + has_av1_libs = False + if system_libaom_info and system_libdav1d_info: + has_av1_libs = True + return has_av1_libs + +@depends(target, when=av1 & depends(system_av1)(lambda v: not v) & compile_environment) def dav1d_asm(target): if target.cpu in ("aarch64", "x86", "x86_64"): return True @@ -761,6 +777,7 @@ set_config("MOZ_DAV1D_ASM", dav1d_asm) set_define("MOZ_DAV1D_ASM", dav1d_asm) set_config("MOZ_AV1", av1) set_define("MOZ_AV1", av1) +set_config("MOZ_SYSTEM_AV1", depends_if(system_av1)(lambda _: True)) # JXL Image Codec Support # ============================================================== [FILE:2175:patches/patch-bug1659612] media/libcubeb/src/cubeb_alsa.c:613:9: error: implicitly declaring library function 'snprintf' with type 'int (char *, unsigned int, const char *, ...)' [-Werror,-Wimplicit-function-declaration] r = snprintf(node_name, sizeof(node_name), "pcm.%s", string); ^ media/libcubeb/src/cubeb_alsa.c:613:9: note: include the header or explicitly provide a declaration for 'snprintf' media/libcubeb/src/cubeb_alsa.c:1168:3: error: implicitly declaring library function 'alloca' with type 'void *(unsigned int)' [-Werror,-Wimplicit-function-declaration] snd_pcm_hw_params_alloca(&hw_params); ^ /usr/local/include/alsa/pcm.h:737:39: note: expanded from macro 'snd_pcm_hw_params_alloca' #define snd_pcm_hw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_hw_params) ^ /usr/local/include/alsa/global.h:106:57: note: expanded from macro '__snd_alloca' #define __snd_alloca(ptr,type) do { *ptr = (type##_t *) alloca(type##_sizeof()); memset(*ptr, 0, type##_sizeof()); } while (0) ^ media/libcubeb/src/cubeb_alsa.c:1168:3: note: include the header or explicitly provide a declaration for 'alloca' /usr/local/include/alsa/pcm.h:737:39: note: expanded from macro 'snd_pcm_hw_params_alloca' #define snd_pcm_hw_params_alloca(ptr) __snd_alloca(ptr, snd_pcm_hw_params) ^ /usr/local/include/alsa/global.h:106:57: note: expanded from macro '__snd_alloca' #define __snd_alloca(ptr,type) do { *ptr = (type##_t *) alloca(type##_sizeof()); memset(*ptr, 0, type##_sizeof()); } while (0) ^ 2 errors generated. --- media/libcubeb/src/cubeb_alsa.c.orig 2023-06-08 22:09:41 UTC +++ media/libcubeb/src/cubeb_alsa.c @@ -5,12 +5,16 @@ * accompanying file LICENSE for details. */ #undef NDEBUG +#if defined(__FreeBSD__) +#define _GNU_SOURCE +#else #define _DEFAULT_SOURCE #define _BSD_SOURCE #if defined(__NetBSD__) #define _NETBSD_SOURCE /* timersub() */ #endif #define _XOPEN_SOURCE 500 +#endif #include "cubeb-internal.h" #include "cubeb/cubeb.h" #include "cubeb_tracing.h" [FILE:14560:patches/patch-bug1680982] commit 3204512f58a1 Author: Greg V Date: Sun Dec 6 22:07:00 2020 +0000 Bug 1680982 - Use evdev instead of the Linux legacy joystick API for gamepads Using evdev is a prerequisite for adding rumble (haptic feedback) and LED support. - BTN_GAMEPAD semantic buttons are interpreted directly, since all kernel drivers are supposed to use them correctly: https://www.kernel.org/doc/html/latest/input/gamepad.html - BTN_JOYSTICK legacy style numbered buttons use the model specific remappers - we support even strange devices that combine both styles in one device - the Linux gamepad module is enabled on FreeBSD and DragonFly, because these kernels provide evdev, and libudev-devd provides enough of libudev (evdev headers are provided by the devel/evdev-proto package) Differential Revision: https://phabricator.services.mozilla.com/D98868 --- dom/gamepad/linux/LinuxGamepad.cpp | 262 ++++++++++++++++++++++++++++++++----- dom/gamepad/moz.build | 2 +- 2 files changed, 229 insertions(+), 35 deletions(-) diff --git dom/gamepad/linux/LinuxGamepad.cpp dom/gamepad/linux/LinuxGamepad.cpp index deee47b9d267..31f0aad7ae4a 100644 --- dom/gamepad/linux/LinuxGamepad.cpp.orig 2023-06-08 22:09:33 UTC +++ dom/gamepad/linux/LinuxGamepad.cpp @@ -5,15 +5,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* - * LinuxGamepadService: A Linux backend for the GamepadService. - * Derived from the kernel documentation at - * http://www.kernel.org/doc/Documentation/input/joystick-api.txt + * LinuxGamepadService: An evdev backend for the GamepadService. + * + * Ref: https://www.kernel.org/doc/html/latest/input/gamepad.html */ #include +#include #include #include -#include +#include #include #include #include @@ -21,10 +22,14 @@ #include "nscore.h" #include "mozilla/dom/GamepadHandle.h" #include "mozilla/dom/GamepadPlatformService.h" +#include "mozilla/dom/GamepadRemapping.h" #include "mozilla/Tainting.h" #include "mozilla/UniquePtr.h" #include "udev.h" +#define LONG_BITS (sizeof(long) * 8) +#define NLONGS(x) (((x) + LONG_BITS - 1) / LONG_BITS) + namespace { using namespace mozilla::dom; @@ -36,19 +41,29 @@ using mozilla::udev_list_entry; using mozilla::udev_monitor; using mozilla::UniquePtr; -static const float kMaxAxisValue = 32767.0; -static const char kJoystickPath[] = "/dev/input/js"; +static const char kEvdevPath[] = "/dev/input/event"; + +static inline bool TestBit(const unsigned long* arr, int bit) { + return !!(arr[bit / LONG_BITS] & (1LL << (bit % LONG_BITS))); +} + +static inline double ScaleAxis(const input_absinfo& info, int value) { + return 2.0 * (value - info.minimum) / (double)(info.maximum - info.minimum) - + 1.0; +} // TODO: should find a USB identifier for each device so we can // provide something that persists across connect/disconnect cycles. -typedef struct { +struct Gamepad { GamepadHandle handle; - guint source_id; - int numAxes; - int numButtons; - char idstring[256]; - char devpath[PATH_MAX]; -} Gamepad; + RefPtr remapper = nullptr; + guint source_id = UINT_MAX; + char idstring[256] = {0}; + char devpath[PATH_MAX] = {0}; + uint8_t key_map[KEY_MAX] = {0}; + uint8_t abs_map[ABS_MAX] = {0}; + std::unordered_map abs_info; +}; class LinuxGamepadService { public: @@ -66,7 +81,7 @@ class LinuxGamepadService { bool is_gamepad(struct udev_device* dev); void ReadUdevChange(); - // handler for data from /dev/input/jsN + // handler for data from /dev/input/eventN static gboolean OnGamepadData(GIOChannel* source, GIOCondition condition, gpointer data); @@ -114,8 +129,14 @@ void LinuxGamepadService::AddDevice(stru g_io_channel_set_encoding(channel, nullptr, nullptr); g_io_channel_set_buffered(channel, FALSE); int fd = g_io_channel_unix_get_fd(channel); + + struct input_id id {}; + if (ioctl(fd, EVIOCGID, &id) == -1) { + return; + } + char name[128]; - if (ioctl(fd, JSIOCGNAME(sizeof(name)), &name) == -1) { + if (ioctl(fd, EVIOCGNAME(sizeof(name)), &name) == -1) { strcpy(name, "unknown"); } const char* vendor_id = @@ -131,20 +152,86 @@ void LinuxGamepadService::AddDevice(stru model_id = mUdev.udev_device_get_sysattr_value(parent, "id/product"); } } + if (!vendor_id && id.vendor != 0) { + vendor_id = (const char*)alloca(5); + snprintf((char*)vendor_id, 5, "%04x", id.vendor); + } + if (!model_id && id.product != 0) { + model_id = (const char*)alloca(5); + snprintf((char*)model_id, 5, "%04x", id.product); + } snprintf(gamepad->idstring, sizeof(gamepad->idstring), "%s-%s-%s", vendor_id ? vendor_id : "unknown", model_id ? model_id : "unknown", name); char numAxes = 0, numButtons = 0; - ioctl(fd, JSIOCGAXES, &numAxes); - gamepad->numAxes = numAxes; - ioctl(fd, JSIOCGBUTTONS, &numButtons); - gamepad->numButtons = numButtons; + unsigned long key_bits[NLONGS(KEY_CNT)] = {0}; + unsigned long abs_bits[NLONGS(ABS_CNT)] = {0}; + ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(key_bits)), key_bits); + ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(abs_bits)), abs_bits); + + /* Here, we try to support even strange cases where proper semantic + * BTN_GAMEPAD button are combined with arbitrary extra buttons. */ + for (uint16_t i = BTN_JOYSTICK; i < KEY_MAX; i++) { + /* Do not map semantic buttons, they are handled directly */ + if (i == BTN_GAMEPAD) { + i = BTN_THUMBR + 1; + continue; + } + if (i == BTN_DPAD_UP) { + i = BTN_DPAD_RIGHT + 1; + continue; + } + if (TestBit(key_bits, i)) { + gamepad->key_map[i] = numButtons++; + } + } + for (uint16_t i = 0; i < BTN_JOYSTICK; i++) { + if (TestBit(key_bits, i)) { + gamepad->key_map[i] = numButtons++; + } + } + for (uint16_t i = BTN_GAMEPAD; i <= BTN_THUMBR; i++) { + /* But if any semantic event exists, count them all */ + if (TestBit(key_bits, i)) { + numButtons += BUTTON_INDEX_COUNT; + break; + } + } + for (uint16_t i = 0; i < ABS_MAX; ++i) { + if (TestBit(abs_bits, i)) { + gamepad->abs_info.emplace(i, input_absinfo{}); + if (ioctl(fd, EVIOCGABS(i), &gamepad->abs_info[i]) < 0) { + continue; + } + if (gamepad->abs_info[i].minimum == gamepad->abs_info[i].maximum) { + gamepad->abs_info.erase(i); + continue; + } + gamepad->abs_map[i] = numAxes++; + } + } + + if (numAxes == 0) { + NS_WARNING("Gamepad with zero axes detected?"); + } + if (numButtons == 0) { + NS_WARNING("Gamepad with zero buttons detected?"); + } + + bool defaultRemapper = false; + RefPtr remapper = + GetGamepadRemapper(id.vendor, id.product, defaultRemapper); + MOZ_ASSERT(remapper); + remapper->SetAxisCount(numAxes); + remapper->SetButtonCount(numButtons); gamepad->handle = service->AddGamepad( - gamepad->idstring, mozilla::dom::GamepadMappingType::_empty, - mozilla::dom::GamepadHand::_empty, gamepad->numButtons, gamepad->numAxes, - 0, 0, 0); // TODO: Bug 680289, implement gamepad haptics for Linux. + gamepad->idstring, remapper->GetMappingType(), GamepadHand::_empty, + remapper->GetButtonCount(), remapper->GetAxisCount(), 0, + remapper->GetLightIndicatorCount(), remapper->GetTouchEventCount()); + gamepad->remapper = remapper.forget(); + // TODO: Bug 680289, implement gamepad haptics for Linux. // TODO: Bug 1523355, implement gamepad lighindicator and touch for Linux. gamepad->source_id = @@ -257,7 +344,7 @@ bool LinuxGamepadService::is_gamepad(str if (!devpath) { return false; } - if (strncmp(kJoystickPath, devpath, sizeof(kJoystickPath) - 1) != 0) { + if (strncmp(kEvdevPath, devpath, sizeof(kEvdevPath) - 1) != 0) { return false; } @@ -292,7 +379,7 @@ gboolean LinuxGamepadService::OnGamepadD if (condition & G_IO_ERR || condition & G_IO_HUP) return FALSE; while (true) { - struct js_event event; + struct input_event event {}; gsize count; GError* err = nullptr; if (g_io_channel_read_chars(source, (gchar*)&event, sizeof(event), &count, @@ -301,18 +388,125 @@ gboolean LinuxGamepadService::OnGamepadD break; } - // TODO: store device state? - if (event.type & JS_EVENT_INIT) { - continue; - } - switch (event.type) { - case JS_EVENT_BUTTON: - service->NewButtonEvent(gamepad->handle, event.number, !!event.value); + case EV_KEY: + switch (event.code) { + /* The gamepad events are meaningful, and according to + * https://www.kernel.org/doc/html/latest/input/gamepad.html + * "No other devices, that do not look/feel like a gamepad, shall + * report these events" */ + case BTN_SOUTH: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_PRIMARY, + !!event.value); + break; + case BTN_EAST: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_SECONDARY, + !!event.value); + break; + case BTN_NORTH: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_QUATERNARY, + !!event.value); + break; + case BTN_WEST: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_TERTIARY, + !!event.value); + break; + case BTN_TL: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_LEFT_SHOULDER, + !!event.value); + break; + case BTN_TR: + service->NewButtonEvent(gamepad->handle, + BUTTON_INDEX_RIGHT_SHOULDER, !!event.value); + break; + case BTN_TL2: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_LEFT_TRIGGER, + !!event.value); + break; + case BTN_TR2: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_RIGHT_TRIGGER, + !!event.value); + break; + case BTN_SELECT: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_BACK_SELECT, + !!event.value); + break; + case BTN_START: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_START, + !!event.value); + break; + case BTN_MODE: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_META, + !!event.value); + break; + case BTN_THUMBL: + service->NewButtonEvent( + gamepad->handle, BUTTON_INDEX_LEFT_THUMBSTICK, !!event.value); + break; + case BTN_THUMBR: + service->NewButtonEvent( + gamepad->handle, BUTTON_INDEX_RIGHT_THUMBSTICK, !!event.value); + break; + case BTN_DPAD_UP: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_DPAD_UP, + !!event.value); + break; + case BTN_DPAD_DOWN: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_DPAD_DOWN, + !!event.value); + break; + case BTN_DPAD_LEFT: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_DPAD_LEFT, + !!event.value); + break; + case BTN_DPAD_RIGHT: + service->NewButtonEvent(gamepad->handle, BUTTON_INDEX_DPAD_RIGHT, + !!event.value); + break; + default: + /* For non-gamepad events, this is the "anything goes" numbered + * handling that should be handled with remappers. */ + gamepad->remapper->RemapButtonEvent( + gamepad->handle, gamepad->key_map[event.code], !!event.value); + break; + } break; - case JS_EVENT_AXIS: - service->NewAxisMoveEvent(gamepad->handle, event.number, - ((float)event.value) / kMaxAxisValue); + case EV_ABS: + if (!gamepad->abs_info.count(event.code)) continue; + switch (event.code) { + case ABS_HAT0X: + service->NewButtonEvent( + gamepad->handle, BUTTON_INDEX_DPAD_LEFT, + AxisNegativeAsButton( + ScaleAxis(gamepad->abs_info[event.code], event.value))); + service->NewButtonEvent( + gamepad->handle, BUTTON_INDEX_DPAD_RIGHT, + AxisPositiveAsButton( + ScaleAxis(gamepad->abs_info[event.code], event.value))); + break; + case ABS_HAT0Y: + service->NewButtonEvent( + gamepad->handle, BUTTON_INDEX_DPAD_UP, + AxisNegativeAsButton( + ScaleAxis(gamepad->abs_info[event.code], event.value))); + service->NewButtonEvent( + gamepad->handle, BUTTON_INDEX_DPAD_DOWN, + AxisPositiveAsButton( + ScaleAxis(gamepad->abs_info[event.code], event.value))); + break; + case ABS_HAT1X: + case ABS_HAT1Y: + case ABS_HAT2X: + case ABS_HAT2Y: + case ABS_HAT3X: + case ABS_HAT3Y: + break; + default: + gamepad->remapper->RemapAxisMoveEvent( + gamepad->handle, gamepad->abs_map[event.code], + ScaleAxis(gamepad->abs_info[event.code], event.value)); + break; + } break; } } --- dom/gamepad/moz.build.orig 2023-06-08 22:09:34 UTC +++ dom/gamepad/moz.build @@ -59,7 +59,7 @@ elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "wi UNIFIED_SOURCES += ["windows/WindowsGamepad.cpp"] elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "android": UNIFIED_SOURCES += ["android/AndroidGamepad.cpp"] -elif CONFIG["OS_ARCH"] == "Linux": +elif CONFIG["OS_ARCH"] in ("Linux", "FreeBSD", "DragonFly"): UNIFIED_SOURCES += ["linux/LinuxGamepad.cpp"] else: UNIFIED_SOURCES += ["fallback/FallbackGamepad.cpp"] [FILE:2089:patches/patch-bug1859752] # HG changeset patch # User AndrĂ© Bargull # Date 1699346749 0 # Node ID 0e7eefda24250041d7f008cc77dfa79045afa791 # Parent 1e39572cb1c784039a9e14b8c36396c66cf58a5d Bug 1859752 - Part 9: Add new line break classes. r=platform-i18n-reviewers,dminor Use `CLASS_CHARACTER` because that matches the previous character class for most characters which are now part of the new character classes. Depends on D192733 Differential Revision: https://phabricator.services.mozilla.com/D192734 diff --git intl/lwbrk/LineBreaker.cpp intl/lwbrk/LineBreaker.cpp --- intl/lwbrk/LineBreaker.cpp +++ intl/lwbrk/LineBreaker.cpp @@ -443,17 +443,23 @@ static int8_t GetClass(uint32_t u, LineB /* JT = 34, [JT] */ CLASS_CHARACTER, /* JV = 35, [JV] */ CLASS_CHARACTER, /* CLOSE_PARENTHESIS = 36, [CP] */ CLASS_CLOSE_LIKE_CHARACTER, /* CONDITIONAL_JAPANESE_STARTER = 37, [CJ] */ CLASS_CLOSE, /* HEBREW_LETTER = 38, [HL] */ CLASS_CHARACTER, /* REGIONAL_INDICATOR = 39, [RI] */ CLASS_CHARACTER, /* E_BASE = 40, [EB] */ CLASS_BREAKABLE, /* E_MODIFIER = 41, [EM] */ CLASS_CHARACTER, - /* ZWJ = 42, [ZWJ]*/ CLASS_CHARACTER}; + /* ZWJ = 42, [ZWJ]*/ CLASS_CHARACTER, + /* AKSARA = 43, [AK] */ CLASS_CHARACTER, + /* AKSARA_PREBASE = 44, [AP] */ CLASS_CHARACTER, + /* AKSARA_START = 45, [AS] */ CLASS_CHARACTER, + /* VIRAMA_FINAL = 46, [VF] */ CLASS_CHARACTER, + /* VIRAMA = 47, [VI] */ CLASS_CHARACTER, + }; static_assert(U_LB_COUNT == mozilla::ArrayLength(sUnicodeLineBreakToClass), "Gecko vs ICU LineBreak class mismatch"); auto cls = GetLineBreakClass(u); MOZ_ASSERT(cls < mozilla::ArrayLength(sUnicodeLineBreakToClass)); // Overrides based on rules for the different line-break values given in [FILE:402:patches/patch-build_autoconf_config.guess] --- build/autoconf/config.guess.orig 2023-06-08 22:09:32 UTC +++ build/autoconf/config.guess @@ -284,7 +284,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE ;; *:MidnightBSD:*:*) - GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE + GUESS=%%MBSD64_TGT%% ;; *:ekkoBSD:*:*) GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE [FILE:704:patches/patch-dom_media_flac_FlacDecoder.cpp] Enable FLAC on platforms without ffvpx like powerpc* --- dom/media/flac/FlacDecoder.cpp.orig 2023-06-08 22:09:33 UTC +++ dom/media/flac/FlacDecoder.cpp @@ -7,6 +7,7 @@ #include "FlacDecoder.h" #include "MediaContainerType.h" #include "mozilla/StaticPrefs_media.h" +#include "PDMFactory.h" namespace mozilla { @@ -14,6 +15,10 @@ namespace mozilla { bool FlacDecoder::IsEnabled() { #ifdef MOZ_FFVPX return StaticPrefs::media_flac_enabled(); +#elif defined(MOZ_FFMPEG) + RefPtr platform = new PDMFactory(); + return StaticPrefs::media_flac_enabled() && + (platform->SupportsMimeType("audio/flac"_ns) != media::DecodeSupport::Unsupported); #else return false; #endif [FILE:893:patches/patch-env-api-keys] # Accept API keys from environment like before bug 1294585 --- build/moz.configure/keyfiles.configure.orig 2023-06-08 22:09:32 UTC +++ build/moz.configure/keyfiles.configure @@ -19,6 +19,7 @@ def keyfile(desc, default=None, help=Non @checking("for the %s key" % desc, lambda x: x and x is not no_key) @imports(_from="__builtin__", _import="open") @imports(_from="__builtin__", _import="IOError") + @imports(_from="os", _import="environ") def keyfile(value): if value: try: @@ -29,7 +30,7 @@ def keyfile(desc, default=None, help=Non raise FatalCheckError("'%s' is empty." % value[0]) except IOError as e: raise FatalCheckError("'%s': %s." % (value[0], e.strerror)) - return no_key + return environ.get("MOZ_%s_KEY" % desc.upper().replace(" ", "_")) or no_key return keyfile [FILE:1188:patches/patch-gfx_skia_skia_src_base_SkContainers.cpp] DragonFly eventually gets malloc_usable_size, check again when sysroot updates --- gfx/skia/skia/src/base/SkContainers.cpp.orig 2023-06-08 22:09:35 UTC +++ gfx/skia/skia/src/base/SkContainers.cpp @@ -14,7 +14,7 @@ #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_FOR_IOS) #include -#elif defined(SK_BUILD_FOR_ANDROID) || (defined(SK_BUILD_FOR_UNIX) && !defined(__OpenBSD__)) +#elif defined(SK_BUILD_FOR_ANDROID) || (defined(SK_BUILD_FOR_UNIX) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__NetBSD__)) #include #elif defined(SK_BUILD_FOR_WIN) #include @@ -38,7 +38,7 @@ SkSpan complete_size(void* pt #elif defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 17 completeSize = malloc_usable_size(ptr); SkASSERT(completeSize >= size); - #elif defined(SK_BUILD_FOR_UNIX) && !defined(__OpenBSD__) + #elif defined(SK_BUILD_FOR_UNIX) && !defined(__OpenBSD__) && !defined(__DragonFly__) && !defined(__FreeBSD__) && !defined(__NetBSD__) completeSize = malloc_usable_size(ptr); SkASSERT(completeSize >= size); #elif defined(SK_BUILD_FOR_WIN) [FILE:217:patches/patch-image_imgFrame.h] --- image/imgFrame.h.orig 2023-06-08 22:09:34 UTC +++ image/imgFrame.h @@ -9,6 +9,7 @@ #include #include +#include #include "AnimationParams.h" #include "MainThreadUtils.h" [FILE:316:patches/patch-ipc_chromium_src_base_platform__thread__posix.cc] --- ipc/chromium/src/base/platform_thread_posix.cc.orig 2023-06-08 22:35:48 UTC +++ ipc/chromium/src/base/platform_thread_posix.cc @@ -16,6 +16,8 @@ #elif defined(OS_LINUX) # include # include +#elif defined(OS_DRAGONFLY) +# include #endif #if !defined(OS_MACOSX) [FILE:614:patches/patch-ipc_chromium_src_base_shared__memory__posix.cc] --- ipc/chromium/src/base/shared_memory_posix.cc.orig 2023-08-03 14:46:56 UTC +++ ipc/chromium/src/base/shared_memory_posix.cc @@ -284,6 +284,11 @@ bool SharedMemory::AppendPosixShmPrefix( StringAppendF(str, "snap.%s.", snap); } # endif // XP_LINUX +# ifdef OS_DRAGONFLY + // DragonFly BSD has a userland IPC implementation, we need to prefix the + // path to shm_open(3), preferably with '/tmp' + StringAppendF(str, "tmp/"); +# endif // Hopefully the "implementation defined" name length limit is long // enough for this. StringAppendF(str, "org.mozilla.ipc.%d.", static_cast(pid)); [FILE:1584:patches/patch-js_public_Utility.h] commit 57b30241311091b5a6a5a0bb1c19a8e073860fc3 Author: Christoph Moench-Tegeder do not assert on alignment when not having the bits the underlying issue seemed to be win-only anyways? diff --git js/public/Utility.h js/public/Utility.h index 0d745e9df785..f0ca7ea37162 100644 --- js/public/Utility.h +++ js/public/Utility.h @@ -480,6 +480,7 @@ static inline void js_free(void* p) { * Note: Do not add a ; at the end of a use of JS_DECLARE_NEW_METHODS, * or the build will break. */ +#if !defined(__i386__) #define JS_DECLARE_NEW_METHODS(NEWNAME, ALLOCATOR, QUALIFIERS) \ template \ QUALIFIERS T* MOZ_HEAP_ALLOCATOR NEWNAME(Args&&... args) { \ @@ -490,6 +491,15 @@ static inline void js_free(void* p) { return MOZ_LIKELY(memory) ? new (memory) T(std::forward(args)...) \ : nullptr; \ } +#else +#define JS_DECLARE_NEW_METHODS(NEWNAME, ALLOCATOR, QUALIFIERS) \ + template \ + QUALIFIERS T* MOZ_HEAP_ALLOCATOR NEWNAME(Args&&... args) { \ + void* memory = ALLOCATOR(sizeof(T)); \ + return MOZ_LIKELY(memory) ? new (memory) T(std::forward(args)...) \ + : nullptr; \ + } +#endif /* * Given a class which should provide a 'new' method that takes an arena as [FILE:318:patches/patch-js_src_old-configure.in] --- js/src/old-configure.in.orig 2023-06-08 22:35:48 UTC +++ js/src/old-configure.in @@ -652,7 +652,7 @@ then fi case "$target" in - *-*-freebsd*) + *-*-freebsd*|*-*-dragonfly*) AC_DEFINE(_REENTRANT) AC_DEFINE(_THREAD_SAFE) dnl -pthread links in -lpthread, so don't specify it explicitly. [FILE:361:patches/patch-media_libcubeb_src_cubeb__jack.cpp] --- media/libcubeb/src/cubeb_jack.cpp.orig 2023-06-08 22:09:41 UTC +++ media/libcubeb/src/cubeb_jack.cpp @@ -8,7 +8,7 @@ */ #define _DEFAULT_SOURCE #define _BSD_SOURCE -#if !defined(__FreeBSD__) && !defined(__NetBSD__) +#if !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) #define _POSIX_SOURCE #endif #include "cubeb-internal.h" [FILE:736:patches/patch-modules_fdlibm_src_math__private.h] commit 7a20fbf537ee0867244109d1ea48a8ad9de2e4ea Author: Christoph Moench-Tegeder align typedefs with our libm for historical CPUs diff --git modules/fdlibm/src/math_private.h modules/fdlibm/src/math_private.h index f4373f27834a..3b898241660f 100644 --- modules/fdlibm/src/math_private.h +++ modules/fdlibm/src/math_private.h @@ -30,9 +30,17 @@ * Adapted from https://github.com/freebsd/freebsd-src/search?q=__double_t */ +#ifdef __LP64__ typedef double __double_t; +#else +typedef long double __double_t; +#endif typedef __double_t double_t; +#ifdef __LP64__ typedef float __float_t; +#else +typedef long double __float_t; +#endif /* * The original fdlibm code used statements like: [FILE:2547:patches/patch-mozglue_misc_SSE.h] commit 70c3be521da1296f7ba47bd07b67927e43634d1b Author: Christoph Moench-Tegeder disable SSE and friends in builds for legacy architectures diff --git gfx/thebes/moz.build gfx/thebes/moz.build index 71903756ea19..3591cc0f38e8 100644 --- gfx/thebes/moz.build +++ gfx/thebes/moz.build @@ -174,7 +174,7 @@ elif CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows": ] # Are we targeting x86 or x64? If so, build gfxAlphaRecoverySSE2.cpp. -if CONFIG["INTEL_ARCHITECTURE"]: +if CONFIG["INTEL_ARCHITECTURE"] and CONFIG['CPU_ARCH'] == 'x86_64': SOURCES += ["gfxAlphaRecoverySSE2.cpp"] # The file uses SSE2 intrinsics, so it needs special compile flags on some # compilers. diff --git mozglue/misc/SSE.h mozglue/misc/SSE.h index 0b87366a8043..af0a0b38d23c 100644 --- mozglue/misc/SSE.h +++ mozglue/misc/SSE.h @@ -100,36 +100,50 @@ # define MOZILLA_PRESUME_MMX 1 # endif # ifdef __SSE__ +# if !defined(__386__) // It's ok to use SSE instructions based on the -march option (or // the default for x86_64 or for Intel Mac). # define MOZILLA_PRESUME_SSE 1 # endif +# endif # ifdef __SSE2__ +# if !defined(__386__) // It's ok to use SSE2 instructions based on the -march option (or // the default for x86_64 or for Intel Mac). # define MOZILLA_PRESUME_SSE2 1 # endif +# endif # ifdef __SSE3__ +# if !defined(__386__) // It's ok to use SSE3 instructions based on the -march option (or the // default for Intel Mac). # define MOZILLA_PRESUME_SSE3 1 # endif +# endif # ifdef __SSSE3__ +# if !defined(__386__) // It's ok to use SSSE3 instructions based on the -march option. # define MOZILLA_PRESUME_SSSE3 1 # endif +# endif # ifdef __SSE4A__ +# if !defined(__386__) // It's ok to use SSE4A instructions based on the -march option. # define MOZILLA_PRESUME_SSE4A 1 # endif +# endif # ifdef __SSE4_1__ +# if !defined(__386__) // It's ok to use SSE4.1 instructions based on the -march option. # define MOZILLA_PRESUME_SSE4_1 1 # endif +# endif # ifdef __SSE4_2__ +# if !defined(__386__) // It's ok to use SSE4.2 instructions based on the -march option. # define MOZILLA_PRESUME_SSE4_2 1 # endif +# endif # ifdef __AVX__ // It's ok to use AVX instructions based on the -march option. # define MOZILLA_PRESUME_AVX 1 @@ -144,8 +158,10 @@ # endif # ifdef HAVE_CPUID_H +# if !defined(__i386__) # define MOZILLA_SSE_HAVE_CPUID_DETECTION # endif +# endif #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64)) [FILE:5140:patches/patch-pipewire_init] Chase ABI from multimedia/pipewire/files/patch-src_pipewire_pipewire_init Ref: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1819 diff --git third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc index 1872a8684132..7e519f9e9cbb 100644 --- third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc +++ third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc @@ -417,7 +417,7 @@ bool SharedScreenCastStreamPrivate::StartScreenCastStream( pw_stream_node_id_ = stream_node_id; - pw_init(/*argc=*/nullptr, /*argc=*/nullptr); + pipewire_init(/*argc=*/nullptr, /*argc=*/nullptr); pw_main_loop_ = pw_thread_loop_new("pipewire-main-loop", nullptr); diff --git third_party/libwebrtc/modules/desktop_capture/linux/wayland/test/test_screencast_stream_provider.cc third_party/libwebrtc/modules/desktop_capture/linux/wayland/test/test_screencast_stream_provider.cc index ffba13775363..da6a828a21ee 100644 --- third_party/libwebrtc/modules/desktop_capture/linux/wayland/test/test_screencast_stream_provider.cc +++ third_party/libwebrtc/modules/desktop_capture/linux/wayland/test/test_screencast_stream_provider.cc @@ -36,7 +36,7 @@ TestScreenCastStreamProvider::TestScreenCastStreamProvider(Observer* observer, return; } - pw_init(/*argc=*/nullptr, /*argc=*/nullptr); + pipewire_init(/*argc=*/nullptr, /*argc=*/nullptr); pw_main_loop_ = pw_thread_loop_new("pipewire-test-main-loop", nullptr); diff --git third_party/libwebrtc/modules/portal/pipewire.sigs third_party/libwebrtc/modules/portal/pipewire.sigs index c3abf05b386f..a994c218f5a5 100644 --- third_party/libwebrtc/modules/portal/pipewire.sigs +++ third_party/libwebrtc/modules/portal/pipewire.sigs @@ -15,7 +15,7 @@ pw_loop * pw_loop_new(const spa_dict *props); // pipewire.h -void pw_init(int *argc, char **argv[]); +void pipewire_init(int *argc, char **argv[]); const char* pw_get_library_version(); // properties.h diff --git third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc index f2680b28162c..03476a5fffd0 100644 --- third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc +++ third_party/libwebrtc/modules/video_capture/linux/pipewire_session.cc @@ -252,7 +252,7 @@ void PipeWireSession::InitPipeWire(int fd) { } bool PipeWireSession::StartPipeWire(int fd) { - pw_init(/*argc=*/nullptr, /*argv=*/nullptr); + pipewire_init(/*argc=*/nullptr, /*argv=*/nullptr); pw_main_loop_ = pw_thread_loop_new("pipewire-main-loop", nullptr); diff --git third_party/pipewire/libpipewire/mozpipewire.cpp third_party/pipewire/libpipewire/mozpipewire.cpp index b8068296745e..7e8be3dc764f 100644 --- third_party/pipewire/libpipewire/mozpipewire.cpp +++ third_party/pipewire/libpipewire/mozpipewire.cpp @@ -58,7 +58,7 @@ struct pw_context * (*pw_context_new_fn)(struct pw_loop *main_loop, struct pw_properties *props, size_t user_data_size); static int (*pw_core_disconnect_fn)(struct pw_core *core); -static void (*pw_init_fn)(int *argc, char **argv[]); +static void (*pipewire_init_fn)(int *argc, char **argv[]); static void (*pw_proxy_destroy_fn)(struct pw_proxy *proxy); static void (*pw_stream_add_listener_fn)(struct pw_stream *stream, struct spa_hook *listener, @@ -103,7 +103,7 @@ bool IsPwLibraryLoaded() { IS_FUNC_LOADED(pw_context_destroy_fn) && IS_FUNC_LOADED(pw_context_new_fn) && IS_FUNC_LOADED(pw_core_disconnect_fn) && - IS_FUNC_LOADED(pw_init_fn) && + IS_FUNC_LOADED(pipewire_init_fn) && IS_FUNC_LOADED(pw_proxy_destroy_fn) && IS_FUNC_LOADED(pw_stream_add_listener_fn) && IS_FUNC_LOADED(pw_stream_connect_fn) && @@ -146,7 +146,7 @@ bool LoadPWLibrary() { GET_FUNC(pw_context_destroy, pwLib); GET_FUNC(pw_context_new, pwLib); GET_FUNC(pw_core_disconnect, pwLib); - GET_FUNC(pw_init, pwLib); + GET_FUNC(pipewire_init, pwLib); GET_FUNC(pw_stream_add_listener, pwLib); GET_FUNC(pw_stream_connect, pwLib); GET_FUNC(pw_stream_disconnect, pwLib); @@ -226,12 +226,12 @@ pw_core_disconnect(struct pw_core *core) } void -pw_init(int *argc, char **argv[]) +pipewire_init(int *argc, char **argv[]) { if (!LoadPWLibrary()) { return; } - return pw_init_fn(argc, argv); + return pipewire_init_fn(argc, argv); } void diff --git third_party/pipewire/pipewire/pipewire.h third_party/pipewire/pipewire/pipewire.h index b932103f46e6..2c88e28421ec 100644 --- third_party/pipewire/pipewire/pipewire.h +++ third_party/pipewire/pipewire/pipewire.h @@ -69,9 +69,9 @@ extern "C" { * \{ */ void -pw_init(int *argc, char **argv[]); +pipewire_init(int *argc, char **argv[]); -void pw_deinit(void); +void pipewire_deinit(void); bool pw_debug_is_category_enabled(const char *name); [FILE:2079:patches/patch-python_mozbuild_mozbuild_gn__processor.py] commit 8dfec3226ff4d7d7f852ea700a5052976eded46e Author: Christoph Moench-Tegeder chase gn_processor.py changes diff --git python/mozbuild/mozbuild/gn_processor.py python/mozbuild/mozbuild/gn_processor.py index b6c51ee010a8..15b4bda9df6e 100644 --- python/mozbuild/mozbuild/gn_processor.py +++ python/mozbuild/mozbuild/gn_processor.py @@ -185,6 +185,7 @@ def filter_gn_config(path, gn_result, sandbox_vars, input_vars, gn_target): } oses = { "android": "Android", + "freebsd": "FreeBSD", "linux": "Linux", "mac": "Darwin", "openbsd": "OpenBSD", @@ -735,16 +736,16 @@ def main(): vars_set = [] for is_debug in (True, False): - for target_os in ("android", "linux", "mac", "openbsd", "win"): + for target_os in ("freebsd",): target_cpus = ["x64"] - if target_os in ("android", "linux", "mac", "win", "openbsd"): + if target_os in ("android", "freebsd", "linux", "mac", "win", "openbsd"): target_cpus.append("arm64") if target_os in ("android", "linux"): target_cpus.append("arm") - if target_os in ("android", "linux", "win"): + if target_os in ("android", "freebsd", "linux", "win"): target_cpus.append("x86") - if target_os == "linux": - target_cpus.extend(["ppc64", "riscv64", "mipsel", "mips64el"]) + if target_os in ("freebsd", "linux"): + target_cpus.extend(["ppc64", "mipsel", "mips64el"]) for target_cpu in target_cpus: vars = { "host_cpu": "x64", @@ -752,7 +753,7 @@ def main(): "target_cpu": target_cpu, "target_os": target_os, } - if target_os == "linux": + if target_os in ("freebsd", "linux"): for use_x11 in (True, False): vars["use_x11"] = use_x11 vars_set.append(vars.copy()) [FILE:468:patches/patch-testing_mozbase_mozinfo_mozinfo_mozinfo.py] --- testing/mozbase/mozinfo/mozinfo/mozinfo.py.orig 2023-06-08 22:35:48 UTC +++ testing/mozbase/mozinfo/mozinfo/mozinfo.py @@ -131,7 +131,7 @@ elif system == "Linux": info["os"] = "linux" info["linux_distro"] = distribution -elif system in ["DragonFly", "FreeBSD", "NetBSD", "OpenBSD"]: +elif system in ["DragonFly", "FreeBSD", "NetBSD", "OpenBSD", "MidnightBSD"]: info["os"] = "bsd" version = os_version = sys.platform elif system == "Darwin": [FILE:361:patches/patch-third__party_libwebrtc_build_build__config.h] --- third_party/libwebrtc/build/build_config.h.orig 2023-06-08 22:09:49 UTC +++ third_party/libwebrtc/build/build_config.h @@ -76,7 +76,7 @@ #define OS_WIN 1 #elif defined(__Fuchsia__) #define OS_FUCHSIA 1 -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) #define OS_FREEBSD 1 #elif defined(__NetBSD__) #define OS_NETBSD 1 [FILE:515:patches/patch-third__party_sqlite3_src_moz.build] --- third_party/sqlite3/src/moz.build.orig 2023-06-08 22:35:48 UTC +++ third_party/sqlite3/src/moz.build @@ -92,7 +92,8 @@ DEFINES['SQLITE_TEMP_FILE_PREFIX'] = '"m # Enabling sqlite math functions DEFINES['SQLITE_ENABLE_MATH_FUNCTIONS'] = True -if CONFIG["OS_TARGET"] == "Linux" or CONFIG["OS_TARGET"] == "Android": +if CONFIG["OS_TARGET"] == "Linux" or CONFIG["OS_TARGET"] == "Android" or \ + CONFIG["OS_TARGET"] == "FreeBSD" or CONFIG["OS_TARGET"] == "DragonFly": OS_LIBS += [ "m" ] [FILE:3543:patches/patch-toolkit_components_processtools_procinfo__bsd.c] diff --git toolkit/components/processtools/ProcInfo_bsd.cpp toolkit/components/processtools/ProcInfo_bsd.cpp index a6ff4881940c..f041ed5e50ce 100644 --- toolkit/components/processtools/ProcInfo_bsd.cpp +++ toolkit/components/processtools/ProcInfo_bsd.cpp @@ -18,6 +18,9 @@ #include #include #include +#ifdef __FreeBSD__ +#include +#endif namespace mozilla { @@ -50,25 +53,39 @@ ProcInfoPromise::ResolveOrRejectValue GetProcInfoSync( } for (const auto& request : aRequests) { size_t size; +#ifdef __FreeBSD__ + int mib[4]; + int mibsize = 4; + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID | KERN_PROC_INC_THREAD; + mib[3] = request.pid; +#else int mib[6]; + int mibsize = 6; mib[0] = CTL_KERN; mib[1] = KERN_PROC; mib[2] = KERN_PROC_PID | KERN_PROC_SHOW_THREADS; mib[3] = request.pid; mib[4] = sizeof(kinfo_proc); mib[5] = 0; - if (sysctl(mib, 6, nullptr, &size, nullptr, 0) == -1) { +#endif + if (sysctl(mib, mibsize, nullptr, &size, nullptr, 0) == -1) { // Can't get info for this process. Skip it. continue; } +#ifdef __FreeBSD__ + auto procs = MakeUniqueFallible(size / sizeof(kinfo_proc)); +#else mib[5] = size / sizeof(kinfo_proc); auto procs = MakeUniqueFallible(mib[5]); +#endif if (!procs) { result.SetReject(NS_ERROR_OUT_OF_MEMORY); return result; } - if (sysctl(mib, 6, procs.get(), &size, nullptr, 0) == -1 && + if (sysctl(mib, mibsize, procs.get(), &size, nullptr, 0) == -1 && errno != ENOMEM) { continue; } @@ -84,19 +101,34 @@ ProcInfoPromise::ResolveOrRejectValue GetProcInfoSync( bool found = false; for (size_t i = 0; i < size / sizeof(kinfo_proc); i++) { const auto& p = procs[i]; +#ifdef __FreeBSD__ + if (i == 0) { +#else if (p.p_tid == -1) { +#endif // This is the process. found = true; +#ifdef __FreeBSD__ + info.cpuTime = uint64_t(p.ki_runtime) * 1'000u; + info.memory = (p.ki_tsize + p.ki_dsize + p.ki_ssize) * getpagesize(); +#else info.cpuTime = uint64_t(p.p_rtime_sec) * 1'000'000'000u + uint64_t(p.p_rtime_usec) * 1'000u; info.memory = (p.p_vm_tsize + p.p_vm_dsize + p.p_vm_ssize) * getpagesize(); +#endif + } else { // This is one of its threads. ThreadInfo threadInfo; +#ifdef __FreeBSD__ + threadInfo.tid = p.ki_tid; + threadInfo.cpuTime = uint64_t(p.ki_runtime) * 1'000u; +#else threadInfo.tid = p.p_tid; threadInfo.cpuTime = uint64_t(p.p_rtime_sec) * 1'000'000'000u + uint64_t(p.p_rtime_usec) * 1'000u; +#endif info.threads.AppendElement(threadInfo); } } diff --git toolkit/components/processtools/moz.build toolkit/components/processtools/moz.build index b7c164c1b0ac..a41dad52c343 100644 --- toolkit/components/processtools/moz.build +++ toolkit/components/processtools/moz.build @@ -39,7 +39,7 @@ BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"] # Platform-specific implementations of `ProcInfo`. toolkit = CONFIG["MOZ_WIDGET_TOOLKIT"] if toolkit == "gtk" or toolkit == "android": - if CONFIG["OS_TARGET"] == "OpenBSD": + if CONFIG["OS_TARGET"] == "FreeBSD" or CONFIG["OS_TARGET"] == "OpenBSD": UNIFIED_SOURCES += ["ProcInfo_bsd.cpp"] else: UNIFIED_SOURCES += ["ProcInfo_linux.cpp"] [FILE:498:patches/patch-toolkit_components_protobuf_src_google_protobuf_stubs_port.h] --- toolkit/components/protobuf/src/google/protobuf/stubs/port.h.orig 2023-06-08 22:09:52 UTC +++ toolkit/components/protobuf/src/google/protobuf/stubs/port.h @@ -59,7 +59,7 @@ #else #ifdef __APPLE__ #include // __BYTE_ORDER -#elif defined(__FreeBSD__) +#elif defined(__FreeBSD__) || defined(__DragonFly__) #include // __BYTE_ORDER #elif (defined(sun) || defined(__sun)) && (defined(__SVR4) || defined(__svr4__)) #include // __BYTE_ORDER [FILE:536:patches/patch-toolkit_xre_glxtest.cpp] --- toolkit/xre/glxtest/glxtest.cpp.orig 2023-06-08 22:09:52 UTC +++ toolkit/xre/glxtest/glxtest.cpp @@ -195,9 +195,14 @@ extern "C" { static void get_pci_status() { log("GLX_TEST: get_pci_status start\n"); +#if defined(__FreeBSD__) || defined(__DragonFly__) + if (access("/dev/pci", F_OK) != 0) { + record_warning("cannot access /dev/pci"); +#else if (access("/sys/bus/pci/", F_OK) != 0 && access("/sys/bus/pci_express/", F_OK) != 0) { record_warning("cannot access /sys/bus/pci"); +#endif return; } [FILE:1519:patches/patch-tools_profiler_core_patform.cpp] commit 45a7951cb6a9b1735b9b6cec89db69b5933715c7 Author: Christoph Moench-Tegeder Date: Mon Mar 28 21:54:35 2022 +0200 FreeBSD can use sched_getcpu() from 1400046/1300524 on diff --git tools/profiler/core/platform.cpp tools/profiler/core/platform.cpp index 92bcc1100687..2f17a88942a8 100644 --- tools/profiler/core/platform.cpp.orig 2023-06-08 22:09:52 UTC +++ tools/profiler/core/platform.cpp @@ -115,6 +115,20 @@ # include #endif +#if defined(GP_OS_freebsd) +#include +// "after making CPU_SET macros compatible with glibc" +# if __FreeBSD_version > 1400045 || (__FreeBSD_version > 1300523 && __FreeBSD_version < 1400000) +# include +# else +# if __x86_64__ || __i386__ +// similar cpuid_count() trick as on Darwin, using LLVM +// but not for all CPUs +# include +# endif +# endif +#endif + #if defined(GP_OS_windows) # include @@ -6703,6 +6717,19 @@ void profiler_mark_thread_awake() { cpuId = ebx >> 24; } # endif +#elif defined(GP_OS_freebsd) +# if __FreeBSD_version > 1400045 || (__FreeBSD_version > 1300523 && __FreeBSD_version < 1400000) + cpuId = sched_getcpu(); +# elif defined(__amd64__) + unsigned int eax, ebx, ecx, edx; + __cpuid_count(1, 0, eax, ebx, ecx, edx); + // Check if we have an APIC. + if ((edx & (1 << 9))) { + // APIC ID is bits 24-31 of EBX + cpuId = ebx >> 24; + } +# endif +// the fallthrough is cpuID = 0 #else cpuId = sched_getcpu(); #endif [FILE:231:files/pkg-message-single] ========================================================================== If Firefox segfaults, try setting MOZ_FORCE_DISABLE_E10S=1 in environment. ========================================================================== [FILE:187:files/special.mk] .if defined(BUILD_WITH_CCACHE) # QMAKE_ARGS+= --with-ccache=${LOCALBASE}/bin/sccache MAKE_ENV+= SCCACHE_DIR=${CCACHE_DIR}/sccache MAKE_ENV+= RUSTC_WRAPPER=${LOCALBASE}/bin/sccache .endif