[buildroot] $(STRIP) --strip-unneeded on a SHARED library...WHY?

John Z. Bohach jzb at aexorsyst.com
Tue Dec 6 18:48:59 UTC 2005


On Tuesday 06 December 2005 10:10, Mike Frysinger wrote:
> On Tue, Dec 06, 2005 at 11:44:56AM -0500, Paul Fox wrote:
> >  > > -$(STRIP) --strip-unneeded $(TARGET_DIR)/lib/libdb*so*
> >  > >
> >  > > which is not fine, because all symbol information from the libraries
> >  > > is now removed, and whenever a linker tries linking against thusly
> >  > > stripped libraries, you get "undefined symbol..." errors.
> >  >
> >  > cant say ive had this issue before and as solar pointed out, we've
> >  > been using --strip-unneeded on *all* shared libraries for quite a long
> >  > time now without any linking issues
> >
> > we use --strip-unneeded too, and it's fine.  but it's fine for
> > runtime.  is it perhaps the case that libraries stripped like
> > that can no longer be used in development?
>
> no, because we're using it in Gentoo
>
> that means every single Gentoo user has every single shared library
> stripped with --strip-unneeded
>
> i have yet to see a bug reported where someone was unable to link
> against a library ... and since it's Gentoo, everytime a package is
> installed, it's compiled and linked on every system
> -mike

Can't speak to gentoo, but I can tell you what I've observed myself when 
trying to build buildroot in a development environment built by buildroot.  
Once I commented out the 'strip'-ing of ncurses, berkelydb, etc., things like 
perl, 'make menuconfig' of buildroot itself, etc. all work.  Otherwise, 
"undefined symbol ..." error.  LFS chapter 5 comments on stripping static 
libraries:

http://www.linuxfromscratch.org/lfs/view/stable/chapter05/stripping.html

says don't do it.

and also in Ch.6 it comments on --strip-all on all libraries:

http://www.linuxfromscratch.org/lfs/view/stable/chapter06/strippingagain.html

and specifically does '--strip-debug' on the libraries instead.  Looking 
closely, however, there is no reference to 'strip-unneeded' on the libraries 
themselves (just binaries).

This, combined with my own observed behavior, leads me to believe that the 
--strip-unneeded option on shared libraries is the root cause of the 
'undefined symbol...' errors when linking against the shared libraries.

I guess its possible that somehow the --strip-unneeded option to strip is 
broken under buildroot, but it doesn't seem likely.  I run:

 $ nm libdb-4.3.so 

and get:

nm: libdb-4.3.so: no symbols

after its been '--strip-unneeded'-ed.  Seems like the right root cause, unless 
'strip' is broken?!

If I run 'nm' on a not '--strip-unneeded'-ed version of libdb, or any other 
library, I get all the symbols, and linking is fine.  Otherwise, link-time 
'undefined symbol' errors.

So if nobody else sees this behavior, then I'm really confused...

Could someone else please try a 'strip --strip-unneeded'  on a lib*.so, and 
see if you can still link against it afterwards, and what 'nm lib*.so' 
produces?  Is this unique to buildroot devel. envs. only?

(P.S.:  I ran all this natively in a devel. env. created by buildroot...)

--john




More information about the busybox mailing list