diff --git a/D188068.diff b/D188068.diff new file mode 100644 index 0000000000000000000000000000000000000000..cccc8079d69da9e1286ed86f6097fd98b3350d54 --- /dev/null +++ b/D188068.diff @@ -0,0 +1,42 @@ +diff --git a/js/src/jit/riscv64/CodeGenerator-riscv64.cpp b/js/src/jit/riscv64/CodeGenerator-riscv64.cpp +--- a/js/src/jit/riscv64/CodeGenerator-riscv64.cpp ++++ b/js/src/jit/riscv64/CodeGenerator-riscv64.cpp +@@ -1103,22 +1103,29 @@ + masm.xor64(ToRegister64(lhs), ToRegister64(lhs)); + return; + case 1: + // nop + return; ++ case 2: ++ masm.add(output.reg, ToRegister64(lhs).reg, ToRegister64(lhs).reg); ++ return; + default: + if (constant > 0) { +- if (mozilla::IsPowerOfTwo(static_cast(constant + 1))) { +- masm.move64(ToRegister64(lhs), output); +- masm.lshift64(Imm32(FloorLog2(constant + 1)), output); +- masm.sub64(ToRegister64(lhs), output); ++ if (mozilla::IsPowerOfTwo(static_cast(constant + 1))) { ++ ScratchRegisterScope scratch(masm); ++ masm.movePtr(ToRegister64(lhs).reg, scratch); ++ masm.slli(output.reg, ToRegister64(lhs).reg, ++ FloorLog2(constant + 1)); ++ masm.sub64(scratch, output); + return; + } else if (mozilla::IsPowerOfTwo( +- static_cast(constant - 1))) { +- masm.move64(ToRegister64(lhs), output); +- masm.lshift64(Imm32(FloorLog2(constant - 1u)), output); +- masm.add64(ToRegister64(lhs), output); ++ static_cast(constant - 1))) { ++ int32_t shift = mozilla::FloorLog2(constant - 1); ++ ScratchRegisterScope scratch(masm); ++ masm.movePtr(ToRegister64(lhs).reg, scratch); ++ masm.slli(output.reg, ToRegister64(lhs).reg, shift); ++ masm.add64(scratch, output); + return; + } + // Use shift if constant is power of 2. + int32_t shift = mozilla::FloorLog2(constant); + if (int64_t(1) << shift == constant) { + diff --git a/bmo-1559213-Support-system-av1.patch b/bmo-1559213-Support-system-av1.patch new file mode 100644 index 0000000000000000000000000000000000000000..0bdbd6a126705c727b15e65078be715cfbc4f3f5 --- /dev/null +++ b/bmo-1559213-Support-system-av1.patch @@ -0,0 +1,114 @@ +From 8a4627c0c910415b00bebeb976dc6ea8c3e0d5d0 Mon Sep 17 00:00:00 2001 +From: Thomas Deutschmann +Date: Mon, 6 Apr 2020 19:36:02 +0200 +Subject: [PATCH 06/30] bmo#1559213: Support system av1 + +Allow building against system-wide av1. + +Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1559213 +Signed-off-by: Thomas Deutschmann +--- + config/external/moz.build | 5 +++-- + config/system-headers.mozbuild | 8 ++++++++ + dom/media/platforms/moz.build | 5 +++++ + toolkit/moz.configure | 20 ++++++++++++++++++-- + 4 files changed, 34 insertions(+), 4 deletions(-) + +diff --git a/config/external/moz.build b/config/external/moz.build +index ab771212bf..75595d999c 100644 +--- a/config/external/moz.build ++++ b/config/external/moz.build +@@ -49,8 +49,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 a/config/system-headers.mozbuild b/config/system-headers.mozbuild +index 2f7ae39515..96ab3a6466 100644 +--- a/config/system-headers.mozbuild ++++ b/config/system-headers.mozbuild +@@ -1301,6 +1301,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 a/dom/media/platforms/moz.build b/dom/media/platforms/moz.build +index 8509aec6ef..7c5a1df63d 100644 +--- a/dom/media/platforms/moz.build ++++ b/dom/media/platforms/moz.build +@@ -78,6 +78,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 a/toolkit/moz.configure b/toolkit/moz.configure +index a68e1b347d..7b7975bd12 100644 +--- a/toolkit/moz.configure ++++ b/toolkit/moz.configure +@@ -544,14 +544,29 @@ def av1(value): + if value: + return True + ++option("--with-system-av1", help="Use system av1 (located with pkg-config)") + +-@depends(target, when=av1 & compile_environment) ++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 + + +-@depends(target, when=av1 & compile_environment) ++@depends(target, when=av1 & depends(system_av1)(lambda v: not v) & compile_environment) + def dav1d_nasm(target): + if target.cpu in ("x86", "x86_64"): + return namespace(version="2.14", what="AV1") +@@ -561,6 +576,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 + # ============================================================== +-- +2.34.1 + \ No newline at end of file diff --git a/bmo-1559213-fix-system-av1-libs.patch b/bmo-1559213-fix-system-av1-libs.patch new file mode 100644 index 0000000000000000000000000000000000000000..e197152eefb3484c482b30e6e9a8474e7be6b241 --- /dev/null +++ b/bmo-1559213-fix-system-av1-libs.patch @@ -0,0 +1,23 @@ +diff --git a/media/ffvpx/libavcodec/moz.build b/media/ffvpx/libavcodec/moz.build +index 61d9962a71..d028ec9d70 100644 +--- a/media/ffvpx/libavcodec/moz.build ++++ b/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_WAYLAND']: + LOCAL_INCLUDES += ['/media/mozva'] + SOURCES += [ diff --git a/firefox.spec b/firefox.spec index c51bf66c6432d60fe591dd564feaad6ade2a4769..2fb5d3c9f21633b33fc194452544122c6c2b3523 100644 --- a/firefox.spec +++ b/firefox.spec @@ -18,9 +18,11 @@ %global system_nss 1 %global llvm_version 7.0 %global rust_version 1.66 -%global system_libvpx 0 %global wayland_backend_default 0 +%global system_av1 0 +%global system_libvpx 1 +%global system_webp 1 %if %{?system_nss} %global nspr_version 4.35 @@ -43,7 +45,7 @@ Summary: Mozilla Firefox Web browser Name: firefox Version: 115.5.0 -Release: 1 +Release: 2 URL: https://www.mozilla.org/firefox/ License: MPLv1.1 or GPLv2+ or LGPLv2+ Source0: https://ftp.mozilla.org/pub/firefox/releases/%{version}esr/source/firefox-%{version}esr.source.tar.xz @@ -93,7 +95,6 @@ Patch106: mozilla-bmo998749.patch # Big endian fix Patch107: mozilla-bmo1716707-swizzle.patch Patch108: mozilla-bmo1716707-svg.patch -Patch109: mozilla-bmo1789216-disable-av1.patch # ---- Fedora specific patches ---- Patch151: firefox-enable-addons.patch @@ -111,6 +112,16 @@ Patch201: firefox-tests-xpcshell-freeze.patch # ---- Security patches ---- Patch301: CVE-2023-44488-libvpx.patch + +# system AV1 patches (from Gentoo) +Patch800: bmo-1559213-Support-system-av1.patch +Patch801: bmo-1559213-fix-system-av1-libs.patch + +# ---- RISCV64 patches ---- +# Fix register conflict in MulI64.r=jseward +# https://phabricator.services.mozilla.com/D188068 +Patch1001: D188068.diff + # BUILD REQURES/REQUIRES %if %{?system_nss} BuildRequires: pkgconfig(nspr) >= %{nspr_version} @@ -121,10 +132,6 @@ BuildRequires: nss-static >= %{nss_version} BuildRequires: nss-static < %{nss_version_max} %endif -%if %{?system_libvpx} -BuildRequires: libvpx-devel >= 1.8.2 -%endif - BuildRequires: bzip2-devel BuildRequires: dbus-glib-devel BuildRequires: desktop-file-utils @@ -216,9 +223,22 @@ BuildRequires: xorg-x11-fonts-misc BuildRequires: xorg-x11-server-Xvfb %endif +%if %{?system_av1} +BuildRequires: pkgconfig(aom) +BuildRequires: pkgconfig(dav1d) +%endif +%if %{?system_libvpx} +BuildRequires: libvpx-devel +%endif +%if %{?system_webp} +BuildRequires: pkgconfig(libwebp) +BuildRequires: pkgconfig(libwebpdemux) +%endif + Requires: mozilla-filesystem Requires: p11-kit-trust Requires: pciutils-libs +Requires: ffmpeg %if %{?system_nss} Requires: nspr >= %{nspr_version} @@ -260,7 +280,6 @@ Provides: bundled(jpeg-xl) Provides: bundled(kissfft) Provides: bundled(libaom) Provides: bundled(libcubeb) -Provides: bundled(libdav1d) Provides: bundled(libdrm) Provides: bundled(libepoxy) Provides: bundled(libgbm) @@ -278,8 +297,6 @@ Provides: bundled(libsrtp) Provides: bundled(libtheora) Provides: bundled(libtremor) Provides: bundled(libvorbis) -Provides: bundled(libvpx) -Provides: bundled(libwebp) Provides: bundled(libwebrtc) Provides: bundled(libyuv) Provides: bundled(lit) @@ -317,6 +334,13 @@ Provides: bundled(xz-embedded) Provides: bundled(ycbcr) Provides: bundled(zlib) +%if ! %{?system_libvpx} +Provides: bundled(libvpx) +%endif +%if ! %{?system_av1} +Provides: bundled(dav1d) +%endif + %description Mozilla Firefox is an open-source web browser, designed for standards compliance, performance and portability. @@ -376,7 +400,6 @@ rm -vf ./*/layout/inspector/tests/chrome/test_fontVariationsAPI.css %patch -P106 -p1 -b .mozilla-bmo998749 %patch -P107 -p1 -b .mozilla-bmo1716707-swizzle %patch -P108 -p1 -b .mozilla-bmo1716707-svg -%patch -P109 -p1 -b .mozilla-bmo1789216-disable-av1 # ---- Fedora specific patches ---- %patch -P151 -p1 -b .addons @@ -396,6 +419,15 @@ cd media/libvpx/libvpx %patch -P301 -p1 -b .CVE-2023-44488-libvpx cd - +# system AV1 patches +%if %{system_av1} +%patch -P800 -p1 -b .system-av1 +%patch -P801 -p1 -b .system-av1-fixup +%endif + +# RISCV64 patches +%patch -P1001 -p1 -b .D188068 + %{__rm} -f .mozconfig %{__cp} %{SOURCE10} .mozconfig %{__cp} %{SOURCE24} mozilla-api-key @@ -421,7 +453,7 @@ echo "ac_add_options --disable-optimize" >> .mozconfig %ifarch s390x %global optimize_flags "-g -O1" %endif -%ifarch ppc64le aarch64 +%ifarch ppc64le aarch64 riscv64 %global optimize_flags "-g -O2" %endif %if %{optimize_flags} != "none" @@ -433,21 +465,25 @@ echo "ac_add_options --disable-debug" >> .mozconfig %endif # Second arches fail to start with jemalloc enabled -%ifnarch %{ix86} x86_64 +%ifnarch %{ix86} x86_64 riscv64 echo "ac_add_options --disable-jemalloc" >> .mozconfig %endif -%if 0%{?build_tests} -echo "ac_add_options --enable-tests" >> .mozconfig -%else -echo "ac_add_options --disable-tests" >> .mozconfig +%if %{?system_av1} +echo "ac_add_options --with-system-av1" >> .mozconfig %endif - - %if %{?system_libvpx} echo "ac_add_options --with-system-libvpx" >> .mozconfig +%endif +%if %{?system_webp} +echo "ac_add_options --with-system-webp" >> .mozconfig +%endif + + +%if 0%{?build_tests} +echo "ac_add_options --enable-tests" >> .mozconfig %else -echo "ac_add_options --without-system-libvpx" >> .mozconfig +echo "ac_add_options --disable-tests" >> .mozconfig %endif %ifarch s390 s390x @@ -552,21 +588,24 @@ MOZ_OPT_FLAGS="$MOZ_OPT_FLAGS -fPIC -Wl,-z,relro -Wl,-z,now" MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-O2//') %endif -%ifarch %{ix86} +%ifarch %{ix86} riscv64 MOZ_OPT_FLAGS=$(echo "$MOZ_OPT_FLAGS" | %{__sed} -e 's/-g/-g0/') export MOZ_DEBUG_FLAGS=" " %endif -%ifarch s390x aarch64 %{ix86} -MOZ_LINK_FLAGS="-Wl,--no-keep-memory -Wl,--reduce-memory-overheads" -%endif +### NOTE: these sections are not required anymore. Alson --no-keep-memory + -Wl,-z,pack-relative-relocs causes +### ld to go OOM (https://sourceware.org/bugzilla/show_bug.cgi?id=30756) +# Limit RAM usage during link +#%ifarch s390x aarch64 %{ix86} +#MOZ_LINK_FLAGS="-Wl,--no-keep-memory -Wl,--reduce-memory-overheads" +#%endif %if 0%{?flatpak} # Make sure the linker can find libraries in /app/lib64 as we don't use # __global_ldflags that normally sets this. MOZ_LINK_FLAGS="$MOZ_LINK_FLAGS -L%{_libdir}" %endif -%ifarch %{ix86} %{s390x} +%ifarch %{ix86} %{s390x} riscv64 export RUSTFLAGS="-Cdebuginfo=0" echo 'export RUSTFLAGS="-Cdebuginfo=0"' >> .mozconfig %endif @@ -599,6 +638,8 @@ MOZ_SMP_FLAGS=-j1 [ "$RPM_BUILD_NCPUS" -ge 4 ] && MOZ_SMP_FLAGS=-j4 [ "$RPM_BUILD_NCPUS" -ge 8 ] && MOZ_SMP_FLAGS=-j8 [ "$RPM_BUILD_NCPUS" -ge 16 ] && MOZ_SMP_FLAGS=-j16 +[ "$RPM_BUILD_NCPUS" -ge 32 ] && MOZ_SMP_FLAGS=-j32 +[ "$RPM_BUILD_NCPUS" -ge 64 ] && MOZ_SMP_FLAGS=-j64 #%endif echo "mk_add_options MOZ_MAKE_FLAGS=\"$MOZ_SMP_FLAGS\"" >> .mozconfig @@ -904,6 +945,11 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %endif %changelog +* Sat Nov 25 2023 Jingwiw - 115.5.0-2 +- Optimize for riscv64 +- Use system libraries for VP8, VP9, and WebP +- Force ffmpeg as a dependency + * Thu Nov 23 2023 wangkai <13474090681@163.com> - 115.5.0-1 - Update to 115.5.0 diff --git a/mozilla-bmo1789216-disable-av1.patch b/mozilla-bmo1789216-disable-av1.patch deleted file mode 100644 index ce91a124b54f58f2d2cf74682f3355625019e1ba..0000000000000000000000000000000000000000 --- a/mozilla-bmo1789216-disable-av1.patch +++ /dev/null @@ -1,89 +0,0 @@ -diff --git a/media/ffvpx/libavcodec/allcodecs.c b/media/ffvpx/libavcodec/allcodecs.c ---- a/media/ffvpx/libavcodec/allcodecs.c -+++ b/media/ffvpx/libavcodec/allcodecs.c -@@ -755,12 +755,15 @@ - extern FFCodec ff_libaom_av1_encoder; - extern const FFCodec ff_libaribb24_decoder; - extern const FFCodec ff_libcelt_decoder; - extern const FFCodec ff_libcodec2_encoder; - extern const FFCodec ff_libcodec2_decoder; -+#if CONFIG_MOZ_AV1 - extern const FFCodec ff_libdav1d_decoder; - extern const FFCodec ff_libdavs2_decoder; -+extern const FFCodec ff_libuavs3d_decoder; -+#endif - extern const FFCodec ff_libfdk_aac_encoder; - extern const FFCodec ff_libfdk_aac_decoder; - extern const FFCodec ff_libgsm_encoder; - extern const FFCodec ff_libgsm_decoder; - extern const FFCodec ff_libgsm_ms_encoder; -@@ -783,11 +786,10 @@ - extern const FFCodec ff_libspeex_encoder; - extern const FFCodec ff_libspeex_decoder; - extern const FFCodec ff_libsvtav1_encoder; - extern const FFCodec ff_libtheora_encoder; - extern const FFCodec ff_libtwolame_encoder; --extern const FFCodec ff_libuavs3d_decoder; - extern const FFCodec ff_libvo_amrwbenc_encoder; - extern const FFCodec ff_libvorbis_encoder; - extern const FFCodec ff_libvorbis_decoder; - extern const FFCodec ff_libvpx_vp8_encoder; - extern const FFCodec ff_libvpx_vp8_decoder; -diff --git a/media/ffvpx/libavcodec/codec_list.c b/media/ffvpx/libavcodec/codec_list.c ---- a/media/ffvpx/libavcodec/codec_list.c -+++ b/media/ffvpx/libavcodec/codec_list.c -@@ -9,12 +9,14 @@ - &ff_flac_decoder, - #endif - #if CONFIG_MP3_DECODER - &ff_mp3_decoder, - #endif -+#if CONFIG_MOZ_AV1 - #if CONFIG_LIBDAV1D - &ff_libdav1d_decoder, - #endif - #if CONFIG_AV1_DECODER - &ff_av1_decoder, - #endif -+#endif - NULL }; -diff --git a/media/ffvpx/libavcodec/moz.build b/media/ffvpx/libavcodec/moz.build ---- a/media/ffvpx/libavcodec/moz.build -+++ b/media/ffvpx/libavcodec/moz.build -@@ -84,11 +84,10 @@ - 'cbs.c', - 'cbs_av1.c', - 'golomb.c', - 'h264pred.c', - 'imgconvert.c', -- 'libdav1d.c', - 'mathtables.c', - 'qsv_api.c', - 'raw.c', - 'videodsp.c', - 'vp8.c', -@@ -107,14 +106,19 @@ - 'vp9mvs.c', - 'vp9prob.c', - 'vp9recon.c', - 'vpx_rac.c', - ] -- USE_LIBS += [ -- 'dav1d', -- 'media_libdav1d_asm', -- ] -+ if CONFIG['MOZ_AV1']: -+ USE_LIBS += [ -+ 'dav1d', -+ 'media_libdav1d_asm', -+ ] -+ SOURCES += [ -+ 'libdav1d.c', -+ ] -+ - if CONFIG['MOZ_WAYLAND']: - LOCAL_INCLUDES += ['/media/mozva'] - SOURCES += [ - 'vaapi_av1.c', - 'vaapi_decode.c', -