LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 10-27-2009, 09:12 AM   #1
xirtyllo
LQ Newbie
 
Registered: Oct 2009
Posts: 23

Rep: Reputation: 0
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
 
Old 10-27-2009, 10:25 AM   #2
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by xirtyllo View Post
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 ...
 
Old 10-27-2009, 11:03 AM   #3
xirtyllo
LQ Newbie
 
Registered: Oct 2009
Posts: 23

Original Poster
Rep: Reputation: 0
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...
 
Old 10-27-2009, 11:39 AM   #4
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by xirtyllo View Post
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 ), 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
 
Old 11-02-2009, 01:30 AM   #5
xirtyllo
LQ Newbie
 
Registered: Oct 2009
Posts: 23

Original Poster
Rep: Reputation: 0
Thx JohnGraham, it worked fine!
bythe way my kernel compiled with -O3 and works!
 
Old 11-03-2009, 03:27 AM   #6
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by xirtyllo View Post
Thx JohnGraham, it worked fine!
bythe way my kernel compiled with -O3 and works!
Nice one - I stand corrected

John G
 
  


Reply

Tags
cflags, compilation, kernel



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
Linux kernel API. Cflags needed? rvca Programming 2 02-28-2008 12:20 AM
Compiling w/ CFLAGS=-O2 matsko Linux - Software 6 05-03-2007 06:28 PM
Compiling Xmame - which CFlags in makefile? lets-eat-gary Linux - Games 2 03-12-2005 05:15 AM
CFLAGS to compile kernel frzburn Linux - Software 4 03-05-2005 05:42 AM
./configure, CFLAGS, checkinstall, and kernel arch type rgiggs Slackware 3 12-28-2004 01:39 AM

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

All times are GMT -5. The time now is 07:32 PM.

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