Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Speeding up your install
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Duplicate Threads
View previous topic :: View next topic  
Author Message
Lokheed
Veteran
Veteran


Joined: 12 Jul 2004
Posts: 1295
Location: /usr/src/linux

PostPosted: Thu Mar 31, 2005 6:40 am    Post subject: Speeding up your install Reply with quote

I was sent a link to this article from osnew.com today. Curious but warry as it sounds just to good to be true...

Quote:

Today I thought about how I can make my very own application to only link against those libraries that it really requires and not those it get provided by PKG-CONFIG.

Problem-case:

When we use pkgconfig within our programs which of course makes sense, we also see that other libraries from other packages are being processed to our *_LIBS variables. So we end up in linking a lot of libraries to our application which we really do not need and which also causes (so I assume) a lot of overhead. After thinking for a while I looked some programs up by using:

readelf -d /usr/local/bin/gnome-terminal |grep NEEDED | wc -l

And saw that it was requiring over 52 libraries. I then recompiled gnome-terminal with

export CFLAGS = "-Os -s -Wl,--as-needed"

Pay attention to the --as-needed and the resulting binary required just 21 libraries afterwards instead of the 52 before because it only linked those really required to the final executable. I continued this with vte and saw that it required 29 libraries initially but after the --as-needed flag it went down to 7 libraries.

Now imagine this for the entire GNOME desktop or the entire KDE desktop and also package management systems which will reduce dependency tracking a lot. The problem with this method is that you surely don't keep track of API compatibility but a good package management system will certainly make sure that the packages packed belong to a certain desktop version.


What do you guys think?
_________________
You're not afraid of the dark are you?
Back to top
View user's profile Send private message
kimchi_sg
Advocate
Advocate


Joined: 26 Nov 2004
Posts: 2915
Location: Singapore

PostPosted: Thu Mar 31, 2005 2:08 pm    Post subject: Reply with quote

Hmm... I think a better way would be to set USE="static" in make.conf and then do an emerge -e world.

"Look ma, I don't need to link to any libraries!" :P
_________________
Murphy's Law of Gentoo installation: If a compile can fail, it will.

MacGillicuddy's Corollary: At the most inopportune time.

Please search and read the FAQs before posting.
Back to top
View user's profile Send private message
mikegpitt
Advocate
Advocate


Joined: 22 May 2004
Posts: 3221

PostPosted: Sun Apr 03, 2005 6:11 pm    Post subject: Reply with quote

Some things look screwy. The example above:
Quote:
export CFLAGS = "-Os -s -Wl,--as-needed"

is combining CFLAGS and LDFLAGS in the same line. This most likely will screw something up.


Quote:
Hmm... I think a better way would be to set USE="static" in make.conf and then do an emerge -e world.

"Look ma, I don't need to link to any libraries!" Razz

You probably are kidding, but this isn't a great solution either, becasue the binary size will increase drastically. You may get some better runtime performance, but the load time will be increased. Most GUI apps wait for you to do something so IMHO initial loadtime is probably where you will observe the largest performance gain.
Back to top
View user's profile Send private message
ecoffey
Tux's lil' helper
Tux's lil' helper


Joined: 16 Jun 2004
Posts: 122
Location: Colorado

PostPosted: Sun Apr 03, 2005 9:49 pm    Post subject: Reply with quote

So wait. The default behaviour for gcc is to link in EVERYTHING you give it? Are you sure?

UPDATE: Holy cr*p it does!

I tried this simple hello world program:

Code:

#include <stdio.h>

int main()
{
    printf("Hello World\n");
}


compiled it with 'gcc -o hello hello.c -lX11' and gcc compiled without complaint

here is the output from 'readelf -d ./hello | grep NEEDED':

Code:
 
0x00000001 (NEEDED)                     Shared library: [libX11.so.6]
0x00000001 (NEEDED)                     Shared library: [libc.so.6]


Thats really weird that gcc doesn't automatically check to see what is needed. I thought it did, so I ran that little test, but yeah. Goofy to the max.
Back to top
View user's profile Send private message
Maedhros
Bodhisattva
Bodhisattva


Joined: 14 Apr 2004
Posts: 5511
Location: Durham, UK

PostPosted: Sun Apr 03, 2005 9:51 pm    Post subject: Reply with quote

Please follow up here: https://forums.gentoo.org/viewtopic-t-316445.html

Moved from Gentoo Chat.
_________________
No-one's more important than the earthworm.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Duplicate Threads All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum