lfs-book, version 6.4, chapter 6.7, "make: gcc: Command not found"

Aaron Schawalder mygcc at gmx.ch
Sat Feb 14 00:54:45 PST 2009


Chris Staub wrote:
> Aaron Schawalder wrote:
>   
>> (I apologize for sending this mail again. I have sent the last mail with 
>> wrong return address. I am sorry.)
>>
>>     
>
> I'm seeing a long list of problems with what you're doing...
>
>   
>> Hello
>>
>> I am new to lfs and have successfully built the toolchain. At the end 
>> oft chapter "5.12 GCC-4.3.2 - Pass 2" the output of readelf was correct:
>>
>> lfs at esprit:/mnt/lfs/tools$ echo 'main(){}' > dummy.c
>> lfs at esprit:/mnt/lfs/tools$ cc dummy.c
>> lfs at esprit:/mnt/lfs/tools$ readelf -l a.out | grep ': /tools'
>>      [Requesting program interpreter: /tools/lib/ld-linux.so.2]
>>
>>     
> At least this much is correct.
>
>   
>> All went fine and I was very careful to always strictly follow the 
>> commands of the lfs-book.
>>
>> I entered chapter 6.7 and I performed the following commands:
>> root:/sources# tar jxf linux-2.6.27.4.tar.bz2
>> root:/sources# cd linux-2.6.27.4
>> root:/sources/linux-2.6.27.4# make mrproper
>> make: gcc: Command not found
>> root:/sources/linux-2.6.27.4# gcc --version
>> bash: /tools/bin/gcc: No such file or directory
>>
>>     

Here I am in the chroot environment after chapter 6.6, that means also 
after "exec /tools/bin/bash --login +h", so the prompt ist root:/....

>> Something is wrong ...
>>
>> I performed the following tests:
>> /home/lfs is the home directory of user "lfs"
>>
>> root:/sources/linux-2.6.27.4# exit
>> logout
>> esprit:/home/lfs# echo $LFS
>> /mnt/lfs
>> esprit:/home/lfs# readelf -l /tools/bin/gcc | grep interpret
>>      [Requesting program interpreter: /lib/ld-linux.so.2]
>> esprit:/home/lfs#
>>     
>
> I don't see the point of this. You're neither the lfs user nor inside 
> chroot - this is just as a regular user, so you're only testing the host 
> system's gcc.
>
>   
The point here is, that I was user "lfs" and went "su" and performed 
"readelf -l /tools/bin/gcc | grep interpret". So I performed the readelf 
for /tools/bin/gcc as root but not in chroot.


>> esprit:/home/lfs# echo 'main(){}' > dummy.c
>> esprit:/home/lfs# cc dummy.c
>> bash: cc: command not found
>> esprit:/home/lfs# cd /tools/bin
>> esprit:/tools/bin# vdir ./cc
>> lrwxrwxrwx 1 root root 3 Jan  4 07:57 ./cc -> gcc
>> esprit:/tools/bin#
>>     
>
> Obviously "cc" isn't going to be found if /tools/bin isn't in the PATH.
>   
When I am logged in as user "lfs" and I am not in the chroot 
environment, I get:

lfs at esprit:~$ echo $LFS
/mnt/lfs
lfs at esprit:~$ echo $PATH
/tools/bin:/bin:/usr/bin
lfs at esprit:~$

So the PATH here is correct.

Now I go:

lfs at esprit:~$ cd $LFS
lfs at esprit:/mnt/lfs$ cd tools/
lfs at esprit:/mnt/lfs/tools$

Now clearly I get:

lfs at esprit:/mnt/lfs/tools$ echo 'main(){}' > dummy.c
bash: dummy.c: Permission denied
lfs at esprit:/mnt/lfs/tools$

because

lfs at esprit:/mnt/lfs$ vdir 
....
drwxr-xr-x 11 root root  4096 Feb 14 08:35 tools
...
lfs at esprit:/mnt/lfs$

what is correct.

[As I mentioned: At the end of the second path of gcc (chapter 5.12) I get:
lfs at esprit:/mnt/lfs/tools$ echo 'main(){}' > dummy.c
lfs at esprit:/mnt/lfs/tools$ cc dummy.c
lfs at esprit:/mnt/lfs/tools$ readelf -l a.out | grep ': /tools'
      [Requesting program interpreter: /tools/lib/ld-linux.so.2]

and

lfs at esprit:/mnt/lfs/tools$ readelf -l a.out                  

Elf file type is EXEC (Executable file)
....
  INTERP         0x000114 0x08048114 0x08048114 0x00019 0x00019 R   0x1
      [Requesting program interpreter: /tools/lib/ld-linux.so.2]
]


Then I go su because I can do chroot only as root:

lfs at esprit:~$ su
Password:
esprit:/home/lfs#

Now I performe chroot:

esprit:/home/lfs# chroot /mnt/lfs /tools/bin/env -i HOME=/root 
TERM="$TERM" PS1='\u:\w\$ ' 
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin /tools/bin/bash --login +h
root:/#

Now echo $PATH gives:

root:/# echo $PATH
/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin
root:/#

Now I perform:

root:/tools# echo 'main(){}' > dummy.c
root:/tools# cc dummy.c
bash: /tools/bin/cc: No such file or directory
root:/tools#



>> New login as user "lfs" just as in chapter 5:
>> lfs at esprit:~$ cd /mnt/lfs/tools/
>> lfs at esprit:/mnt/lfs/tools$ ls
>> bin  etc  i686-pc-linux-gnu  include  lib  libexec  sbin  share  var
>> lfs at esprit:/mnt/lfs/tools$ echo 'main(){}' > dummy.c
>> bash: dummy.c: Permission denied
>> lfs at esprit:/mnt/lfs/tools$ su
>> Password: esprit:/mnt/lfs/tools# echo $PATH
>> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
>> esprit:/mnt/lfs/tools# echo 'main(){}' > dummy.c
>> esprit:/mnt/lfs/tools# ls
>> bin  dummy.c  etc  i686-pc-linux-gnu  include  lib  libexec  sbin  
>> share  var
>> esprit:/mnt/lfs/tools# ./bin/cc dummy.c esprit:/mnt/lfs/tools# readelf 
>> -l a.out | grep interpret
>>      [Requesting program interpreter: /tools/lib/ld-linux.so.2]
>> esprit:/mnt/lfs/tools#
>> I don't understand why this failure occurs. I would be pleased if 
>> somebody could give me advise in this issue.
>>
>> Kind regards
>>
>> A.Schawalder
>>     
>
> readelf -l /tools/bin/gcc | grep interpret
>
> My guess is it will say /lib, not /tools/lib. 
No because als user "lfs" (not in chroot environment), it was /tools/lib 
as you see above.

> If so, gcc is linked 
> wrong, in which case my guess would be that you forgot to rm the source 
> and/or build dirs for gcc in between pass 1 and pass 2. 
No I didn't forgot this. I always removed the sources before performing 
the next step.

> If that's the 
> case, you'll need to rm -rf /tools/* and go back to the beginning of 
> chapter 5.
>   




More information about the lfs-support mailing list