Re: Shared library linking with external static libraries.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Ian Lance Taylor-3 wrote:
> 
> FloofLeBo <bluswedshooz@xxxxxxxx> writes:
> 
>> And now I'll go to the dead-stripping. How can I be sure that unused code
>> from the external and internal static libraries is not shipped with the
>> shared object ?
>>
>> I tried naively to add the "-Wl,-dead-strip" to the gcc -shared command,
>> but
>> this gave me the warning:
>>
>> /usr/bin/ld: warning: cannot find entry symbol ad-strip; defaulting to
>> 0000000000071f00
>>
>> What would gcc need to only pull needed code for the static libs ?
> 
> Neither the GNU linker nor gold support an option -dead-strip.  That is
> two options: -d, and -e ad-strip.  Hence the warning.  They both support
> an option --gc-sections, which tells them to discard sections that are
> not needed.  To use that to full effect, you need to compile with
> -ffunction-sections -fdata-sections.  So this will look like
> 
> gcc -ffunction-sections -fdata-sections -c file.cc
> gcc -o file file.o -Wl,--gc-sections
> 
> Ian
> 
> 


Ok, I adapted all my projects makefiles, and recompiled my external static
libs with -ffunction-sections and -fdata-sections. The shared object did
drop from 4.3MB to 3.0MB. Nice!

Nevertheles a new problem appeared. One of the external libraries i use now
causes ld to segfault. How can  I debug that ? It's one of the biggest
external libs I use, and I think I use < 20% of it ...

Again, thanks for your help & kind regards
Florent.
-- 
View this message in context: http://old.nabble.com/Shared-library-linking-with-external-static-libraries.-tp29941925p29951444.html
Sent from the gcc - Help mailing list archive at Nabble.com.



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux