Bug#640163: yate: FTBFS with ld that defaults to --as-needed: bad linkage order

Colin Watson cjwatson at ubuntu.com
Fri Sep 2 23:29:00 UTC 2011


Package: yate
Version: 2.2.0-1~dfsg-1.1
Severity: important
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch oneiric

yate fails to build with a linker that defaults to --as-needed, as shown
in this Ubuntu bug report:

  https://bugs.launchpad.net/ubuntu/+source/yate/+bug/832890

This is because of various faults in its link ordering, mostly putting
libraries before the objects that use them rather than after.  See:

  http://wiki.debian.org/ToolChain/DSOLinking#Only_link_with_needed_libraries

The following patch fixes this.

  * Adjust various bits of linkage for 'ld --as-needed'.

diff -Nru yate-2.2.0-1~dfsg/debian/patches/as-needed yate-2.2.0-1~dfsg/debian/patches/as-needed
--- yate-2.2.0-1~dfsg/debian/patches/as-needed	1970-01-01 01:00:00.000000000 +0100
+++ yate-2.2.0-1~dfsg/debian/patches/as-needed	2011-09-03 00:26:27.000000000 +0100
@@ -0,0 +1,96 @@
+Description: Adjust various bits of linkage for 'ld --as-needed'
+Author: Colin Watson <cjwatson at ubuntu.com>
+Bug-Ubuntu: https://bugs.launchpad.net/bugs/832890
+Forwarded: no
+Last-Update: 2011-09-02
+
+Index: b/Makefile.in
+===================================================================
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -315,8 +315,8 @@
+ Makefile: @srcdir@/Makefile.in $(MKDEPS)
+ 	./config.status
+ 
+-yate: libyate.so $(OBJS) $(LIBS)
+-	$(LINK) -o $@ $(LIBTHR) $^ @LIBS@
++yate: $(OBJS) libyate.so $(LIBS)
++	$(LINK) -o $@ $^ $(LIBTHR) @LIBS@
+ 
+ libyate.so: $(YLIB)
+ 	ln -sf $^ $@
+Index: b/modules/Makefile.in
+===================================================================
+--- a/modules/Makefile.in
++++ b/modules/Makefile.in
+@@ -12,10 +12,11 @@
+ MOC := @QT4_MOC@
+ SED := sed
+ DEFS :=
++LIBTHR:= @THREAD_LIB@
+ INCLUDES := -I.. -I at top_srcdir@
+ CFLAGS := @CFLAGS@ @MODULE_CFLAGS@ @INLINE_FLAGS@
+ CPPFLAGS := @CFLAGS@ @MODULE_CPPFLAGS@ @INLINE_FLAGS@
+-LDFLAGS:= @LDFLAGS@ -L.. -lyate
++LDFLAGS:= @LDFLAGS@ -L..
+ MODFLAGS:= @MODULE_LDFLAGS@
+ MODRELAX:= @MODULE_LDRELAX@
+ MODSTRIP:= @MODULE_SYMBOLS@
+@@ -123,6 +124,7 @@
+ 
+ LOCALFLAGS =
+ LOCALLIBS =
++YATELIBS = -lyate
+ CCOMPILE = $(CC) $(DEFS) $(DEBUG) $(INCLUDES) $(CFLAGS)
+ COMPILE = $(CXX) $(DEFS) $(DEBUG) $(INCLUDES) $(CPPFLAGS)
+ LINK = $(CXX) $(LDFLAGS)
+@@ -197,22 +199,22 @@
+ 	cd .. && ./config.status
+ 
+ lib%.so: %.o
+-	$(LINK) -shared -o $@ $^ @LIBS@
++	$(LINK) -shared -o $@ $^ $(YATELIBS) @LIBS@
+ 
+ server/%.yate: @srcdir@/server/%.cpp $(MKDEPS) $(INCFILES)
+-	$(MODCOMP) -o $@ $(LOCALFLAGS) $< $(LOCALLIBS) @LIBS@
++	$(MODCOMP) -o $@ $(LOCALFLAGS) $< $(YATELIBS) $(LOCALLIBS) @LIBS@
+ 
+ client/%.yate: @srcdir@/client/%.cpp $(MKDEPS) $(INCFILES)
+-	$(MODCOMP) -o $@ $(LOCALFLAGS) $< $(LOCALLIBS) @LIBS@
++	$(MODCOMP) -o $@ $(LOCALFLAGS) $< $(YATELIBS) $(LOCALLIBS) @LIBS@
+ 
+ qt4/%.yate: @srcdir@/qt4/%.cpp $(MKDEPS) $(INCFILES)
+-	$(MODCOMP) -o $@ $(LOCALFLAGS) @QT4_INC@ -I at top_srcdir@/clients/qt4 $< $(LOCALLIBS) @QT4_LIB@ @LIBS@
++	$(MODCOMP) -o $@ $(LOCALFLAGS) @QT4_INC@ -I at top_srcdir@/clients/qt4 $< $(YATELIBS) $(LOCALLIBS) @QT4_LIB@ @LIBS@
+ 
+ qt4/%.moc: @srcdir@/qt4/%.h $(MKDEPS) $(INCFILES)
+ 	mkdir -p qt4 && $(MOC) $(DEFS) $(INCLUDES) @QT4_INC@ -I at top_srcdir@/clients/qt4 -I at srcdir@/qt4 -o $@ $<
+ 
+ %.yate: @srcdir@/%.cpp $(MKDEPS) $(INCFILES)
+-	$(MODCOMP) -o $@ $(LOCALFLAGS) $< $(LOCALLIBS) @LIBS@
++	$(MODCOMP) -o $@ $(LOCALFLAGS) $< $(YATELIBS) $(LOCALLIBS) @LIBS@
+ 
+ # Take special care of the modules that depend on optional libs
+ 
+@@ -227,7 +229,7 @@
+ server/analogdetect.yate: LOCALLIBS = -L../libs/ymodem -lyatemodem
+ 
+ h323chan.yate: LOCALFLAGS = -DPHAS_TEMPLATES -D_REENTRANT -DP_HAS_SEMAPHORES @H323_INC@
+-h323chan.yate: LOCALLIBS = @H323_LIB@
++h323chan.yate: LOCALLIBS = @H323_LIB@ $(LIBTHR)
+ 
+ server/pgsqldb.yate: LOCALFLAGS = @PGSQL_INC@
+ server/pgsqldb.yate: LOCALLIBS = -lpq
+Index: b/libs/ysig/Makefile.in
+===================================================================
+--- a/libs/ysig/Makefile.in
++++ b/libs/ysig/Makefile.in
+@@ -70,7 +70,7 @@
+ 	cd ../.. && ln -sf $(LIBD_VER) $(LIBD_DEV)
+ 
+ yate-%: @srcdir@/main-%.cpp $(MKDEPS) $(LIBS) ../../libyate.so $(INCFILES)
+-	$(COMPILE) -o $@ $(LOCALFLAGS) $< $(LIBTHR) $(LDFLAGS) $(LOCALLIBS) @LIBS@
++	$(COMPILE) -o $@ $(LOCALFLAGS) $< $(LDFLAGS) $(LOCALLIBS) $(LIBTHR) @LIBS@
+ 
+ $(LIBS): $(OBJS)
+ 	$(AR) rcs $@ $^
diff -Nru yate-2.2.0-1~dfsg/debian/patches/series yate-2.2.0-1~dfsg/debian/patches/series
--- yate-2.2.0-1~dfsg/debian/patches/series	2010-03-21 09:16:31.000000000 +0000
+++ yate-2.2.0-1~dfsg/debian/patches/series	2011-09-02 20:07:33.000000000 +0100
@@ -1 +1,2 @@
 debian-changes-2.2.0-1~dfsg-1
+as-needed

Thanks,

-- 
Colin Watson                                       [cjwatson at ubuntu.com]





More information about the Pkg-voip-maintainers mailing list