LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-27-2006, 11:34 PM   #1
Oxagast
Member
 
Registered: Aug 2003
Location: Mocksville, NC, USA
Distribution: Gentoo, Slackware.
Posts: 410

Rep: Reputation: 30
Gentoo, specify optimization for different compiles


Hi,
I use Gentoo 2006.0. I was wondering if anybody knew of a way to specify which programs used which processor optimization flags, without editing the make or dist files or anything specifically. For example, Firefox works better when compiled with the -Os flag, because it is large and takes a long time to start up, so if you make the code as small as possible, it tends to start up faster, but once it's started, its not using much processing power so thats not needed, so it would be optimized for startup time. But then theres other programs that I would want to be optimized for processing power, for various reasons, so say I would compile games, servers, etc with the -O3 flag (or anything else that would be specifically benefitial to that program, doesn't have to just be -Os and -O3, those are only examples) because I don't really care how long they take to start up, but once they're started I want them to run as fast as possible.

I know in the make.conf file you can specify which optimization flags to use, but I would like to make the modification stick for specific programs, so that say, when I do an update of all the programs on my system, it would still compile Firefox with -Os, and still compile Quake 3 with -O3, without me having to manually change it, and it would stick through version changes, and emerge syncs.

If anybody knows of a way to do this, if you could point me in the right dirrection, it would be much appriciated!

Thanks,
Marshall
 
Old 04-28-2006, 12:24 AM   #2
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495

Rep: Reputation: 48
The Gentoo handbook has a bit on this, but the following is more detailed: http://gentoo-wiki.com/USE_Flags

Edit: I guess that doesn't answer your question. You want to set CFLAGS, not USE flags. Apparently this was a Request For Enhancement sometime last year, but I don't know if it has been implemented yet.

Otherwise you could probably do

CFLAGS="-Os" emerge ....

or something similar for each package.

Last edited by maroonbaboon; 04-28-2006 at 01:09 AM.
 
Old 04-28-2006, 01:04 AM   #3
Oxagast
Member
 
Registered: Aug 2003
Location: Mocksville, NC, USA
Distribution: Gentoo, Slackware.
Posts: 410

Original Poster
Rep: Reputation: 30
That link looks like it is describing ways to specify USE flags for specific programs, but I think the optimization flags are differnet, in the make.conf file, USE flags are like:

USE="X gtk -kde"

... and whatever. Where as the compiler flags are set like:

CFLAGS="-march=pentium3 -O2 -pipe"

... or whatever.

I would like to be able to change the CFLAGS variable for invididual programs and make the changes stick, so everytime I compiled Firefox, no matter what version, or if I had emerge sync'd from the last time I set it, it would compile with -Os, where as, say, if I compiled Fluxbox, it would always compile with -O3, and I could just let the regular make.conf handle the ones I don't want to modify. Right now, after every update (where I emerge sync, emerge world -upD) it will compile everything as -O2, and then I have to go back and RECOMPILE things like Firefox that I want to be -Os, which is time consuming and annoying. I don't think/know if there is a way to do this via the USE flags stuff, but I didn't think there was. I thought it was a completely different thing. One has to do with options passed to ./configure (i think), and the other has to do with what flags are passed to gcc upon compliation.

The assumption that Gentoo makes is that the user wants to compile every program with the same compiler flags, where as this is not always desireable in cases such as my own. Firefox starts like 8 seconds faster if I compile with -Os verses -O3. But if I compile everything in -Os, some things that I dont care about starting up fast feel slugish in operation, or don't work right.
 
Old 04-28-2006, 01:30 AM   #4
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495

Rep: Reputation: 48
I realised I had not answered your question, but my edit crossed over with your second post. If you google for "package specific CFLAGS" you will know as much or more than me.

Interesting fact about Firefox startup time. I didn't realise the difference could be so large.
 
Old 04-28-2006, 08:27 AM   #5
Oxagast
Member
 
Registered: Aug 2003
Location: Mocksville, NC, USA
Distribution: Gentoo, Slackware.
Posts: 410

Original Poster
Rep: Reputation: 30
Yeah, well, the real bottleneck in program start time I have found is the hard drive speed. If you make the program smaller, the drive has less to read, and can get it much faster, and although the processor churns through the code a bit slower, the outcome is a pretty drastic reduction in start time, at the cost of a little runtime efficiency, but in firefox I find that hardly noticeable, it's not a very processor intensive application. But the start time is irrellivant in things that start once and run all the time, like deamons, servers, X, the base of window managers, games, etc, because once they're started you ususally just leave them running for days at a time and it is more important to have them respond fast while they are running. Overall I am just trying to customize my system into being a little more snappy by selecting where I can make tradeoffs from start time, memory useage, and processor useage. The gains are relative, and each user perfers a different thing, but that's what Gentoo is about, so I am supprised there is not an easier way to do this.

I was thinking I may code something of my own to do this, now that I'm thinking about it it doesn't seem that it would be too difficult. The code would get the programs that were going to be emerged (by doing an emerge -p on whatever you were emerging I suppose), and grep them out, and then read from a file where I specify CFLAGS for each program I want to have specific CFLAGS, and then emerge each program and dependancy individually, matching and setting the CFLAGS for that program alone, then going on and doing a another emerge for the next one with different CFLAGS. A front end to emerge/portage I guess you could say. I would elaborate, but I have class. I'll post it here if I start a project like that, it seems useful.

Marshall
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
g++ compiles but not gcc senthilpr_in Linux - Software 10 08-29-2005 02:20 PM
javac compiles all subdirectory tuananhbirm Linux - General 2 03-18-2005 03:58 PM
Compiles on bash, but not in KDevelop Cornholio Programming 3 03-09-2005 11:59 AM
kdevelop compiles but won't run. exodist Linux - Software 0 03-28-2004 07:31 PM
php does not compiles alaios Linux - Software 1 12-13-2003 08:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration