Bug 572 - elfutils-native-0.148 build fails: ./ld: unrecognized option '--no-add-needed'
Summary: elfutils-native-0.148 build fails: ./ld: unrecognized option '--no-add-needed'
Status: RESOLVED NOTABUG
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: devtools / tool chain (show other bugs)
Version: unspecified
Hardware: x86 ppc
: High major
Target Milestone: 1.0 M2
Assignee: Nitin Kamble
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2010-12-08 08:37 UTC by Wolfgang Denk
Modified: 2010-12-21 06:09 UTC (History)
6 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments
elfutils patch for unrecognized option '--no-add-needed' issue (3.50 KB, patch)
2010-12-08 08:37 UTC, Wolfgang Denk
no flags Details | Diff
log of do_compile for elfutils-native on fedora 14 x86_64 system (625.85 KB, application/octet-stream)
2010-12-15 08:50 UTC, Nitin Kamble
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Denk 2010-12-08 08:37:14 UTC
Created attachment 76 [details]
elfutils patch for unrecognized option '--no-add-needed' issue

Building for some PPC targets on a Fedora 14 host fails like this:

| ccache gcc -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -fgnu89-inline -Wformat=2   -isystem/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/include -O2 -Wl,-rpath-link,../libelf:../libdw -L/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/lib -Wl,-rpath-link,/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/lib -Wl,-rpath,/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/lib -Wl,-O1 -o findtextrel findtextrel.o ../libdw/libdw.so ../libelf/libelf.so
| ldgeneric.o: In function `ld_generic_open_outfile':
| ldgeneric.c:(.text+0x1681): warning: the use of `mktemp' is dangerous, better use `mkstemp'
| ccache gcc -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -fgnu89-inline -Wformat=2   -isystem/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/include -O2 -Wl,-rpath-link,../libelf:../libdw -L/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/lib -Wl,-rpath-link,/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/lib -Wl,-rpath,/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/lib -Wl,-O1 -o addr2line addr2line.o ../libdw/libdw.so ../libelf/libelf.so
| ./ld: unrecognized option '--no-add-needed'
| Try `ld --help' or `ld --usage' for more information.
| collect2: ld returned 64 exit status

This happens both on i686 and x86_64 hosts.

The attached patch fixes the problem for me, but I have to admit that I'm not
happy about just ignoring the '*add-needed' options, but I did not find a way
to stop the compiler from inserting these.


However, even then build does not complete.  It now ends like this:

| ccache gcc -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -fgnu89-inline -Wformat=2   -isystem/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/include -O2 -Wl,-rpath-link,../libelf:../libdw -L/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/lib -Wl,-rpath-link,/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/lib -Wl,-rpath,/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/lib -Wl,-O1 -o findtextrel findtextrel.o ../libdw/libdw.so ../libelf/libelf.so
| ldgeneric.o: In function `ld_generic_open_outfile':
| ldgeneric.c:(.text+0x1681): warning: the use of `mktemp' is dangerous, better use `mkstemp'
| ccache gcc -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -fgnu89-inline -Wformat=2   -isystem/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/include -O2 -Wl,-rpath-link,../libelf:../libdw -L/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/lib -Wl,-rpath-link,/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/lib -Wl,-rpath,/ssd/poky/build-g61b2906-8xx/tmp/sysroots/i686-linux/usr/lib -Wl,-O1 -o addr2line addr2line.o ../libdw/libdw.so ../libelf/libelf.so
| ./ld: cannot load ld backend library 'libld_elf_i386.so': libld_elf_i386.so: cannot open shared object file: No such file or directory
| collect2: ld returned 1 exit status
Comment 1 Nitin Kamble 2010-12-14 20:10:19 UTC
I just tested this on the current master:

I ran:
  MACHINE=qemuppc bitbake elfutils-native

and I did not see any failures.
Comment 2 Wolfgang Denk 2010-12-14 23:13:25 UTC
Did you try building under Fedora 14?
And did you try building it as "poky-image-sdk" instead of only elfutils?
It's definitely still failing for me.
Comment 3 Wolfgang Denk 2010-12-15 00:08:18 UTC
I just ran a plain "bitbake -v elfutils-native" with current top of tree on Fedora 14; it fails with "./ld: unrecognized option '--no-add-needed'" as before.
Comment 4 Nitin Kamble 2010-12-15 07:43:57 UTC
Wolfgang,
   I am also on 64bit fedora 14 for this test. And it just worked for me. Also I did not hear anybody else hit by this issue. I tried one more time, and did not see this failure.
   So it sounds like something to do with your environment, Here are few things which may help.

A. start from scratch. Delete your build directory, and restart with newly created empty build directory. If there were any issues in the state of the current build directory, those would get avoided.

B. have you installed all poky dependancy packages in fedora 14, try running this command:
  yum install poky-scripts poky-depends

let's see if these steps help or not.

Nitin
Comment 5 Nitin Kamble 2010-12-15 07:50:52 UTC
Also just want to make sure, are you sourcing the poky-init-build-env file before building ?
Comment 6 Wolfgang Denk 2010-12-15 08:22:55 UTC
I've tried all this. It does not change anything.
OK, here is a complete log of what I do:

-> sudo yum install poky-scripts poky-depends
...
Setting up Install Process
Package poky-scripts-6-6.fc13.noarch already installed and latest version
Package poky-depends-6-6.fc13.noarch already installed and latest version
Nothing to do
-> uname -a
Linux atlas.denx.de 2.6.35.6-48.fc14.x86_64 #1 SMP Fri Oct 22 15:36:08 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux

-> git describe --always
bb783af

-> rm -fr /opt/poky/build-TOT-6xx
-> source poky-init-build-env /opt/poky/build-TOT-6xx
-> cp conf/local.conf conf/local.conf.ORIG
-> cp /tmp/local.conf conf/local.conf 
-> diff conf/local.conf.ORIG conf/local.conf
6c6
< #DL_DIR ?= "${TOPDIR}/downloads"
---
> DL_DIR ?= "/home/wd/git/poky/downloads"
14c14
< # BB_NUMBER_THREADS = "4"
---
> BB_NUMBER_THREADS = "4"
16c16
< # PARALLEL_MAKE = "-j 4"
---
> PARALLEL_MAKE = "-j 4"
19c19
< MACHINE ?= "qemux86"
---
> MACHINE ?= "qemuppc"
63c63
< EXTRA_IMAGE_FEATURES = "tools-debug tools-profile tools-testapps debug-tweaks"
---
> EXTRA_IMAGE_FEATURES = "tools-sdk tools-debug tools-profile tools-testapps debug-tweaks"
142c142
< #SDKMACHINE ?= "i586"
---
> SDKMACHINE ?= "i586"
171c171
< NO32LIBS = "1"
---
> # NO32LIBS = "1"

-> echo PATH=$PATH
PATH=/home/wd/git/poky/master/scripts/..//bitbake//bin/:/home/wd/git/poky/master/scripts/..//scripts:/home/wd/git/poky/work/scripts/..//bitbake//bin/:/home/wd/git/poky/work/scripts/..//scripts:.:/home/wd/bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/libexec/git-core:/usr/X11R6/bin:/usr/X11R6/pbmplus:/opt/eldk/bin:/opt/eldk/usr/bin

-> bitbake -v elfutils-native
...
| ccache gcc -std=gnu99 -Wall -Wshadow -Werror -Wunused -Wextra -fgnu89-inline -Wformat=2   -isystem/opt/poky/build-TOT-6xx/tmp/sysroots/x86_64-linux/usr/include -O2 -Wl,-rpath-link,../libelf:../libdw -L/opt/poky/build-TOT-6xx/tmp/sysroots/x86_64-linux/usr/lib -Wl,-rpath-link,/opt/poky/build-TOT-6xx/tmp/sysroots/x86_64-linux/usr/lib -Wl,-rpath,/opt/poky/build-TOT-6xx/tmp/sysroots/x86_64-linux/usr/lib -Wl,-O1 -o elfcmp elfcmp.o ../libebl/libebl.a ../libelf/libelf.so  -ldl
| ./ld: unrecognized option '--no-add-needed'
| Try `ld --help' or `ld --usage' for more information.
| collect2: ld returned 64 exit status
| make[2]: *** [elflint] Error 1
| make[2]: *** Waiting for unfinished jobs....
| ./ld: unrecognized option '--no-add-needed'
| Try `ld --help' or `ld --usage' for more information.
| collect2: ld returned 64 exit status
| make[2]: *** [findtextrel] Error 1
| ./ld: unrecognized option '--no-add-needed'
| Try `ld --help' or `ld --usage' for more information.
| collect2: ld returned 64 exit status
| make[2]: *** [elfcmp] Error 1
| ./ld: unrecognized option '--no-add-needed'
| Try `ld --help' or `ld --usage' for more information.
| collect2: ld returned 64 exit status
| make[2]: *** [addr2line] Error 1
| rm i386_ld.o
| make[2]: Leaving directory `/opt/poky/build-TOT-6xx/tmp/work/x86_64-linux/elfutils-native-0.148-r1/elfutils-0.148/src'
| make[1]: *** [all-recursive] Error 1
| make[1]: Leaving directory `/opt/poky/build-TOT-6xx/tmp/work/x86_64-linux/elfutils-native-0.148-r1/elfutils-0.148'
| make: *** [all] Error 2
| FATAL: oe_runmake failed
| ERROR: Task failed: ('function do_compile failed', '/opt/poky/build-TOT-6xx/tmp/work/x86_64-linux/elfutils-native-0.148-r1/temp/log.do_compile.22971')
NOTE: package elfutils-native-0.148-r1: task do_compile: Failed
ERROR: Task 8 (virtual:native:/home/wd/git/poky/master/meta/recipes-devtools/elfutils/elfutils_0.148.bb, do_compile) failed with 1
ERROR: 'virtual:native:/home/wd/git/poky/master/meta/recipes-devtools/elfutils/elfutils_0.148.bb' failed
Comment 7 Nitin Kamble 2010-12-15 08:38:31 UTC
Thanks Wolfgang for sharing this information. Now looking at it, looks like only differences we have are in local.conf.

  Can you try one more time from scratch, _without_ these modifications in the config file?

63c63
< EXTRA_IMAGE_FEATURES = "tools-debug tools-profile tools-testapps debug-tweaks"
---
> EXTRA_IMAGE_FEATURES = "tools-sdk tools-debug tools-profile tools-testapps debug-tweaks"
142c142
< #SDKMACHINE ?= "i586"
---
> SDKMACHINE ?= "i586"
171c171
< NO32LIBS = "1"
---
> # NO32LIBS = "1"
Comment 8 Nitin Kamble 2010-12-15 08:41:23 UTC
I also notice the path in my setup is little different than yours:

echo $PATH
/home/nitin/prj/poky.git/scripts/..//bitbake//bin/:/home/nitin/prj/poky.git/scripts/..//scripts:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/nitin/prj/poky.git/bitbake/bin:/home/nitin/bin
Comment 9 Nitin Kamble 2010-12-15 08:50:56 UTC
Created attachment 81 [details]
log of do_compile for elfutils-native on fedora 14 x86_64 system

this is the compile log I get.
Comment 10 Wolfgang Denk 2010-12-15 09:09:44 UTC
The modifications to local.conf have no influence.

It's the PATH settings. With a cleaned up PATH like this my build completes fine, too:

PATH=/home/wd/git/poky/master/bitbake/bin/:/home/wd/git/poky/master/scripts:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/bin:/usr/bin:/usr/sbin:/sbin:/usr/libexec/git-core:/usr/X11R6/bin:/usr/X11R6/pbmplus

The problem was caused by the '.' in my old PATH. I just verified this - add '.'
before /bin and /usr/bin and the build breaks.

The '.' early in the PATH runs "./ld" when it probably never should use the linker from the elfutils directory.

Eventually poky-init-build-env should not just prepend it's own settings, but perform a more thorough sanitizing ?
Comment 11 Nitin Kamble 2010-12-15 09:13:45 UTC
Great to see it working for you. Also I notice your ~/bin is before many system paths. Depending on what you have in your ~/bin it can cause some issue too.

  adding more sanitazion/warnings in the poky-init-build-env may avoid such issues in the future. May be you can send a patch for it ? :)

Thanks,
Nitin
Comment 12 Richard Purdie 2010-12-21 06:07:41 UTC
Commit 68030f4 adds a check to sanity.bbclass to check for this and error if found.