From 94e96f7f68c3b9053fdb5dee5b0ab614163aaa08 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Mon, 24 Sep 2018 00:10:37 -0400 Subject: gnu: icecat: Unbundle libevent, libogg, and libvorbis. * gnu/packages/patches/icecat-use-system-media-libs.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/patches/icecat-avoid-bundled-libraries.patch: Add another hunk to enable removal of libevent. * gnu/packages/gnuzilla.scm (icecat)[source]: Add patch. In the snippet, add libevent, libogg, libvorbis, and libtremor to the list of bundled libraries to remove. Add a comment regarding theora. Remove comments regarding unbundling cairo, which is no longer supported. [inputs]: Add libevent, libogg, and libvorbis. [arguments]: Add --with-system-{libevent,ogg,vorbis} to configure flags. Add custom bootstrap phase. Add comments. --- gnu/local.mk | 1 + gnu/packages/gnuzilla.scm | 39 ++- .../patches/icecat-avoid-bundled-libraries.patch | 14 + .../patches/icecat-use-system-media-libs.patch | 381 +++++++++++++++++++++ 4 files changed, 423 insertions(+), 12 deletions(-) create mode 100644 gnu/packages/patches/icecat-use-system-media-libs.patch diff --git a/gnu/local.mk b/gnu/local.mk index 35e78e7816..244c79d221 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -812,6 +812,7 @@ dist_patch_DATA = \ %D%/packages/patches/icecat-avoid-bundled-libraries.patch \ %D%/packages/patches/icecat-CVE-2018-12383.patch \ %D%/packages/patches/icecat-use-system-graphite2+harfbuzz.patch \ + %D%/packages/patches/icecat-use-system-media-libs.patch \ %D%/packages/patches/icedtea-6-hotspot-gcc-segfault-workaround.patch \ %D%/packages/patches/icedtea-7-hotspot-gcc-segfault-workaround.patch \ %D%/packages/patches/id3lib-CVE-2007-4460.patch \ diff --git a/gnu/packages/gnuzilla.scm b/gnu/packages/gnuzilla.scm index ad83444e3c..6834d82426 100644 --- a/gnu/packages/gnuzilla.scm +++ b/gnu/packages/gnuzilla.scm @@ -36,6 +36,7 @@ #:use-module (guix utils) #:use-module (guix build-system gnu) #:use-module (guix build-system cargo) + #:use-module (gnu packages audio) #:use-module (gnu packages autotools) #:use-module (gnu packages base) #:use-module (gnu packages databases) @@ -62,6 +63,7 @@ #:use-module (gnu packages rust) #:use-module (gnu packages icu4c) #:use-module (gnu packages video) + #:use-module (gnu packages xiph) #:use-module (gnu packages xdisorg) #:use-module (gnu packages readline)) @@ -497,6 +499,7 @@ security standards.") (list (search-patch "icecat-avoid-bundled-libraries.patch") (search-patch "icecat-use-system-graphite2+harfbuzz.patch") + (search-patch "icecat-use-system-media-libs.patch") (mozilla-patch "icecat-CVE-2018-12385.patch" "80a4a7ef2813" "1vgcbimpnfjqj934v0cryq1g13xac3wfmd4jyhcb5s60x8xyssf5") (search-patch "icecat-CVE-2018-12383.patch") (mozilla-patch "icecat-bug-1489744.patch" "6546ee839d30" "11mhvj77r789b428bfxqq5wdx8yr7lbrdjzr8qjj6fw197pldn51"))) @@ -516,24 +519,29 @@ security standards.") ;; FIXME: A script from the bundled nspr is used. ;;"nsprpub" ;; - ;; TODO: Use system media libraries. Waiting for: + ;; TODO: Use more system media libraries. See: ;; - ;; * libogg - ;; * libtheora - ;; * libvorbis - ;; * libtremor (not yet in guix) + ;; * libtheora: esr60 wants v1.2, not yet released. + ;; * soundtouch: avoiding the bundled library would + ;; result in some loss of functionality. There's + ;; also an issue with exception handling + ;; configuration. It seems that this is needed in + ;; some moz.build: + ;; DEFINES['ST_NO_EXCEPTION_HANDLING'] = 1 ;; * libopus ;; * speex - ;; * soundtouch (not yet in guix) ;; "modules/freetype2" "modules/zlib" "modules/libbz2" - ;; UNBUNDLE-ME "ipc/chromium/src/third_party/libevent" + "ipc/chromium/src/third_party/libevent" "media/libjpeg" "media/libvpx" + "media/libogg" + "media/libvorbis" + ;; "media/libtheora" ; wants theora-1.2, not yet released + "media/libtremor" "security/nss" - ;; UNBUNDLE-ME "gfx/cairo" "gfx/harfbuzz" "gfx/graphite2" "js/src/ctypes/libffi" @@ -549,7 +557,6 @@ security standards.") (inputs `(("alsa-lib" ,alsa-lib) ("bzip2" ,bzip2) - ;; UNBUNDLE-ME ("cairo" ,cairo) ("cups" ,cups) ("dbus-glib" ,dbus-glib) ("gdk-pixbuf" ,gdk-pixbuf) @@ -564,8 +571,11 @@ security standards.") ("libcanberra" ,libcanberra) ("libgnome" ,libgnome) ("libjpeg-turbo" ,libjpeg-turbo) + ("libogg" ,libogg) + ;; ("libtheora" ,libtheora) ; wants theora-1.2, not yet released + ("libvorbis" ,libvorbis) ("libxft" ,libxft) - ;; UNBUNDLE-ME ("libevent" ,libevent-2.0) + ("libevent" ,libevent) ("libxinerama" ,libxinerama) ("libxscrnsaver" ,libxscrnsaver) ("libxcomposite" ,libxcomposite) @@ -637,7 +647,10 @@ security standards.") "--with-system-zlib" "--with-system-bz2" "--with-system-jpeg" ; must be libjpeg-turbo - ;; UNBUNDLE-ME "--with-system-libevent" + "--with-system-libevent" + "--with-system-ogg" + "--with-system-vorbis" + ;; "--with-system-theora" ; wants theora-1.2, not yet released "--with-system-libvpx" "--with-system-icu" "--with-system-nspr" @@ -645,7 +658,6 @@ security standards.") "--with-system-harfbuzz" "--with-system-graphite2" "--enable-system-pixman" - ;; UNBUNDLE-ME "--enable-system-cairo" "--enable-system-ffi" "--enable-system-hunspell" "--enable-system-sqlite" @@ -695,6 +707,9 @@ security standards.") 'avcodec', 'avutil', 'pulse' ]\n\n" all))) #t)) + (replace 'bootstrap + (lambda _ + (invoke "sh" "-c" "autoconf old-configure.in > old-configure"))) (add-after 'patch-source-shebangs 'patch-cargo-checksums (lambda _ (use-modules (guix build cargo-build-system)) diff --git a/gnu/packages/patches/icecat-avoid-bundled-libraries.patch b/gnu/packages/patches/icecat-avoid-bundled-libraries.patch index b5e9fb887e..33203b1a33 100644 --- a/gnu/packages/patches/icecat-avoid-bundled-libraries.patch +++ b/gnu/packages/patches/icecat-avoid-bundled-libraries.patch @@ -33,3 +33,17 @@ Fixes needed when avoiding bundled libraries. '/dom/base', '/dom/storage', '/ipc/glue', +--- icecat-60.2.0/media/webrtc/trunk/webrtc/base/rtc_task_queue_gn/moz.build.orig 2018-09-13 17:40:54.000000000 -0400 ++++ icecat-60.2.0/media/webrtc/trunk/webrtc/base/rtc_task_queue_gn/moz.build 2018-09-23 21:33:12.319975105 -0400 +@@ -130,11 +130,6 @@ + DEFINES["WEBRTC_POSIX"] = True + DEFINES["_FILE_OFFSET_BITS"] = "64" + +- LOCAL_INCLUDES += [ +- "/ipc/chromium/src/third_party/libevent/include/", +- "/ipc/chromium/src/third_party/libevent/linux/" +- ] +- + UNIFIED_SOURCES += [ + "/media/webrtc/trunk/webrtc/base/task_queue_libevent.cc", + "/media/webrtc/trunk/webrtc/base/task_queue_posix.cc" diff --git a/gnu/packages/patches/icecat-use-system-media-libs.patch b/gnu/packages/patches/icecat-use-system-media-libs.patch new file mode 100644 index 0000000000..648585a6f0 --- /dev/null +++ b/gnu/packages/patches/icecat-use-system-media-libs.patch @@ -0,0 +1,381 @@ +Support building with system media libraries. +See + +Based on: + https://svnweb.freebsd.org/ports/head/www/firefox-esr/files/patch-z-bug517422?revision=472833&view=markup + +Changes to files within the bundled libraries are omitted, since those files +are removed from Guix sources. Modified for use with patch -p1, and to apply +cleanly to GNU IceCat. + +--- icecat-60.2.0/build/moz.configure/old.configure ++++ icecat-60.2.0/build/moz.configure/old.configure +@@ -273,7 +273,12 @@ + '--with-system-libvpx', + '--with-system-nspr', + '--with-system-nss', ++ '--with-system-ogg', + '--with-system-png', ++ '--with-system-soundtouch', ++ '--with-system-theora', ++ '--with-system-tremor', ++ '--with-system-vorbis', + '--with-system-zlib', + '--with-thumb', + '--with-thumb-interwork', +--- icecat-60.2.0/config/external/moz.build ++++ icecat-60.2.0/config/external/moz.build +@@ -23,12 +23,21 @@ + + external_dirs += ['modules/xz-embedded'] + +-if CONFIG['MOZ_VORBIS']: ++if not CONFIG['MOZ_SYSTEM_OGG']: ++ external_dirs += ['media/libogg'] ++ ++if CONFIG['MOZ_VORBIS'] and not CONFIG['MOZ_SYSTEM_VORBIS']: + external_dirs += ['media/libvorbis'] + +-if CONFIG['MOZ_TREMOR']: ++if CONFIG['MOZ_TREMOR'] and not CONFIG['MOZ_SYSTEM_TREMOR']: + external_dirs += ['media/libtremor'] + ++if not CONFIG['MOZ_SYSTEM_THEORA']: ++ external_dirs += ['media/libtheora'] ++ ++if not CONFIG['MOZ_SYSTEM_SOUNDTOUCH']: ++ external_dirs += ['media/libsoundtouch'] ++ + if CONFIG['MOZ_WEBM_ENCODER']: + external_dirs += ['media/libmkv'] + +@@ -51,11 +60,8 @@ + 'media/kiss_fft', + 'media/libcubeb', + 'media/libnestegg', +- 'media/libogg', + 'media/libopus', +- 'media/libtheora', + 'media/libspeex_resampler', +- 'media/libsoundtouch', + 'media/mp4parse-rust', + 'media/psshparser' + ] +--- icecat-60.2.0/config/system-headers.mozbuild ++++ icecat-60.2.0/config/system-headers.mozbuild +@@ -1324,6 +1324,28 @@ + 'harfbuzz/hb.h', + ] + ++if CONFIG['MOZ_SYSTEM_OGG']: ++ system_headers += [ ++ 'ogg/ogg.h', ++ 'ogg/os_types.h', ++ ] ++ ++if CONFIG['MOZ_SYSTEM_THEORA']: ++ system_headers += [ ++ 'theora/theoradec.h', ++ ] ++ ++if CONFIG['MOZ_SYSTEM_VORBIS']: ++ system_headers += [ ++ 'vorbis/codec.h', ++ 'vorbis/vorbisenc.h', ++ ] ++ ++if CONFIG['MOZ_SYSTEM_TREMOR']: ++ system_headers += [ ++ 'tremor/ivorbiscodec.h', ++ ] ++ + if CONFIG['MOZ_SYSTEM_LIBVPX']: + system_headers += [ + 'vpx_mem/vpx_mem.h', +--- icecat-60.2.0/dom/media/AudioStream.cpp ++++ icecat-60.2.0/dom/media/AudioStream.cpp +@@ -121,7 +121,9 @@ + : mMonitor("AudioStream") + , mChannels(0) + , mOutChannels(0) ++#ifndef MOZ_SYSTEM_SOUNDTOUCH + , mTimeStretcher(nullptr) ++#endif + , mDumpFile(nullptr) + , mState(INITIALIZED) + , mDataSource(aSource) +@@ -142,9 +144,11 @@ + if (mDumpFile) { + fclose(mDumpFile); + } ++#ifndef MOZ_SYSTEM_SOUNDTOUCH + if (mTimeStretcher) { + soundtouch::destroySoundTouchObj(mTimeStretcher); + } ++#endif + #if defined(XP_WIN) + if (XRE_IsContentProcess()) { + audio::AudioNotificationReceiver::Unregister(this); +@@ -168,7 +172,11 @@ + { + mMonitor.AssertCurrentThreadOwns(); + if (!mTimeStretcher) { ++#ifdef MOZ_SYSTEM_SOUNDTOUCH ++ mTimeStretcher = new soundtouch::SoundTouch(); ++#else + mTimeStretcher = soundtouch::createSoundTouchObj(); ++#endif + mTimeStretcher->setSampleRate(mAudioClock.GetInputRate()); + mTimeStretcher->setChannels(mOutChannels); + mTimeStretcher->setPitch(1.0); +--- icecat-60.2.0/dom/media/AudioStream.h ++++ icecat-60.2.0/dom/media/AudioStream.h +@@ -15,7 +15,11 @@ + #include "mozilla/TimeStamp.h" + #include "mozilla/UniquePtr.h" + #include "CubebUtils.h" ++#ifdef MOZ_SYSTEM_SOUNDTOUCH ++#include "soundtouch/SoundTouch.h" ++#else + #include "soundtouch/SoundTouchFactory.h" ++#endif + + #if defined(XP_WIN) + #include "mozilla/audio/AudioNotificationReceiver.h" +@@ -297,7 +301,11 @@ + uint32_t mChannels; + uint32_t mOutChannels; + AudioClock mAudioClock; ++#ifdef MOZ_SYSTEM_SOUNDTOUCH ++ nsAutoPtr mTimeStretcher; ++#else + soundtouch::SoundTouch* mTimeStretcher; ++#endif + + // Output file for dumping audio + FILE* mDumpFile; +--- icecat-60.2.0/dom/media/moz.build ++++ icecat-60.2.0/dom/media/moz.build +@@ -327,6 +327,21 @@ + + DEFINES['MOZILLA_INTERNAL_API'] = True + ++if CONFIG['MOZ_SYSTEM_OGG']: ++ CXXFLAGS += CONFIG['MOZ_OGG_CFLAGS'] ++ ++if CONFIG['MOZ_SYSTEM_THEORA']: ++ CXXFLAGS += CONFIG['MOZ_THEORA_CFLAGS'] ++ ++if CONFIG['MOZ_SYSTEM_VORBIS']: ++ CXXFLAGS += CONFIG['MOZ_VORBIS_CFLAGS'] ++ ++if CONFIG['MOZ_SYSTEM_TREMOR']: ++ CXXFLAGS += CONFIG['MOZ_TREMOR_CFLAGS'] ++ ++if CONFIG['MOZ_SYSTEM_SOUNDTOUCH']: ++ CXXFLAGS += CONFIG['MOZ_SOUNDTOUCH_CFLAGS'] ++ + if CONFIG['MOZ_ANDROID_HLS_SUPPORT']: + DEFINES['MOZ_ANDROID_HLS_SUPPORT'] = True + +--- icecat-60.2.0/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp ++++ icecat-60.2.0/dom/media/platforms/ffmpeg/ffvpx/FFVPXRuntimeLinker.cpp +@@ -15,9 +15,13 @@ + #include + #endif + ++#ifdef MOZ_SYSTEM_SOUNDTOUCH ++#include "nsXPCOMPrivate.h" // for XUL_DLL ++#else + // We use a known symbol located in lgpllibs to determine its location. + // soundtouch happens to be always included in lgpllibs + #include "soundtouch/SoundTouch.h" ++#endif + + namespace mozilla { + +@@ -64,6 +68,12 @@ + + sLinkStatus = LinkStatus_FAILED; + ++#ifdef MOZ_SYSTEM_SOUNDTOUCH ++ // We retrieve the path of the XUL library as this is where mozavcodec and ++ // mozavutil libs are located. ++ char* path = ++ PR_GetLibraryFilePathname(XUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Init); ++#else + // We retrieve the path of the lgpllibs library as this is where mozavcodec + // and mozavutil libs are located. + PathString lgpllibsname = GetLibraryName(nullptr, "lgpllibs"); +@@ -73,6 +83,7 @@ + PathString path = + GetLibraryFilePathname(lgpllibsname.get(), + (PRFuncPtr)&soundtouch::SoundTouch::getVersionId); ++#endif + if (path.IsEmpty()) { + return false; + } +--- icecat-60.2.0/old-configure.in ++++ icecat-60.2.0/old-configure.in +@@ -2451,6 +2451,111 @@ + fi + fi # COMPILE_ENVIRONMENT + ++dnl ======================================================== ++dnl Check for libogg ++dnl ======================================================== ++ ++MOZ_ARG_WITH_BOOL(system-ogg, ++[ --with-system-ogg Use system libogg (located with pkgconfig)], ++MOZ_SYSTEM_OGG=1, ++MOZ_SYSTEM_OGG=) ++ ++if test -n "$MOZ_SYSTEM_OGG"; then ++ PKG_CHECK_MODULES(MOZ_OGG, ogg >= 1.3.3) ++ ++ _SAVE_LIBS=$LIBS ++ LIBS="$LIBS $MOZ_OGG_LIBS" ++ AC_CHECK_FUNC(ogg_set_mem_functions, [], ++ [AC_DEFINE(MOZ_OGG_NO_MEM_REPORTING)]) ++ LIBS=$_SAVE_LIBS ++fi ++ ++AC_SUBST(MOZ_SYSTEM_OGG) ++ ++dnl ======================================================== ++dnl Check for libvorbis ++dnl ======================================================== ++ ++MOZ_ARG_WITH_BOOL(system-vorbis, ++[ --with-system-vorbis Use system libvorbis (located with pkgconfig)], ++MOZ_SYSTEM_VORBIS=1, ++MOZ_SYSTEM_VORBIS=) ++ ++if test -n "$MOZ_SYSTEM_VORBIS"; then ++ PKG_CHECK_MODULES(MOZ_VORBIS, vorbis vorbisenc >= 1.3.6) ++fi ++ ++AC_SUBST(MOZ_SYSTEM_VORBIS) ++ ++dnl ======================================================== ++dnl Check for integer-only libvorbis aka tremor ++dnl ======================================================== ++ ++MOZ_ARG_WITH_BOOL(system-tremor, ++[ --with-system-tremor Use system libtremor (located with pkgconfig)], ++MOZ_SYSTEM_TREMOR=1, ++MOZ_SYSTEM_TREMOR=) ++ ++if test -n "$MOZ_SYSTEM_TREMOR"; then ++ PKG_CHECK_MODULES(MOZ_TREMOR, vorbisidec >= 1.2.1) ++fi ++ ++AC_SUBST(MOZ_SYSTEM_TREMOR) ++ ++dnl ======================================================== ++dnl Check for libtheora ++dnl ======================================================== ++ ++MOZ_ARG_WITH_BOOL(system-theora, ++[ --with-system-theora Use system libtheora (located with pkgconfig)], ++MOZ_SYSTEM_THEORA=1, ++MOZ_SYSTEM_THEORA=) ++ ++if test -n "$MOZ_SYSTEM_THEORA"; then ++ PKG_CHECK_MODULES(MOZ_THEORA, theora >= 1.2) ++fi ++ ++AC_SUBST(MOZ_SYSTEM_THEORA) ++ ++dnl ======================================================== ++dnl Check for libSoundTouch ++dnl ======================================================== ++ ++MOZ_ARG_WITH_BOOL(system-soundtouch, ++[ --with-system-soundtouch Use system libSoundTouch (located with pkgconfig)], ++MOZ_SYSTEM_SOUNDTOUCH=1, ++MOZ_SYSTEM_SOUNDTOUCH=) ++ ++if test -n "$MOZ_SYSTEM_SOUNDTOUCH"; then ++ PKG_CHECK_MODULES(MOZ_SOUNDTOUCH, soundtouch >= 1.9.0) ++ ++ AC_LANG_SAVE ++ AC_LANG_CPLUSPLUS ++ _SAVE_CXXFLAGS=$CXXFLAGS ++ CXXFLAGS="$CXXFLAGS $MOZ_SOUNDTOUCH_CFLAGS" ++ AC_CACHE_CHECK(for soundtouch sample type, ++ ac_cv_soundtouch_sample_type, ++ [AC_TRY_COMPILE([#include ++ #ifndef SOUNDTOUCH_INTEGER_SAMPLES ++ #error soundtouch expects float samples ++ #endif], ++ [], ++ [ac_cv_soundtouch_sample_type=short], ++ [ac_cv_soundtouch_sample_type=float])]) ++ CXXFLAGS=$_SAVE_CXXFLAGS ++ AC_LANG_RESTORE ++ ++ if test \( -n "$MOZ_SAMPLE_TYPE_S16" -a "$ac_cv_soundtouch_sample_type" != short \) \ ++ -o \( -n "$MOZ_SAMPLE_TYPE_FLOAT32" -a "$ac_cv_soundtouch_sample_type" != float \) ; then ++ AC_MSG_ERROR([SoundTouch library is built with incompatible sample type. Either rebuild the library with/without --enable-integer-samples, chase default Mozilla sample type or remove --with-system-soundtouch.]) ++ fi ++fi ++ ++if test -n "$MOZ_SYSTEM_SOUNDTOUCH"; then ++ AC_DEFINE(MOZ_SYSTEM_SOUNDTOUCH) ++fi ++AC_SUBST(MOZ_SYSTEM_SOUNDTOUCH) ++ + dnl system libvpx Support + dnl ======================================================== + MOZ_ARG_WITH_BOOL(system-libvpx, +--- icecat-60.2.0/toolkit/library/moz.build ++++ icecat-60.2.0/toolkit/library/moz.build +@@ -244,6 +244,21 @@ + if CONFIG['MOZ_SYSTEM_HUNSPELL']: + OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS'] + ++if CONFIG['MOZ_SYSTEM_OGG']: ++ OS_LIBS += CONFIG['MOZ_OGG_LIBS'] ++ ++if CONFIG['MOZ_SYSTEM_THEORA']: ++ OS_LIBS += CONFIG['MOZ_THEORA_LIBS'] ++ ++if CONFIG['MOZ_SYSTEM_VORBIS']: ++ OS_LIBS += CONFIG['MOZ_VORBIS_LIBS'] ++ ++if CONFIG['MOZ_SYSTEM_TREMOR']: ++ OS_LIBS += CONFIG['MOZ_TREMOR_LIBS'] ++ ++if CONFIG['MOZ_SYSTEM_SOUNDTOUCH']: ++ OS_LIBS += CONFIG['MOZ_SOUNDTOUCH_LIBS'] ++ + if CONFIG['MOZ_SYSTEM_LIBEVENT']: + OS_LIBS += CONFIG['MOZ_LIBEVENT_LIBS'] + +--- icecat-60.2.0/xpcom/build/XPCOMInit.cpp ++++ icecat-60.2.0/xpcom/build/XPCOMInit.cpp +@@ -138,7 +138,9 @@ + + #include "mozilla/ipc/GeckoChildProcessHost.h" + ++#ifndef MOZ_OGG_NO_MEM_REPORTING + #include "ogg/ogg.h" ++#endif + #if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING) + #if defined(HAVE_STDINT_H) + // mozilla-config.h defines HAVE_STDINT_H, and then it's defined *again* in +@@ -639,11 +641,13 @@ + // this oddness. + mozilla::SetICUMemoryFunctions(); + ++#ifndef MOZ_OGG_NO_MEM_REPORTING + // Do the same for libogg. + ogg_set_mem_functions(OggReporter::CountingMalloc, + OggReporter::CountingCalloc, + OggReporter::CountingRealloc, + OggReporter::CountingFree); ++#endif + + #if defined(MOZ_VPX) && !defined(MOZ_VPX_NO_MEM_REPORTING) + // And for VPX. -- cgit v1.2.3