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? |
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 Code:
CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -march=athlon-xp -Wno-trigraphs -O3 \ 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... |
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. |
I did export my CLFAGS. Here's my /etc/profile section where I set them:
Code:
# Setting compile flags for optimization Whatever, I changed them in the Makefile, and everything's working fine now... :) |
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? |
All times are GMT -5. The time now is 02:18 PM. |