LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how do i pass my CFLAGS when compiling the Kernel? (https://www.linuxquestions.org/questions/linux-software-2/how-do-i-pass-my-cflags-when-compiling-the-kernel-764792/)

xirtyllo 10-27-2009 09:12 AM

how do i pass my CFLAGS when compiling the Kernel?
 
Hi,

I have my CFLAGS="-blabla" and CXXFLAGS="-blabla" setted in my .bashrc file, and i can see that the optimizations are applied every time i compile some application (i actually see them printed many times among the lines scrolling in the console..)

When i compile a Kernel, on the other hand, i have no feedback if the CFLAGS that are set in my .bashrc are taken in consideration or not...

what can you tell me about this..?

THX!
Tomm

JohnGraham 10-27-2009 10:25 AM

Quote:

Originally Posted by xirtyllo (Post 3734112)
Hi,

I have my CFLAGS="-blabla" and CXXFLAGS="-blabla" setted in my .bashrc file, and i can see that the optimizations are applied every time i compile some application (i actually see them printed many times among the lines scrolling in the console..)

When i compile a Kernel, on the other hand, i have no feedback if the CFLAGS that are set in my .bashrc are taken in consideration or not...

what can you tell me about this..?

THX!
Tomm

You can see the actual commands that are being run by setting V=1 on the command-line to make, e.g.:

Code:

make V=1 ...

xirtyllo 10-27-2009 11:03 AM

THanks!!
great tip, i'll try it soon!

but by the way, is .bashrc the right way to set the CFLAGS (i use Slackware 13) or are there better methods?

Searching on google i saw someone putting the CFLAGS argument just after the make bzImage command...

JohnGraham 10-27-2009 11:39 AM

Quote:

Originally Posted by xirtyllo (Post 3734212)
THanks!!
great tip, i'll try it soon!

but by the way, is .bashrc the right way to set the CFLAGS (i use Slackware 13) or are there better methods?

Searching on google i saw someone putting the CFLAGS argument just after the make bzImage command...

Yeah, putting CFLAGS on the make command-line works in the same way as the command I showed earlier - e.g:

Code:

export CFLAGS='-flag'
make

is the same as:

Code:

make CFLAGS='-flag'
...BUT this is only because of the way the `make' program parses its arguments - don't expect that to work for other programs.

As for if there are 'better' methods, I personally prefer to set CFLAGS on the make command-line, or manually in the environment before a particular compilation, and not in any configuration files. This is simply because I might forget about it and have it infest a compilation I don't want to.

Oh, and just in case you're wanting to compile the kernel with `-O3' (I'm getting that feeling from you :p), you should definitely make sure you can compile a kernel AND get it working without setting any `-O*' CFLAGS - the Linux kernel is a big system, and if I remember correctly, compiling with `-O3' is basically guaranteed to break it. By all means try it, but make sure you can do it without -O3 first, so if it does fail to build/run, you know why.

John G

xirtyllo 11-02-2009 01:30 AM

Thx JohnGraham, it worked fine!
bythe way my kernel compiled with -O3 and works!

JohnGraham 11-03-2009 03:27 AM

Quote:

Originally Posted by xirtyllo (Post 3740862)
Thx JohnGraham, it worked fine!
bythe way my kernel compiled with -O3 and works!

Nice one - I stand corrected :p

John G


All times are GMT -5. The time now is 10:50 PM.