Modify

#786 new defect

Build system doesn't differentiate between compiler and linker options

Reported by: stefanor@… Owned by:
Priority: normal Milestone:
Component: BitlBee Version: 3.0.2
Keywords: Cc:
IRC client+version: Client-independent Operating System: Linux
OS version/distro:

Description

Bitlbee's build system mixes compiler and linker options.

Debian and Ubuntu are trying to enforce stricter linking behavior, to ease the transition to the gold linker: http://wiki.debian.org/ToolChain/DSOLinking

One of the issues encountered was that bitlbee's otr plugin wasn't linked against libotr2, resulting in https://bugs.launchpad.net/ubuntu/+source/bitlbee/+bug/757008

I think this happened because -lotr came before gcc arguments (-fPIC and the .c file). Linker arguments must come last:

$ gcc -g -O2 -I/home/stefanor/deb/bitlbee-3.0.1/debian/build-native -I/home/stefanor/deb/bitlbee-3.0.1 -I/home/stefanor/deb/bitlbee-3.0.1/lib -I/home/stefanor/deb/bitlbee-3.0.1/protocols -I. -DHAVE_CONFIG_H -Wall -pthread -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include -I/usr/include -MD -MF .depend/otr.so.d -L/usr/lib -lotr -fPIC -shared /home/stefanor/deb/bitlbee-3.0.1/otr.c -o otr.so

Additionally, it would be really handy if the build system outputted the commands it was running.

Attachments (0)

Change History (3)

comment:1 Changed at 2011-10-06T23:16:54Z by pesco

  • wrong: @$(CC) $(CFLAGS) $(OTRFLAGS) -fPIC -shared $(LDFLAGS) $< -o $@
  • better: @$(CC) $(CFLAGS) -fPIC -shared $(LDFLAGS) $< -o $@ $(OTRFLAGS)
  • best: @$(CC) $(CFLAGS) -fPIC -shared $(LDFLAGS) $< -o $@ $(LIBS)

where LDFLAGS=-L/usr/lib and LIBS=-lotr

comment:2 Changed at 2011-10-07T00:02:10Z by pesco

here's a patch for the quick and dirty solution:

--- Makefile	2011-07-31 22:59:42 +0000
+++ Makefile	2011-10-06 23:59:48 +0000
@@ -155,7 +155,7 @@
 
 $(OTR_PI): %.so: $(SRCDIR)%.c
 	@echo '*' Building plugin $@
-	@$(CC) $(CFLAGS) $(OTRFLAGS) -fPIC -shared $(LDFLAGS) $< -o $@
+	@$(CC) $(CFLAGS) -fPIC -shared $< -o $@ $(LDFLAGS) $(OTRFLAGS)
 
 $(SKYPE_PI): $(SRCDIR)protocols/skype/skype.c
 	@echo '*' Building plugin skype

comment:3 Changed at 2011-10-23T16:30:18Z by jtaylor.debian@…

it is also relying on indirect linkage for libglib2 As its using its symbols it should also explicitly link against it:

ldd -r ./debian/build-native/otr.so
...
undefined symbol: g_malloc	(./debian/build-native/otr.so)
...

Modify Ticket

Action
as new The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.