Wheels, reinventing. (Was Re: [uClibc] Understanding what the build wrapper does...)

Erik Andersen andersen at codepoet.org
Fri Sep 5 05:43:47 UTC 2003


On Wed Sep 03, 2003 at 10:44:34PM -0400, Rob Landley wrote:
> In my continuing efforts to reinvent the wheel (or at least make a gcc command 
> line that cross-compiles hello.c against uclibc without the wrapper, so I can 
> understand what the heck is going on.)
> 
> I got to this point:
> 
> ---
> #/bin/sh
> 
> DIR=~/pending/sub
> GCCDIR==`gcc -v 2>&1 | head -n 1`
> GCCDIR=${GCCDIR:19}
> GCCDIR=${GCCDIR:0:$[${#GCCDIR}-6]}
> echo $GCCDIR
> 
> gcc -nostdlib -L$DIR/lib -Wl,--dynamic-linker,/lib/ld-uClibc.so.0 \
>     -Wl,--rpath-link,$DIR/lib -nostdinc -isystem $DIR/usr/include \
>     -iwithprefix include $DIR/usr/lib/crti.o $GCCDIR/crtbegin.o \
>     $DIR/usr/lib/crt1.o hello.c -lc -lgcc $GCCDIR/crtend.o $DIR/usr/lib/crtn.o
> 
> ---
> 
> $DIR is where I've loopback mounted root_fs-i386 for uClibc-0.9.20, and GCCDIR 
> parses out the install path of gcc on the host system so I can explicitly 
> tell it where the heck things live.

I think you are rather close.  What I find most helpful is trying
to compile the same program (i.e. hello.c) vs glibc which
supplying the "-v" argument to gcc, which causes it to print out
_exactly_ what it is doing.  Then (after supplying -nostdlib and
-nostdinc) you will want to do exactly the same thing, but
swapping the paths out so it uses uClibc.  We had to use the "-v"
option a lot to get the compiler wrapper to do everything it is
supposed to do.

> I also tried simplifying the gcc command line down to:
> 
> gcc -nostdlib -L$DIR/lib -Wl,--dynamic-linker,/lib/ld-uClibc.so.0 \
>     -Wl,--rpath-link,$DIR/lib -nostdinc -isystem $DIR/usr/include \
>     -iwithprefix include $DIR/usr/lib/crt0.o hello.c -lc -lgcc
> 
> But it still died with the same error.

I think you should initially try to get it working with a static
binary, and skip all the shared lib stuff till you have that
working.  Again, the best reference point is going to be watching
what 'gcc hello.o -o hello -v' spits out.

 -Erik

--
Erik B. Andersen             http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--



More information about the uClibc mailing list