Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
I need some help with the CFLAGS/CXXFLAGS
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
HimTortons
n00b
n00b


Joined: 13 Sep 2015
Posts: 32

PostPosted: Sun Sep 13, 2015 6:47 pm    Post subject: I need some help with the CFLAGS/CXXFLAGS Reply with quote

So I'm still kind of a noob with Gentoo and I'm just installing inside a VM and I've gotten to the point in the Handbook where you first modify the make.conf file. Now I've read a little about the CFLAGS and CXXFLAGS and how you need it tell the computer what CPU it's supposed to optimize and compile for and what optimization level (if I got that whole thing right). However I don't really understand how to configure and put in the flags. Could someone show me how to do this or send me a link to a good explanation? In this case I'm using an i5 4690K if anyone is wondering
Back to top
View user's profile Send private message
kikko
Apprentice
Apprentice


Joined: 29 Apr 2014
Posts: 260
Location: Milan, IT

PostPosted: Sun Sep 13, 2015 7:30 pm    Post subject: Reply with quote

Hi HimTortons and welcome to Gentoo! :)

CFLAGS and CXXFLAGS variables are "options" passed to the compiler (GCC) in order to tweak the compilation process. Anyway, there is (generally) no need for adding super-special flags, because all compilation parameters are included with the sources

Suggested flags are:
Code:
 -march=XXXX
where XXXX is your processor family; you can have GCC working for you by putting -march=native
Code:
-O2
sets the optimization level; level 2 is generally suitable for most users, and you can find discussion about this in the forum
Code:
-pipe
makes GCC compile files in ram instead of parking them in the disk. Suggested if your device has RAM > 256M :wink:

You can find a proper guide in https://wiki.gentoo.org/wiki/CFLAGS, but generally the following are perfectly suitable for beginning:
Code:
CFLAGS="-march=core2 -O2 -pipe"
CXXFLAGS="${CFLAGS}"
Back to top
View user's profile Send private message
Buffoon
Veteran
Veteran


Joined: 17 Jun 2015
Posts: 1074
Location: EU or US

PostPosted: Sun Sep 13, 2015 7:45 pm    Post subject: Reply with quote

In particular inside of a virtual machine stay with -march=native, unless you have a good reason not to.
Back to top
View user's profile Send private message
HimTortons
n00b
n00b


Joined: 13 Sep 2015
Posts: 32

PostPosted: Mon Sep 14, 2015 4:22 pm    Post subject: Reply with quote

kikko wrote:
Hi HimTortons and welcome to Gentoo! :)

CFLAGS and CXXFLAGS variables are "options" passed to the compiler (GCC) in order to tweak the compilation process. Anyway, there is (generally) no need for adding super-special flags, because all compilation parameters are included with the sources

Suggested flags are:
Code:
 -march=XXXX
where XXXX is your processor family; you can have GCC working for you by putting -march=native
Code:
-O2
sets the optimization level; level 2 is generally suitable for most users, and you can find discussion about this in the forum
Code:
-pipe
makes GCC compile files in ram instead of parking them in the disk. Suggested if your device has RAM > 256M :wink:

You can find a proper guide in https://wiki.gentoo.org/wiki/CFLAGS, but generally the following are perfectly suitable for beginning:
Code:
CFLAGS="-march=core2 -O2 -pipe"
CXXFLAGS="${CFLAGS}"


So can just put in that code into the file using nano (with march=native because I'm on a VM) or do I need to make some other modifications?
Back to top
View user's profile Send private message
freke
Guru
Guru


Joined: 23 Jan 2003
Posts: 434
Location: Somewhere in Denmark

PostPosted: Mon Sep 14, 2015 6:44 pm    Post subject: Reply with quote

HimTortons wrote:

You can find a proper guide in https://wiki.gentoo.org/wiki/CFLAGS, but generally the following are perfectly suitable for beginning:
Code:
CFLAGS="-march=core2 -O2 -pipe"
CXXFLAGS="${CFLAGS}"


So can just put in that code into the file using nano (with march=native because I'm on a VM) or do I need to make some other modifications?[/quote]

That's what I'd use for a 'safe' starter (again as you said - with -march=native instead, yes :) - also that's a capital 'o' - sometime seen it mixed up with a zero - which doesn't do you any good :D)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo 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