Bug 6768

Summary: linking in gas fails with uclibc because of missing libm or flag "-lm" respectively
Product: binutils Reporter: Christian Burger <christian.burger>
Component: gasAssignee: Alan Modra <amodra>
Status: RESOLVED FIXED    
Severity: normal CC: bug-binutils, ps.m
Priority: P2    
Version: 2.18   
Target Milestone: ---   
Host: armeb-softfloat-linux-uclibc Target: armeb-softfloat-linux-uclibc
Build: armeb-softfloat-linux-uclibc Last reconfirmed: 2009-01-16 07:41:22
Attachments: last 100 lines of the build with the error and "make -j"-option not set
link shared libbfd and libopcodes against libm
link shared libbfd and libopcodes against libm

Description Christian Burger 2008-07-26 10:46:27 UTC
The nitty-gritty stuff I already posted at
http://bugs.gentoo.org/sh=ow_bug.cgi?id=226335 , but to summarize: I found
reports of similar bugs in other packages and a report of the same in the
previous version of binutils: 2.17. I wrote a patch targeted at
binutils/gas/configure.tgt .

Just in case you are not familiar with gentoo, file descriptions:
* filed in "emerge.log" is the build error
* "emerge.info" hosts my system configuration

Thanks and so long.
Comment 1 Christian Burger 2008-07-26 10:49:53 UTC
I forgot to explicitly mention, that it is a build related bug.
Comment 2 Alan Modra 2008-08-07 15:21:21 UTC
I can't see why arm gas would need -lm to build.  I can see that arm objdump
does, and this should be handled by AC_SEARCH_LIBS(frexp, m) in
binutils/configure.in.

Your build log attached to the gentoo bug report is just too confusing since it
shows what looks like "make -j" output, ie. the result of multiple compilations
emitted in jumbled order.  Can you please show just the results of remaking
as-new by itself?
Comment 3 Christian Burger 2008-10-27 14:25:50 UTC
Created attachment 3028 [details]
last 100 lines of the build with the error and "make -j"-option not set

(In reply to comment #2)
> I can't see why arm gas would need -lm to build.  I can see that arm objdump
> does, and this should be handled by AC_SEARCH_LIBS(frexp, m) in
> binutils/configure.in.

I can't help you with that either, I only fixed a symptom and don't know if it
is the problem too.

> Your build log attached to the gentoo bug report is just too confusing since
it
> shows what looks like "make -j" output, ie. the result of multiple
compilations
> emitted in jumbled order.  Can you please show just the results of remaking
> as-new by itself?

Didn't get your last sentence, but I think I did the right thing anyway.

Thanks again and bye.
Comment 4 Alan Modra 2009-01-16 07:41:22 UTC
I didn't realise this was an --enable-shared build.  gas links against the
shared libopcodes, which means you are linking against the whole libopcodes. 
libopcodes has a reference to floatformat_to_double (in arm-dis.c), causing
floatformat.o to be linked from libiberty.  A static link would only pull in the
parts of libopcodes used by gas, so no arm-dis.o needed.

It's a little nasty that libopcodes.so needs libiberty like this.  Every app
linked against libopcodes.so thus pulls in parts of the static libiberty whether
or not the app needs it.
Comment 5 Alan Modra 2009-01-19 08:39:36 UTC
*** Bug 6937 has been marked as a duplicate of this bug. ***
Comment 6 Alan Modra 2009-01-20 04:47:57 UTC
Created attachment 3673 [details]
link shared libbfd and libopcodes against libm

Would someone please test whether the following patch, when applied to mainline
CVS binutils, fixes the problem?  You'll need a version more recent than
2001-01-16. to pick up http://sourceware.org/ml/binutils/2009-01/msg00224.html
Comment 7 Alan Modra 2009-01-20 04:50:05 UTC
Created attachment 3674 [details]
link shared libbfd and libopcodes against libm

The right patch this time!
Comment 8 Sourceware Commits 2009-03-04 02:10:48 UTC
Subject: Bug 6768

CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2009-03-04 02:10:34

Modified files:
	bfd            : ChangeLog configure.in configure 
	opcodes        : ChangeLog configure.in configure 

Log message:
	bfd/
	PR 6768
	* configure.in: Test for ld --as-needed support.  Link shared
	libbfd against libm.
	* configure: Regenerate.
	opcodes/
	PR 6768
	* configure.in: Test for ld --as-needed support.  Link shared
	libopcodes against libm.
	* configure: Regenerate.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.4484&r2=1.4485
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/configure.in.diff?cvsroot=src&r1=1.255&r2=1.256
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/configure.diff?cvsroot=src&r1=1.296&r2=1.297
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/opcodes/ChangeLog.diff?cvsroot=src&r1=1.1366&r2=1.1367
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/opcodes/configure.in.diff?cvsroot=src&r1=1.88&r2=1.89
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/opcodes/configure.diff?cvsroot=src&r1=1.117&r2=1.118

Comment 9 Alan Modra 2009-03-04 02:11:26 UTC
Should be fixed