Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
KC14: Kernel CFLAGS
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Frequently Asked Questions
View previous topic :: View next topic  
Author Message
int1
Tux's lil' helper
Tux's lil' helper


Joined: 08 Nov 2002
Posts: 139

PostPosted: Mon Dec 02, 2002 11:00 pm    Post subject: KC14: Kernel CFLAGS Reply with quote

KC14. Why isn't the kernel being compiled with the CFLAGS that I set in /etc/make.conf?

The Linux kernel is the core of the Linux operating system, and because of this is independent of any one distribution. In order to compile cleanly and easily across many different systems, the Linux kernel includes its own unique compilation settings as defined within its Makefile. The Gentoo USE and CFLAGS are not used because the kernel has more unique compiliation setting requirements than most compiled applications.

That being said, if you still want to compile your kernel with a specific set of CFLAGS, there are a number of options to do so.

First, you can define the CFLAGS_KERNEL environment variable before you compile the kernel. While there are a number of ways to define these variables depending on the shell you use, one method is:
export CFLAGS_KERNEL="-Wall -Wstrict-prototypes -march=pentium3 -O3 -mmmx -msse -fomit-frame-pointer -falign-functions=4"

Second, you can edit the Makefile in the kernel source directory, changing the HOSTCFLAGS and CFLAGS line to match your settings.

For example, from my modified Makefile in /usr/src/linux from vanilla-sources-2.4.19 on my Pentium 3 laptop:
(line 20)
HOSTCFLAGS = -Wall -Wstrict-prototypes -march=pentium3 -O3 -mmmx -msse -fomit-frame-pointer -falign-functions=4
(line 91)
CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O3 -fno-strict-aliasing -fno-common -mmmx -msse -falign-functions=4

Finally, the latest gentoo-sources include a "gcc 3+" option in the processor configuration section. This allows for some refinement by allowing the kernel to set the -march option during kernel compile.

As a final note, you many not want to be too aggressive, since the kernel needs to be stable for you to be able to use your system!

(edited 13 Dec, cleaned up and added gcc 3+ option)


Last edited by int1 on Sat Dec 14, 2002 1:27 am; edited 1 time in total
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Sat Jan 25, 2003 6:58 pm    Post subject: Reply with quote

Feedback to KC14 Feedback.
_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Frequently Asked Questions 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