LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Failed to build glibc, VirtualBox 32-bit question (https://www.linuxquestions.org/questions/linux-from-scratch-13/failed-to-build-glibc-virtualbox-32-bit-question-885016/)

MTK358 06-07-2011 11:23 AM

Failed to build glibc, VirtualBox 32-bit question
 
1 Attachment(s)
I started to try building LFS again, and I created a 32-bit VM in VirtualBox. I have gone all the way to glibc pass 1 before I realized that the LFS live CD image I had is 64-bit! :eek: I went back and redid the 64-bit specific steps that I skipped (I hope the order wasn't important).

The strange part is that everything seems to work fine (The host CPU and OS are 64-bit, and the CPU supports hardware virtualization). I would really want to aviod having to redo this since I already spent so much time on it.

Also, I'm stuck because I get an error when running make on glibc (screenshot in attachment). How do I fix it, and could it have anything to do with what I mensioned above?

druuna 06-07-2011 02:13 PM

Hi,

Quote:

.../ld: cannot find -lgcc_eh
This is most often due to a missing symlink. Did you forget to run the ln command (last command gcc pass 1), or is/was $LFS_TGT set correctly?

Hope this helps.

BTW: If you created a 32 bit VM, shouldn't your LFS build reflect that? Strange indeed! What does $(uname -m)-lfs-linux-gnu show?

Hope this helps.

MTK358 06-07-2011 02:49 PM

1 Attachment(s)
Quote:

Originally Posted by druuna (Post 4379062)
This is most often due to a missing symlink. Did you forget to run the ln command (last command gcc pass 1), or is/was $LFS_TGT set correctly?

If you mean this one (on page 35):

Code:

ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | \
sed 's/libgcc/&_eh/'`

, then yes. I ran it inside the gcc build directory. I most likely ran it like this but it shouldn't make any difference:

Code:

ln -vs libgcc.a $($LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
Note that everywhere else they use $(), but here they used backticks. Is that an error?

Quote:

Originally Posted by druuna (Post 4379062)
BTW: If you created a 32 bit VM, shouldn't your LFS build reflect that? Strange indeed! What does $(uname -m)-lfs-linux-gnu show?

Code:

$ echo $(uname -m)-lfs-linux-gnu
x86_64-lfs-linux-gnu

The attached screenshot shows the relevant VirtualBox settings.

druuna 06-08-2011 05:35 AM

Hi,
Quote:

Originally Posted by MTK358 (Post 4379097)
If you mean this one (on page 35):

Code:

ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | \
sed 's/libgcc/&_eh/'`

, then yes. I ran it inside the gcc build directory. I most likely ran it like this but it shouldn't make any difference:

Code:

ln -vs libgcc.a $($LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
Note that everywhere else they use $(), but here they used backticks. Is that an error?

This should not be a problem, I do believe that the using $(...) is even preferred nowadays.

Did you check to see if lgcc_eh is actually present and reachable?

If you are sure nothing went wrong during the previous 3 packages that where build: Have you seen this post: Getting past 'cannot find -lgcc_eh' and 'inlining failed in call to 'syslog'' errors. Bit old and it might not work with the current LFS version, but you might want to give it a try.

Quote:

Code:

$ echo $(uname -m)-lfs-linux-gnu
x86_64-lfs-linux-gnu

The attached screenshot shows the relevant VirtualBox settings.
I assume you used a gui to set up this virtual client, maybe it did not force a 32 bit environment. Looking at the output of the above command I'm pretty sure it shouldn't cause problems.

BTW: I'm assuming you are building LFS 6.8 Stable.

MTK358 06-08-2011 06:40 AM

Quote:

Originally Posted by druuna (Post 4379676)
This should not be a problem, I do believe that the using $(...) is even preferred nowadays.

Should it be reported as an error to the authors of the LFS book? Everywhere else they use $(), but here they used backticks.

Quote:

Originally Posted by druuna (Post 4379676)
Did you check to see if lgcc_eh is actually present and reachable?

I don't even understand what "libgcc_eh" is.

No, I didn't see that post, but before trying the command I wanted to ask something. That post says this:

Code:

gcc -print-libgcc-file-name
, while the LFS book says this:

Code:

$LFS_TGT-gcc -print-libgcc-file-name
. Which one is correct?

Quote:

Originally Posted by druuna (Post 4379676)
I assume you used a gui to set up this virtual client, maybe it did not force a 32 bit environment. Looking at the output of the above command I'm pretty sure it shouldn't cause problems.

Yes, I did use the VirtualBox GUI.

Quote:

Originally Posted by druuna (Post 4379676)
I'm assuming you are building LFS 6.8 Stable.

That's right.

druuna 06-08-2011 07:19 AM

Hi,
Quote:

Originally Posted by MTK358 (Post 4379734)
Should it be reported as an error to the authors of the LFS book? Everywhere else they use $(), but here they used backticks.

This isn't the only place that backtics are used, although $( ) is used much more often. Not an error in my opinion, just team members using "their" default.

The link with the possible solution I posted is based on an older LFS version (I'm not even sure if LFS_TGT was already being used in that version). If you read the complete thread and the link to the lfs mailing list you probably get the same feeling I have: This was during the transition period from 32 bit only to the mixed 32/64 bit that is used nowaday (at least LFS versions 6.7 and 6.8).

The following is probably a bold assumptions: This being your first (second?) attempt to build an LFS system I'm pretty sure that you made a mistake in one of the previous chapters. Your not that far into the build yet, and I would suggest starting over, just to make sure all was done the way it should and just in case: Don't change commands given in the book, even if it looks like the edited command does the same.

Starting to hack the build this early just doesn't feel good (no hacking should be needed at all.....) and if new errors start to appear at a later stage you'll always wonder if the cause was chapter 5 glibc.

Probably not what you expected to read, but hope it helps.

MTK358 06-08-2011 07:36 AM

This is actaully my third or fourth LFS attempt. :redface:

I decided to restart from compiling binutils, since I had made some likely errors and mistakes since then.

I also wrote a script that takes a file with a sequence of commands and runs them in order. If one fails, it stops and tells me what command line options to use to resume from that point. I decided that I'll use it this time, and it's really making the whole process easy. I'm already more than half way done with pass 1!

MTK358 06-08-2011 08:02 AM

I completed Pass 1 successfully! I'll post here is something goes wrong that I can't figure out.

MTK358 06-08-2011 09:35 AM

1 Attachment(s)
Now I get this error when configuring pass 2 of binutins:

druuna 06-08-2011 10:47 AM

Hi,

Did you encounter any errors while doing the Adjusting the Toolchain chapter (especially the checks in the caution box)?

At this point (Binutils-2.21 - Pass 2) you are partially using what you have build before, which is set by the adjusting the toolchain chapter. If binutils pass 2 fails one of the previous three packages (or a combination or all) did not install correctly (the three packages being: binutils, gcc, or glibc).

This is a show-stopper and it does need to be resolved before you continue.

Hope this helps.

MTK358 06-08-2011 11:11 AM

1 Attachment(s)
Quote:

Originally Posted by druuna (Post 4380015)
Did you encounter any errors while doing the Adjusting the Toolchain chapter (especially the checks in the caution box)?

No. But there's another error that I noticed that wouldn't be caught if I followed the instructions exactly. For some reason, the compiled executable doesn't execute! Bash says that the file isn't there (even though tab completion does see it) (see the attached screenshot)!

It works fine if I use the GCC that came with the LFS live CD, though:

Code:

$ /usr/bin/gcc test.c -o test
$ ./test
Hello, World!


crts 06-08-2011 11:16 AM

Hi,

in your initial post you say that your VM is a 32-bit architecture but you are using the 64-bit liveCD. I wonder if this might be a possible source of trouble.
I remember that I also build my first LFS with a 64-bit liveCD. However, it had its own modified LFS-book "onboard". IIRC, there were some differences to the original LFS.

So, if I understood correctly so far, then you are using an unofficial liveCD with the official LFS book. I am not saying that this is wrong. Just trying to point out some other possible sources of trouble.

So I guess my advise at this point is to keep it as simple as possible and use the official 32-bit liveCD with a 32-bit VM and with the official LFS book. Maybe even build an older version of LFS that definitely works with the liveCD, since the liveCD is pretty old. My last LFS with the liveCD was 6.6.

Quote:

For some reason, the compiled executable doesn't execute! Bash says that the file isn't there (even though tab completion does see it)!
This usually means that it cannot find its linker. What is the output of
Code:

ldd a.out
[EDIT]
Just saw your EDIT. Do you have a /tools/lib64 directory? If not then try creating a symlink
/tools/lib64 -> /tools/lib

And of course run 'ldd' on test and not a.out.

druuna 06-08-2011 11:26 AM

Hi,

Quote:

readelf -l a.out | grep ': /tools'
[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]
The green part is not what the book example shows, but is correct as explained in the book. The red part isn't correct, that does need to say ld-linux.so.2.

You've been trying to build LFS by automating it. I would advise not automating and doing it by hand. I've automated the LFS build and found out that some of the commands/actions shown in the book need special care when you automate them. I too tried (half) automating when I did my first build and failed miserably...... ;) Only after knowing what was done in the book by doing it all by hand (twice, during my second build I started adjusting things to my likings and got an even better understanding) I was able to script LFS.

It also made sure that I knew which errors where LFS related and which script related.

BTW: Do make a backup once you finish chapter 5! It would be too bad if something went wrong during chapter 6 and you had to start all over again. With a backup you can delete all, restore the backup and start from the top of chapter 6 again.

Hope this helps.

EDIT: Just noted your edit.

It did NOT work! You are not supposed to use the gcc that came with liveCD at this point!!

MTK358 06-08-2011 12:18 PM

Quote:

Originally Posted by crts (Post 4380050)
I remember that I also build my first LFS with a 64-bit liveCD. However, it had its own modified LFS-book "onboard". IIRC, there were some differences to the original LFS.

So, if I understood correctly so far, then you are using an unofficial liveCD with the official LFS book. I am not saying that this is wrong. Just trying to point out some other possible sources of trouble.

I'm using the PDF version of the LFS book 6.8. I downloaded it the day before yesterday. The Live CD did come with the LFS book, but I hate having to use command-line browsers. Having the PDF version on Okular is so much nicer, and the table of contents in the sidebar is very handy.

The Live CD is the official 64-bit LFS Live CD. It might not be the newest, though, since I downloaded it a few months ago. If I had to start over, I would definitely get the newest 32-bit official LFS Live CD.

Quote:

Originally Posted by crts (Post 4380050)
This usually means that it cannot find its linker. What is the output of
Code:

ldd a.out

Code:

$ ldd test
        not a dynamic executable

Quote:

Originally Posted by crts (Post 4380050)
Just saw your EDIT. Do you have a /tools/lib64 directory? If not then try creating a symlink
/tools/lib64 -> /tools/lib

I checked, and both /tools/lib and /tools/lib64 exist, and they have different contents! Maybe I really need to just start over, this time with the 32-bit CD.

Quote:

Originally Posted by druuna (Post 4380057)
You've been trying to build LFS by automating it. I would advise not automating and doing it by hand. I've automated the LFS build and found out that some of the commands/actions shown in the book need special care when you automate them. I too tried (half) automating when I did my first build and failed miserably...... ;) Only after knowing what was done in the book by doing it all by hand (twice, during my second build I started adjusting things to my likings and got an even better understanding) I was able to script LFS.

The reason I wanted to automate it is because my last attempts failed because I had to do so much waiting between commands, and I kept screwing it up, until I got so bored and frustrated that I just decided to give up.

So before staring, I decided to write a big shell script that takes an input file of commands, and runs them automatically, and (unlike a normal shell script) lets me step in, fix the problem, and resume if something fails. It also meant that it's not such a big deal to do a huge part all over again, since the script takes care of it.

I tried doing pass 1 manually, and found out that I messed it up after spending a few hours on it. So decided to use my automation script, and I completed pass 1 in a matter of minutes with minimal intervention.

Then I spent a long time writing an input file for my automation script that would complete pages 61-91 of the LFS book all on its own. And the point where it failed is when that script got to configuring binutils.

I'm still tempted to use my automation scripts even I have to start over, since I spent a lot of time and effort writing them and they really made the process easier. Maybe I should use them slightly less (especially for the more fragile parts), or thoroughly review them to make sure they don't have any mistakes/typos?

Quote:

Originally Posted by druuna (Post 4380057)
BTW: Do make a backup once you finish chapter 5! It would be too bad if something went wrong during chapter 6 and you had to start all over again. With a backup you can delete all, restore the backup and start from the top of chapter 6 again.

I use VirtualBox's "snapshot" feature after every significan milestone and before I shut it down for te night (it's a Live CD, and if I reboot I will lose everything from the "setting up the environment" part)

Quote:

Originally Posted by druuna (Post 4380057)
It did NOT work! You are not supposed to use the gcc that came with liveCD at this point!!

?????????

druuna 06-08-2011 12:25 PM

Hi,
Quote:

Originally Posted by MTK358 (Post 4380102)
Quote:

Originally Posted by druuna
It did NOT work! You are not supposed to use the gcc that came with liveCD at this point!!

?????????

Forget about that comment. Re-reading it it seems I misunderstood. I thought your solution was using the gcc from the liveCD and thought al was well.


All times are GMT -5. The time now is 10:26 PM.