LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 02-17-2005, 09:25 PM   #1
frzburn
Member
 
Registered: Feb 2004
Location: Canada
Distribution: FreeBSD
Posts: 38

Rep: Reputation: 15
CFLAGS to compile kernel


HI, I rebuild my system on Slackware 10 yesterday, and installed the 2.4.29 kernel from CURRENT tree. I recompile the kernel to suits my needs, and configure my system, etc, etc...
So, I put custom CFLAGS at the end of my /etc/profile to optimize everithing I compile. But, I noticed that those CFLAGS weren't used when compiling the kernel. I looked in the Makefile of ther kernel source, and I found that CFLAGS where defined, ignoring those I put in /etc/profile.

So, my question is: Is there a problem using my custom CFLAGS + those in the kernel Makefile, or should I let the defaults CFLAGS? (Because compiling the kernel with different CFLAGS may cause some errors...)

My CFLAGS in /etc/profile are:
CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer"

and in the kernel Makefile:
CFLAGS := -D__KERNEL__ -I$(HPATH) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common

So, what do you think about it?

Last edited by frzburn; 02-17-2005 at 09:29 PM.
 
Old 02-17-2005, 10:22 PM   #2
frzburn
Member
 
Registered: Feb 2004
Location: Canada
Distribution: FreeBSD
Posts: 38

Original Poster
Rep: Reputation: 15
OK, couldn't wait any longer, so I just tried it
So, here's what I have done:
in /usr/src/linux/Makefile, I added '-march=athlon-xp' and changed '-02' for '-03' to HOSTCFLAGS so it looks like:
Code:
HOSTCFLAGS	= -Wall -Wstrict-prototypes -march=athlon-xp -pipe -O3 -fomit-frame-pointer
I did the same changes to CFLAGS, so I now looks like:
Code:
CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -march=athlon-xp -Wno-trigraphs -O3 \
	  -fno-strict-aliasing -fno-common
Now, the compiled kernel works perfectly, but I didn't check the speed gain (if there is any).
The resulting bzImage is bigger (for the same config file) than the old one, as expected.

That's all. Sorry for asking a question I could answer myself!!
But maybe it'll be useful to someone...
 
Old 02-18-2005, 05:30 AM   #3
__J
Senior Member
 
Registered: Dec 2004
Distribution: Slackware, ROCK
Posts: 1,973

Rep: Reputation: 46
might have to export it. if you do it on the command line:

export CFLAGS=" -march-athlon-xp etc..."

it should show up ( I always leave the kernel alone.... not sure what a -O3 will do ( keep in mind with -O3 it inherits all of -O1 and -O2 levels plus some extra, I'd have to look it up but -fomit-frame-pointer might already be defined in -O3)). you have to leave the rest of the CFLAGS in the makefile intact.
 
Old 02-18-2005, 08:21 AM   #4
frzburn
Member
 
Registered: Feb 2004
Location: Canada
Distribution: FreeBSD
Posts: 38

Original Poster
Rep: Reputation: 15
I did export my CLFAGS. Here's my /etc/profile section where I set them:
Code:
# Setting compile flags for optimization
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer"
CXXFLAGS="$CFLAGS"
export CHOST CFLAGS CXXFLAGS
But still, when I compiled the kernel it just ignored it.
Whatever, I changed them in the Makefile, and everything's working fine now...
 
Old 03-05-2005, 05:42 AM   #5
denning
Member
 
Registered: Jan 2004
Location: Oxford
Distribution: Slackware, Debian, Fedora, FreeBSD, NetBSD
Posts: 150

Rep: Reputation: 15
wicked!! That is cool. I am trying to speed things up by compiling stuff with CFLAGS instead of using binary packages. Now I can even optimize the kernel.

Did you notice any speed improvements?
 
  


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
cflags exodist Linux - Software 2 01-14-2005 07:44 PM
./configure, CFLAGS, checkinstall, and kernel arch type rgiggs Slackware 3 12-28-2004 01:39 AM
Using CFLAGS and other options vexer Linux From Scratch 7 08-18-2004 09:04 AM
CFLAGS library -l and -i abs Programming 2 04-11-2004 10:03 PM
how to unset cflags? shanenin Linux - Software 4 01-25-2004 09:36 PM

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

All times are GMT -5. The time now is 08:35 AM.

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