2011/4/3 Ian Lance Taylor <iant@xxxxxxxxxx>: > parttor@xxxxxxxxx writes: > >> As cc1plus cc1 lto1 using the same big static lib libbackend.a, so >> I patched it to use a shared lib in order to save space. >> I pached by the attachment and set CFLAGS="${CFLAGS} -fPIC" >> CXXFLAGS="${CXXFLAGS} -fPIC" before configure. >> It works well after patched and size reduced. But it works much slower >> than using libbackend.a , spend two times time. >> Can I keep speed while using shared lib? > > I'm kind of surprised that it is twice as slow. But it is true that on > an ELF system shared libraries are always slower than static libraries, > though the slowdown is normally more on the order of 5%. > > Disk prices have fallen so far that very few people are short on space > these days. At least, they aren't short on space for the compiler which > normally lives on a regular computer rather than, say, a phone. Does > this really matter for you? I'm trying to make a linux disco, a living version(livecd liveusb) and a vmware version ready. http://smartutils.sf.net/livecd.html I want to reduce it's size by removing "duplicate data", such as moving static lib to shared lib. > It's a characteristic of ELF. In a shared library, all calls to > globally visible functions have to go through the PLT. All references > to global variables have to go through the GOT. Some slowdown is > inevitable. You can adjust somewhat by using symbol visibility, but > that would be somewhat painful in the gcc source code base, and the gain > would be minimal. Maybe I have to give up the "moving to shared lib work" on gcc.