Linux From ScratchThis Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Hi all. I'm attempting to compile LFS-5.1.1, and am having some problems. Binutils appeared to go smoothly, but when it came to building GCC-3.3.3 pass-one, I got the following error message on configuring:
Configuring "Makefile" in /mnt/lfs/sources/gcc-build using 'mt-frag'
/tools/bin/ld: Unrecognised option '--as needed'
/tools/bin/ld: Use the --help option for usage information
collect2: ld returned 1 exit status
***The command 'gcc conftest -g -02 conftest.c' failed.
***You must set the CC environment variable CC to a working compiler.
I'm quite new to all this, so please try to keep it simple, although any help will be greatly appreciated. Even if you don't have a solution to my problem, if you could explain to me what it means that would be great.
sorry if I do not answer that one directly, but instead give you directions...
I - and others - have commented on exactly the same issue...may have been yesterday or even 3 or 4 days ago...
I cannot remember, so: try searching for posts from me or Andrew Benton - I remember him adding to this issue
this is (most probable) due to a typo in your command (did you cut & paste it?)
The CC environment-variable normally contains the real name - maybe even the path and the name of your compiler - you can use it to select the compiler ... if you have different versions installed - this is described in the hints, which are available for LFS
if I do: "echo $CC" I get this: cc
Jonathan:/home/jochen# echo $CC
in my .bash_profile I have these entries - which enable me to easyly change, which compiler gets used:
if I comment out the first two and uncomment the second two - then source the file or log out and back in - which does the same - I will then be using gcc-2.95.3 which is in /opt/gcc-2.95.3/bin/gcc
- that is: if the makefile references the compiler by using this variable...
Nope, that didn't work. Never mind though. I've gotten around the problem by dumping Fedora Core 2 in favour of Debian as the host system. It seems to work on that. I know it's not the ideal solution, and I'd really have liked to have kept Fedora, but what's done is done. I had no choice because I'm working on a small hard drive.
I found while using Knoppix to build my LFS 5.11 that I had to set the CC environment variable to point to the gcc-2.95 instead gcc-3.3 that /usr/bin/gcc was linked to. As soon as I did this the error went away.
Im a total Linux newbie, started looking into LFS two days ago and compiled my first Linux program ever yesterday. Be warned.
From what I can tell based on experience and looking around on the net, the problem has nothing to do with the actual CC variable, the problem is further up, and the problem is that GCC 3.3.3 (used by Fedora 2) tries to use the --as-needed flag with the ld you compiled one step earlier (in binutils). LFS uses binutils 2.14, and that version of ld does not support --as-needed. Somehow GCC 3.3.3 checks for binutils version on the host system instead of checking the ld it is about to use.
To fix it, use an older GCC or use binutils 2.15 in your LFS.
- Run gcc -v and check the output for line "Reading specs from /usr/lib........./specs
- Save backup copy of specs file.
- Edit this file and find (and delete) option --as-needed
- After building the LFS copy back your original specs file.