Bug 6768 - linking in gas fails with uclibc because of missing libm or flag "-lm" respectively
Summary: linking in gas fails with uclibc because of missing libm or flag "-lm" respec...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.18
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
: 6937 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-07-26 10:46 UTC by Christian Burger
Modified: 2009-03-04 02:11 UTC (History)
2 users (show)

See Also:
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 (1.77 KB, text/plain)
2008-10-27 14:25 UTC, Christian Burger
Details
link shared libbfd and libopcodes against libm (797 bytes, patch)
2009-01-20 04:47 UTC, Alan Modra
Details | Diff
link shared libbfd and libopcodes against libm (1.21 KB, patch)
2009-01-20 04:50 UTC, Alan Modra
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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 cvs-commit@gcc.gnu.org 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