LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Closed Thread
 
LinkBack Search this Thread
Old 02-01-2006, 05:20 PM   #1
brodo
Member
 
Registered: Jan 2004
Location: Poland, Poznan
Distribution: Slackware current
Posts: 168

Rep: Reputation: 16
Passing gcc flags into custom kernel


How to inject "-Os -march=pentium3 -fomit-frame-pointer -pipe" gcc flags settings into kernel being custom compiled ?

Do I need to edit every Makefile in /usr/src/linux*** ?

I do it while compiling other software just by inserting these flags at CFLAGS declarations.
 
Old 02-01-2006, 07:35 PM   #2
mdarby
Member
 
Registered: Nov 2004
Location: Columbus, Ohio
Distribution: Slackware-Current / Debian
Posts: 795

Rep: Reputation: 30
Code:
export CFLAGS="-Os -march=pentium3 -fomit-frame-pointer -pipe"
export CXXFLAGS="-Os -march=pentium3 -fomit-frame-pointer -pipe"
 
Old 02-02-2006, 03:33 AM   #3
brodo
Member
 
Registered: Jan 2004
Location: Poland, Poznan
Distribution: Slackware current
Posts: 168

Original Poster
Rep: Reputation: 16
But...

Is it enough to run from bash these 2 export commands before running "make" ?

What if there will be another CFLAGS= declaration inside Makefile(s) processed later ? Will my hand declaraion be overwritten ?
 
Old 02-02-2006, 05:52 AM   #4
mdarby
Member
 
Registered: Nov 2004
Location: Columbus, Ohio
Distribution: Slackware-Current / Debian
Posts: 795

Rep: Reputation: 30
The above export commands will append what's already in the makefile, IIRC.
I have the statements in my ~/.bashrc with no ill effects...
 
Old 02-02-2006, 07:59 AM   #5
KMcD
Member
 
Registered: Jun 2003
Location: Dublin, Ireland
Distribution: Slack -- current
Posts: 354

Rep: Reputation: 30
I have flags like the above in my .profile (and .bashrc) and they are over-ridden by the Makefile. You'll have to edit the Makefile I believe, at least that's how I changed it.

(On kernel 2.6.x there is the option for -Os, enabling that will do.)
 
Old 03-04-2012, 09:09 AM   #6
cnd
LQ Newbie
 
Registered: May 2005
Posts: 8

Rep: Reputation: 0
env vars didn't work on CentOS 6.2

I had to manually edit the 2 makefiles in this folder:-

/usr/src/redhat/BUILD/kernel-2.6.32/linux-2.6.32.x86_64/arch/x86

to get the thing to pick up those changes, prior to building like this:-

cd /usr/src/redhat/SPECS/;rpmbuild -bb --target `uname -m` kernel.spec
 
Old 03-04-2012, 09:32 AM   #7
the3dfxdude
Member
 
Registered: May 2007
Posts: 304

Rep: Reputation: 66
Set the following config options. It's better to do it this way, so you can keep a record of the config file. There's no reason to edit the Makefiles, or set CC on your own.

General setup -> Check "Optimize for size" (CONFIG_CC_OPTIMIZE_FOR_SIZE)
Processor type and features -> Processor family -> Check "Pentium-III/Celeron(Coppermine)/Xeon" (CONFIG_MPENTIUMIII)
Kernel hacking -> Uncheck "Compile the kernel with frame pointers" (CONFIG_FRAME_POINTER=n)

-pipe doesn't affect the quality of the compiled code.
 
Old 03-05-2012, 03:17 AM   #8
narz
Member
 
Registered: May 2007
Location: US
Distribution: slackware
Posts: 184

Rep: Reputation: 35
Quote:
Originally Posted by cnd View Post
I had to manually edit the 2 makefiles in this folder:-

/usr/src/redhat/BUILD/kernel-2.6.32/linux-2.6.32.x86_64/arch/x86

to get the thing to pick up those changes, prior to building like this:-

cd /usr/src/redhat/SPECS/;rpmbuild -bb --target `uname -m` kernel.spec
You bumped a 6 year old Slackware thread to give Redhat advice?
 
1 members found this post helpful.
Old 03-05-2012, 04:03 AM   #9
cnd
LQ Newbie
 
Registered: May 2005
Posts: 8

Rep: Reputation: 0
@narz Why are you wasting everyones time with your stupid comment?

I obviously had my reasons, and you'd have to be pretty dim not to figure it out: This is the top google result for this issue, and the advice doesn't work for modern distros.

If you actually want to optimize your kernel for your running CPU, my response now tells people how to do that, which is to mod the -mtune=native parm into those 2 makefiles.

Do not reply. Go on. I dare you. Prove you're not a troll, and try not to reply.
 
Old 03-05-2012, 05:10 AM   #10
55020
Member
 
Registered: Sep 2009
Location: Yorks. W.R. 167397
Distribution: Slackware
Posts: 271
Blog Entries: 4

Rep: Reputation: 256Reputation: 256Reputation: 256
Quote:
Originally Posted by cnd View Post
This is the top google result for this issue, and the advice doesn't work for modern distros.
And, uh, what proportion of modern distros does your advice work for? the3dfxdude's advice works properly, for all distros, and the fact that the options are right there in the standard kernel menus for all to see is why nobody worries about this any more.

Allocation of stupidity is left as an exercise for the reader.
 
1 members found this post helpful.
Old 03-05-2012, 06:39 AM   #11
narz
Member
 
Registered: May 2007
Location: US
Distribution: slackware
Posts: 184

Rep: Reputation: 35
Quote:
Originally Posted by cnd View Post
@narz Why are you wasting everyones time with your stupid comment?

I obviously had my reasons, and you'd have to be pretty dim not to figure it out: This is the top google result for this issue, and the advice doesn't work for modern distros.

If you actually want to optimize your kernel for your running CPU, my response now tells people how to do that, which is to mod the -mtune=native parm into those 2 makefiles.

Do not reply. Go on. I dare you. Prove you're not a troll, and try not to reply.
Wow you're serious?? Like 55020 mentioned, the3dfxdude tells you exactly how to do all this on modern distros. You don't have to edit any makefiles. Try and relax.

Last edited by narz; 03-05-2012 at 06:41 AM.
 
Old 03-05-2012, 10:09 AM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,532
Blog Entries: 51

Rep: Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601
Now now, there there. All quiet again... (Closed)
 
  


Closed Thread


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Qt tool for gcc flags Ephracis Programming 4 01-15-2006 01:28 AM
passing bootable flags to init at boot ? Infernal211283 Linux - Newbie 3 12-18-2005 01:44 PM
GCC 3.4/3.3 Optimization Flags monohouse Linux - Software 0 10-28-2004 10:48 AM
Custom optimisation flags for building QT ugenn Linux - Software 0 04-27-2004 08:39 AM
mplayer - wrong gcc flags crashmeister Linux - Software 2 11-19-2002 06:25 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration