Static binary (no shared libs) fails in Busybox 1.3.0 ?

Rich Felker dalias at aerifal.cx
Mon Dec 18 23:43:49 UTC 2006


On Mon, Dec 18, 2006 at 02:59:24PM +0100, Denis Vlasenko wrote:
> On Monday 18 December 2006 07:28, Rich Felker wrote:
> > > ~/tmp/busybox/busybox-1.3.0>make
> > > SPLIT   include/autoconf.h -> include/config/*
> > > GEN     include/bbconfigopts.h
> > > CC      applets/applets.o
> > > applets/applets.c:22:2: error: #warning Static linking against glibc produces buggy executables
> > > applets/applets.c:23:2: error: #warning (glibc does not cope well with ld --gc-sections).
> > > applets/applets.c:24:2: error: #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
> > > applets/applets.c:25:2: error: #warning Note that glibc is utterly unsuitable for static linking anyway.
> > > make[1]: *** [applets/applets.o] Error 1
> > > make: *** [applets] Error 2
> > > 
> > > I also tried in gcc 3.2.2 in RedHat Linux 9, it has same problem.
> > > Does anyone has same problem ?
> > 
> > Did you actually READ the above message? glibc has critical bugs that
> > make it so programs static-linked against glibc with gc-sections
> > option DO NOT WORK. Thus BB has provided an error message for you
> > rather than generating a binary that will seriously misbehave under
> > many circumstances.
> 
> I wouldn't be THAT harsh on glibc people. They manage a quite difficult
> project, and do a reasonably good work on that.
> 
> This isn't a "bug", glibc people simply decided that (a) static linking
> should work, but it's not their goal (priority) to work on making that
> reasonably small and (b) static linking with ld --gc-sections
> is not supported.
> 
> I even thought on overcoming this problem by always making
> busybox_static along with just busybox (and eliminating CONFIG_STATIC)
> but if we will link busybox_static without --gc-sections,
> this would pessimize uclibc people. And with --gc-sections
> we are back at square one...
> 
> What to do? Link busybox_static AND busybox_static_for_glibc?? :)

I would suggest following the glibc recommendations and not using
static linking with glibc. Even if you make a 'static' binary with
glibc it still needs libnss* crap, so glibc is rather impractical if
you really want a true static binary with no external dependencies.

Rich




More information about the busybox mailing list