add -fPIC option for shared libbusybox.so

Bernhard Fischer rep.nop at aon.at
Tue May 2 15:38:44 UTC 2006


On Tue, May 02, 2006 at 12:16:55PM +0200, Peter S. Mazinger wrote:
>On Tue, 2 May 2006, Yasushi SHOJI wrote:
>
>> At Tue, 2 May 2006 10:40:21 +0200 (CEST),
>> Peter S. Mazinger wrote:
>> > 
>> > On Tue, 2 May 2006, Yasushi SHOJI wrote:
>> > 
>> > > --- busybox.orig/Rules.mak	2006-05-02 13:25:36.000000000 +0900
>> > > +++ busybox/Rules.mak	2006-05-02 13:25:43.000000000 +0900
>> > > @@ -233,6 +233,9 @@ LIB_CFLAGS+=$(CFLAGS_SHARED)
>> > >  ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
>> > >      CFLAGS_PIC:= $(call check_gcc,-fPIC,)
>> > >      LIB_CFLAGS+=$(CFLAGS_PIC)
>> > > +    ifeq ($(strip $(TARGET_ARCH)),x86_64)
>> > > +        CHECKED_CFLAGS+=$(CFLAGS_PIC)
>> > > +    endif
>> > >  endif
>> > 
>> > this is rather a general issue, I have checked on x86 (bb-1.1.2, changed 
>> > the CONFIG_DISABLE_SHARED, curious name for what it should do) and iirc 
>> > it was also reported for arm on uClibc ml maybe a week ago.
>> > CFLAGS_PIC should be used for all objects going into any shared lib (so 
>> > at least libbb/*), but it is used only at link time (where it is 
>> > superfluos)
>> 
>> if so, we can just ommit ifeq/endif and add CFLAGS_PIC to
>> CHECKED_CFLAGS.
>
>I would leave the issue to Bernhard, he knows what he wants there to 
>have (and in busybox 1.1.2 you can't come to enable this option at all)
>for the earlier version(s) simply don't enable building libbusybox.so

The now reverted new buildsys did use different extensions for objects
which were ment to be compuled with PIC:
.os  # single-source file for .so (i.e. with PIC)
.osm # multi-source file for .so (i.e. with PIC)

That way, we were able to build objects with the flags needed for the
respective final target (PIC vs. non-PIC).

This distinction is not available in svn anymore, i reverted it since
there was a requirement to support make-3.79* (which doesn't do the
right thing even with the current buildsystem, strictly speaking). Also
we did trip bugs in make-3.81-rc1. I tried to support the new
buildsystem, but finally went back to the "original" version so we could
ship the 1.1.x series with the know-to-work buildsystem.


To recap:

1) -fPIC is needed for _any_ object which will be used as a .so.
2) few cases to consider:
2a) SHARED_BUSYBOX (busybox uses libbusybox): lib*/*.c -fPIC, build .so
and don't build lib*/*.c into busybox but link against .so.
2b) non SHARED_BUSYBOX ( busybox doesn't use libbusybox): requires two
passes:
- lib*/*.c for objects used in busybox
- lib*/*.c -fPIC for objects used in libbusybox

While i agree that the new buildsystem may be stressing make(1) more
than the old one, i still feel that it was _rather_ simple without
completely rewriting what was there.

I'm convinced that it is pretty straight forward to completely rewrite
busybox' buildsystem to be small and easy to understand and to work with
GNU make-3.x. I'm currently not willing to invest the time needed to do
this and support it, though (i already spent too much "invain" time for
something that didn't work out to be generally supportable, so i will
not revisit this topic during the next couple of months, fwiw).

regards,
Bernhard
>
>Peter
>> 
>> the problem is that I don't know what was going on when this happend.
>> svn annotate command show me that the revision 14531 changed the
>> portion of the code:
>> 
>>  14531      aldot ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
>>  14531      aldot     CFLAGS_PIC:= $(call check_gcc,-fPIC,)
>>  14531      aldot     LIB_CFLAGS+=$(CFLAGS_PIC)
>>  14531      aldot endif
>> 
>> but r14531 is:
>> 
>>     r14531 | aldot | 2006-03-14 04:04:00 +0900 (Tue, 14 Mar 2006) | 2 lines
>> 
>>     - revert back to r14406
>> 
>> I've also checked the out put from svn log between 13793 (right before
>> r14406 for Rules.mak) and 14531 doesn't give me much info. r13638
>> might be it but i'm not sure.
>> --
>>      yashi



More information about the busybox mailing list