paul w wrote:> Hi
>
> I've managed to compile klibc 0.198 and run the hello world program.
> How can I compile my own program?
> Can someone give an example or provide a simple wrapper program for doing
this?
> like uclibc did with their earlier versions.
>
> I looked at the make process and did a bit reading and figure out this
much:
>
> gcc -Wp,[preprocessor options] -MT,[target_name_I_think] tests/hello.o,
> -MD,[include dependency] tests/.hello.o.d
> -mregparm=3 -DREGPARM=3 [Control how many registers are used to pass
integer arguments]
> -march=i386 [arch] -Os [optimization] -g [debug info]
> -falign-functions=0 -falign-jumps=0 -falign-loops=0 [I think they are
to optimize for size]
> -nostdinc -iwithprefix [include dir prefix] include -D__KLIBC__
-DBITSIZE=32
> -I -I ... -DWITH_ERRLIST
> -W -Wall -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
-c -o tests/hello.o
> crt0.o tests/hello.o libc.a
/usr/lib/gcc/i686-pc-linux-gnu/3.4.1/libgcc.a
> ld -o tests/hello crt0.o tests/hello.o libc.a
/usr/lib/gcc/i686-pc-linux-gnu/3.4.1/libgcc.a
>
> I guess I need to do a few things here:
> 1. copy libc.a crt0.o somewhere fixed
> 2. copy klibc include dir somewhere fixed
> 3. figure out how to instruct gcc to search for klibc includes
> 4. figure out how to instruct gcc to search for system libc
>
> Please help with 3 and 4. Thanks
>
4. isn't even valid; klibc uses ld directly rather than going through gcc.
There really isn't a standard klibc out-of-tree build system yet. There
are more things than that; gcc sometimes needs additional
architecture-specific options (like -mregparm=3 -DREGPARM=3 for i386).
Right now all that stuff is embedded in Makefiles.
At this point, your best bet is is to use the klibc build system, and
clone one of the existing Makefiles, or add your stuff to the utils/
directory.
-hpa