Bug 1022425 - Force mozgtk stubs dependency on gtk libraries when -Wl,--as-needed is used. r=mshal, a=NPOTB
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 10 Jun 2014 16:00:55 +0900
changeset 206864 730801cf5af434351ab15f0873d1adc5fb2775d2
parent 206863 9a8d4ed2b88fd4151bf16e071c19ca38a66f067f
child 206865 119f0fbdf0b47e1cfa1e22406ea0bd3cb63eca6a
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal, NPOTB
bugs1022425
milestone32.0a2
Bug 1022425 - Force mozgtk stubs dependency on gtk libraries when -Wl,--as-needed is used. r=mshal, a=NPOTB
widget/gtk/mozgtk/gtk2/Makefile.in
widget/gtk/mozgtk/gtk3/Makefile.in
--- a/widget/gtk/mozgtk/gtk2/Makefile.in
+++ b/widget/gtk/mozgtk/gtk2/Makefile.in
@@ -1,9 +1,19 @@
 # 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/.
 
-EXTRA_DSO_LDOPTS += -lgtk-x11-2.0 -lgdk-x11-2.0
-
 include $(topsrcdir)/config/rules.mk
 
 LDFLAGS += -Wl,-soname=$(DLL_PREFIX)mozgtk$(DLL_SUFFIX)
+
+# If LDFLAGS contains -Wl,--as-needed, 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.
+ifeq (,$(filter -Wl,--as-needed),$(LDFLAGS))
+no_as_needed = $1
+else
+no_as_needed = -Wl,--no-as-needed $1 -Wl,--as-needed
+endif
+
+EXTRA_DSO_LDOPTS += $(call no_as_needed,-lgtk-x11-2.0 -lgdk-x11-2.0)
--- a/widget/gtk/mozgtk/gtk3/Makefile.in
+++ b/widget/gtk/mozgtk/gtk3/Makefile.in
@@ -1,7 +1,17 @@
 # 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/.
 
-EXTRA_DSO_LDOPTS += -lgtk-3 -lgdk-3
+include $(topsrcdir)/config/rules.mk
 
-include $(topsrcdir)/config/rules.mk
+# If LDFLAGS contains -Wl,--as-needed, 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.
+ifeq (,$(filter -Wl,--as-needed),$(LDFLAGS))
+no_as_needed = $1
+else
+no_as_needed = -Wl,--no-as-needed $1 -Wl,--as-needed
+endif
+
+EXTRA_DSO_LDOPTS += $(call no_as_needed,-lgtk-3 -lgdk-3)