Difference between revisions of "Gentoo compile flags"

From ThinkWiki
Jump to: navigation, search
(Which flags to use)
 
(7 intermediate revisions by 5 users not shown)
Line 4: Line 4:
 
<div style="margin: 0; margin-right:10px; border: 1px solid #dfdfdf; padding: 0em 1em 1em 1em; background-color:#F8F8FF; align:right;">
 
<div style="margin: 0; margin-right:10px; border: 1px solid #dfdfdf; padding: 0em 1em 1em 1em; background-color:#F8F8FF; align:right;">
 
=== Gentoo compile flags ===
 
=== Gentoo compile flags ===
This page gives an introduction to Gentoo compile flags.
+
This page gives an introduction to {{Gentoo}} compile flags.
 
</div>
 
</div>
 
|}
 
|}
Line 16: Line 16:
  
 
=== Which flags to use ===
 
=== Which flags to use ===
In order to adjust USE correctly, you have to find out, which instruction set extensions your processor supports. You can use google for this, or look at /proc/cpuinfo. The Pentium M instruction set is compatible to a Pentium 4 and supports mmx and sse extensions, so your make.conf should contain something like this:
+
Gentoo has a [http://en.gentoo-wiki.com/wiki/Safe_Cflags separate wiki page] for deciding which CFLAGS are right for you. Use your model's page here at ThinkWiki to figure out your processor family, then look it up on that page for the proper CFLAGS. That page may assume that you're using GCC version 4.2, but this is the case on all reasonably modern systems.
  
USE="mmx mmx2 sse sse2"
+
Additionally, it may help to include ''some'' of the following USE flags:
CFLAGS="-O2 -march=pentium4 -pipe -fomit-frame-pointer"
 
  
You might also use -O3, but it may cause crashes in your programs if you optimize too much.
+
USE="mmx sse sse2 ssse3"
Independently of the CPU it's also a good idea to tell portage which libraries to use. If you leave away all the libraries you don't need, you can save compile time, get a smaller binary size and faster programs.
 
  
For instance, if you know you don't use Gnome and don't need java support in you binaries, but you want to use KDE, your make.conf might contain
+
Run the command "cat /proc/cpuinfo" and look through the "flags" section to see which your CPU supports; only include those in your global USE flag.
USE="mmx mmx2 sse sse2 qt kde -gnome -java"
 
If you want gnome support in your binaries at any later time, you just have to edit make.conf an run "emerge --newuse world" (this will take some time though).
 
  
 
=== Example files ===
 
=== Example files ===
These are the make.conf and package.use files I use for my T40P:
+
These are the make.conf and package.use files used for a T40P:
 
*make.conf
 
*make.conf
 
  USE="X mmx mmx2 sse sse2 qt kde -gpm -gtk -gtk2 -gnome -arts -alsa -cups -java -esd -v4l -v4l1 -samba -ipv6 -directfb -lirc -svga"
 
  USE="X mmx mmx2 sse sse2 qt kde -gpm -gtk -gtk2 -gnome -arts -alsa -cups -java -esd -v4l -v4l1 -samba -ipv6 -directfb -lirc -svga"
Line 43: Line 39:
 
  media-libs/xine-lib dvd
 
  media-libs/xine-lib dvd
  
 +
This is the make.conf file used for a 64-bit T61 (with Intel X3100 graphics):
 +
*make.conf
 +
CFLAGS="-march=nocona -O2 -pipe"
 +
CXXFLAGS="${CFLAGS}"
 +
MAKEOPTS="-j5"
 +
CHOST="x86_64-pc-linux-gnu"
 +
VIDEO_CARDS="vesa vga i810"
 +
ALSA_CARDS="hda-intel"
 +
INPUT_DEVICES="keyboard mouse evdev synaptics"
  
 
=== Other portage features ===
 
=== Other portage features ===
Line 48: Line 53:
  
 
|}
 
|}
 
[[Category:Gentoo]]
 

Latest revision as of 10:18, 24 July 2011

Gentoo

Gentoo compile flags

This page gives an introduction to Gentoo compile flags.

About compile flags in Gentoo

One strength of Gentoo is the ability to use global flags for code optimizing. This is done through the file /etc/make.conf (man page). Since the Pentium Mobile (Centrino) used in some Thinkpads supports the mmx and sse extensions of the insturuction set, using compile flags can speedup programs quite a bit. To use optimized code, you have to adjust the USE (Gentoo Handbook) variable, which contains the libraries and extensions you want to use and the CFLAGS variable, which contains compiler flags, that portage passes along to gcc.

If you want to set specific flags for only one package, you can also use the file /etc/portage/package.use instead of the USE variable in make.conf.

Which flags to use

Gentoo has a separate wiki page for deciding which CFLAGS are right for you. Use your model's page here at ThinkWiki to figure out your processor family, then look it up on that page for the proper CFLAGS. That page may assume that you're using GCC version 4.2, but this is the case on all reasonably modern systems.

Additionally, it may help to include some of the following USE flags:

USE="mmx sse sse2 ssse3"

Run the command "cat /proc/cpuinfo" and look through the "flags" section to see which your CPU supports; only include those in your global USE flag.

Example files

These are the make.conf and package.use files used for a T40P:

  • make.conf
USE="X mmx mmx2 sse sse2 qt kde -gpm -gtk -gtk2 -gnome -arts -alsa -cups -java -esd -v4l -v4l1 -samba -ipv6 -directfb -lirc -svga"
CFLAGS="-O2 -march=pentium4 -pipe -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"
MAKEOPTS="-j2"
  • package.use
sys-libs/glibc userlocales
app-laptop/tpb xosd
media-video/mplayer dvd xanim divx4linux network xvid live
media-libs/xine-lib dvd

This is the make.conf file used for a 64-bit T61 (with Intel X3100 graphics):

  • make.conf
CFLAGS="-march=nocona -O2 -pipe"
CXXFLAGS="${CFLAGS}"
MAKEOPTS="-j5"
CHOST="x86_64-pc-linux-gnu"
VIDEO_CARDS="vesa vga i810"
ALSA_CARDS="hda-intel" 
INPUT_DEVICES="keyboard mouse evdev synaptics"

Other portage features

There are lots of other great features in portage (the Gentoo package managing system). If you want to use Gentoo, you should read the docs on gentoo.org and the man pages of portage and make.conf.