You are not logged in.

#1 2009-03-19 01:32:36

.Maleficus.
Member
Registered: 2008-11-13
Posts: 18

Problem with command from LFS

So right now I'm in the middle of a LFS build (current stable).  I'm at Chapter 5 and currently doing the first build of glibc.  I'm having problems with the command:

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

I've tried the above, escaping the sed command with '\' and doing a new line, a whole bunch of things.  It's all typed correctly because the 'gcc -print... | sed 's/libgcc/&_eh/'' line works fine by itself, but not with the whole command.  I would just use the absolute path that the second half (I think) is looking for, but I'm on a fresh Arch install, no X or anything and the path it prints me is "/mnt/lfs/tools/bin/../lib/gcc..." and that's not going to work. 

Any help would be greatly appreciated.

Offline

#2 2009-03-19 08:58:53

plurt
Member
Registered: 2008-10-16
Posts: 88

Re: Problem with command from LFS

could you post the exact output?


When everything's coming your way, you're in the wrong lane I say.
FAQ / Beginners Guide / The Arch Way

Offline

#3 2009-03-19 11:08:19

.Maleficus.
Member
Registered: 2008-11-13
Posts: 18

Re: Problem with command from LFS

I accidently hit the left-arrow after I finished typing my reply so eLinks dominated me, so sorry for the briefness of this one.

Here's the output:

ln: target 'gcc -print-libgcc-file-name | \\\nsed 's/libgcc/' is not a directory: No such file or directory
[1]7370 #Changes randomly, I don't know why
bash: _eh/: No such file or directory
[1]+ Exit 1                  ln -vs libgcc.a 'gcc -print-libgcc-file-name | \
sed 's/libgcc/

Seems like it's escaping in weird places, ideas?  I've tried different combinations of single and double quotes but nothing seems to work out (except typing the commands separately, and I can't see the full output of the gcc/sed command).

Thanks again.

Offline

#4 2009-03-19 11:37:35

bobdob
Member
Registered: 2008-06-13
Posts: 138

Re: Problem with command from LFS

Hey it is supposed to be back quotes (`), the one above tab, wrapping `gcc .. | sed ...` .

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

Offline

#5 2009-03-19 11:47:17

.Maleficus.
Member
Registered: 2008-11-13
Posts: 18

Re: Problem with command from LFS

bobdob wrote:

Hey it is supposed to be back quotes (`), the one above tab, wrapping `gcc .. | sed ...` .

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

Thank you so much!  I don't know why I didn't notice that, they seem so obvious now...

Also, I know next to nothing about sed, could you explain what the 'gcc...sed' line is actually doing?  The LFS page says it's just creating the symlink, but I'd like to know how it found the file to link to, not just why I'm linking to it.

Offline

#6 2009-03-19 11:59:26

bobdob
Member
Registered: 2008-06-13
Posts: 138

Re: Problem with command from LFS

Sure, I don't know much about sed but I think i know what this does.

gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'
This takes the output of gcc .. and passes it as the input to sed ..

sed 's/libgcc/&_eh/'
Then this replaces the first occurance of 'libgcc' with '&_eh' and outputs the result.

Last edited by bobdob (2009-03-19 11:59:50)

Offline

#7 2009-03-19 12:01:38

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,498
Website

Re: Problem with command from LFS

So, the "gcc -printt-libgcc-file-name" command will print something like "/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/libgcc.a" and the sed changes that to "/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/libgcc_eh.a".  I can not remember why you do that off the top of my head (been a couple of years since I did an LFS build...)

Edit: it is something to do with the way gcc is built to minimise the influence of the host system.  That does not create the libgcc_ed.a file which it appears glibc uses in a compile.   This appears to be something newer to the LFS build that is not explained very well...

Offline

#8 2009-03-20 02:22:09

.Maleficus.
Member
Registered: 2008-11-13
Posts: 18

Re: Problem with command from LFS

Thanks bobdob and Allan.  I think I'm going to start over (having some problems with finishing up the second gcc build, can't find a directory and Google yields 8 results...) but this will definitely help me out when I start over.

Offline

#9 2009-03-20 06:10:24

Aprz
Member
From: Newark
Registered: 2008-05-28
Posts: 277

Re: Problem with command from LFS

Just so you know, sed is sort of like a filter. If you do

echo "hello" | sed s/hello/bye/

The output will be bye instead of hello. It subsistuted hello with bye. It's a very handy dandy tool. If you can master it, you can do some very powerful and meaningful things with your outputs and files. The amp (&) is what you filtered (libgcc in your case) and then you added the _eh to the end of it (replacing all libgcc with libgcc_eh instead). I really recommend looking into sed, I find it very useful. Even if you don't have anything useful to do with it, you can definitely make yourself look cool using it instead which is really why we all use Linux (just kidding - sort of). B)

echo "hello" | sed 's/hello/Then I said "&" to her./'

Last edited by Aprz (2009-03-20 06:14:15)

Offline

#10 2009-03-20 08:32:23

lilith2k3
Member
From: Osnabrueck
Registered: 2008-09-01
Posts: 25

Re: Problem with command from LFS

But why use Backticks instead of "$()"?
Then it would be much clearer.

Offline

#11 2009-03-20 09:31:20

Aprz
Member
From: Newark
Registered: 2008-05-28
Posts: 277

Re: Problem with command from LFS

lilith2k3 wrote:

But why use Backticks instead of "$()"?
Then it would be much clearer.

Preference. *shrugs* hmm

Offline

#12 2009-03-20 11:14:24

.Maleficus.
Member
Registered: 2008-11-13
Posts: 18

Re: Problem with command from LFS

@Aprz - Yeah, after the few sed commands they've done I've decided to read O'Reilly's book "sed & awk".  awk seems a little more useful than sed (for me anyways) but not knowing much about either I can't really say much about it yet.

@lilith - They do use "$()" in the later pages, and yeah, it's much clearer wink.

Offline

Board footer

Powered by FluxBB