diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index b2ac2fac9ff5..8db2de682b34 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -104,6 +104,7 @@ #endif #endif #ifdef MOZ_GTK +@BINPATH@/@DLL_PREFIX@mozgtk@DLL_SUFFIX@ #ifdef MOZ_WAYLAND @BINPATH@/@DLL_PREFIX@mozwayland@DLL_SUFFIX@ #endif diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index b4e7042d94c0..e684c9782e52 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -157,6 +157,21 @@ USE_LIBS += [ ] if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": + # The mozgtk library is a workaround that makes Gtk+ use libwayland-client + # instead of mozwayland. The reason it works is that by being a dependency + # of libxul, mozgtk appears in dependentlibs.list, preceding mozwayland + # (which is important and guaranteed by the USE_LIBS order in this file). + # That, in turn, makes firefox dlopen() mozgtk before mozwayland, which + # will trigger the loading of the Gtk+ libraries (mozgtk depending on them). + # Those libraries, if they depend on libwayland-client, will use the symbols + # from libwayland-client because mozwayland is not loaded yet. + # When eventually libxul is loaded after both mozgtk and mozwayland, it will + # get symbols from libwayland-client too. + # In the case where Gtk+ doesn't have wayland support, libwayland-client is + # not loaded, and libxul ends up using the mozwayland symbols. + USE_LIBS += [ + "mozgtk", + ] OS_LIBS += CONFIG["MOZ_GTK3_LIBS"] if CONFIG["MOZ_WAYLAND"]: diff --git a/widget/gtk/moz.build b/widget/gtk/moz.build index 8a40e2319b8b..378b8b5ce8d2 100644 --- a/widget/gtk/moz.build +++ b/widget/gtk/moz.build @@ -19,6 +19,9 @@ with Files("*IMContextWrapper*"): with Files("*nsGtkKeyUtils*"): BUG_COMPONENT = ("Core", "DOM: UI Events & Focus Handling") +if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": + DIRS += ["mozgtk"] + if CONFIG["MOZ_WAYLAND"]: DIRS += ["wayland", "mozwayland"] diff --git a/widget/gtk/mozgtk/moz.build b/widget/gtk/mozgtk/moz.build new file mode 100644 index 000000000000..f5ad4660d466 --- /dev/null +++ b/widget/gtk/mozgtk/moz.build @@ -0,0 +1,30 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +SharedLibrary("mozgtk") + +# If LDFLAGS contains -Wl,--as-needed or if it's the default for the toolchain, +# we need to add -Wl,--no-as-needed before the gtk libraries, otherwise the +# linker will drop those dependencies because no symbols are used from them. +# But those dependencies need to be kept for things to work properly. +# Ideally, we'd only add -Wl,--no-as-needed if necessary, but it's just simpler +# to add it unconditionally. This library is also simple enough that forcing +# -Wl,--as-needed after the gtk libraries is not going to make a significant +# difference. +if CONFIG["GCC_USE_GNU_LD"]: + no_as_needed = ["-Wl,--no-as-needed"] + as_needed = ["-Wl,--as-needed"] +else: + no_as_needed = [] + as_needed = [] + +OS_LIBS += [f for f in CONFIG["MOZ_GTK3_LIBS"] if f.startswith("-L")] +OS_LIBS += no_as_needed +OS_LIBS += [ + "gtk-3", + "gdk-3", +] +OS_LIBS += as_needed