[plug] building GRUB against uClibc or as a static binary?

Craig Ringer craig at postnewspapers.com.au
Sun Aug 3 22:48:04 WST 2003


>>Everything else (busybox, coreutils' dd, gzip, e2fsprogs, etc) builds
>>and runs fine against uClibc.
> 
> uclibc eh. Hmmm... mind if i ask how you got everything else to build
> against uclibc? I was trying to build a uclibc rootfs not long ago, so I
> could build a few utilities to cram on a floppy boot/root system I was
> making. The make process just doesn't seem to work... Complains about
> some missing script (apparently).

"it just worked".

uClibc was very easy to set up - I just unpacked it, ran
	make config
	make
	make install
	make PREFIX=<target-root> install_target
and it was done.

Once uclibc is built and installed, to build binaries against uclibc you 
just

export \
PATH=/usr/i386-linux-uclibc/bin:/usr/i386-linux-uclibc/usr/bin:$PATH

and then build as usual.

Try the latest uclibc release, maybe you'll have more luck. It was 
massively reworked at some stage, but I'm not sure how recent that was. 
Right now it's so easy to work with that it's great.

You do, however, have to change one configuration setting to get things 
to work like you expect, and that's the location of the dynamic linker. 
It defaults to
/usr/i386-linux-uclibc/lib
and unless you want to have your rootfs libs in that path, you'll want 
to change it to /lib . It can be changed in the "make config" interface 
of uclibc. If you change it to /lib, do NOT "make install_target" w/o a 
prefix definted as it'll overwrite libpthread.0 and it'll be rescue disk 
time. You can have uClibc in /lib fine, but you can't use threaded apps 
due to the libpthread.0 name conflict.

That said, perhaps there's nothing wrong with /usr/i386-linux-uclibc/lib 
being the location of the dynamic linker and C library. Certainly makes 
it easier to run uclibc binaries on your normal system during testing.

If you try to run a binary built against uClibc and it can't find the 
dynamic linker library, it'll fail with the rather uninformative 'not 
found'. This includes a confusing message by the kernel if you're using 
a uclibc dynamic binary as /sbin/init or /linuxrc - "init: not found" 
(or something like that). Took me a while to figure out that that meant 
it couldn't find the dynamic linker.

Busybox is clearly designed to work with uclibc, gzip and coreutils 
build w/o problems, so do e2fsprogs. I had some trouble with devfsd, 
having to remove all references to the nis (yp) services to get it to 
build. And GRUB had to be built without curses support.

Unfortunately, the image I'm building is definitely /not/ small. I'm 
trying to pack it into a 4 mb initrd :-( but perhaps building e2fsck as 
a dynamic executable will help (it defaults to static).

I'll be interested in hearing how you go. It's not hard, at least so 
long as you don't make the mistake I did about the uClibc dynamic linker 
path.

Craig Ringer



More information about the plug mailing list