Results 1 to 3 of 3

Thread: Geeky stuff Part 1: Optimizing your compiler

  1. #1
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default Geeky stuff Part 1: Optimizing your compiler

    Here I am gonna shows some cool flags to optimize your compiled applications for linux in faqs form.
    Why compile applications?
    To harvest all power of your cpu you need to compile your own package. Binaries distributed by applications like apache , mplayer , mysql, e.t.c. are not optimized for your cpu.
    I have generally written here only safe configurations.



    Run the command
    cat /proc/cpuinfo


    open /etc/make.conf
    Scroll down to this:

    Cflags :

    march options
    If you don't what is your cpu. Then use this

    CFLAGS="-march=native
    GCC will try to use flags appropriate for you.
    If your are using core2duo or above then use this:
    CFLAGS="-march=core2

    Os options
    O ( O for orange not 0 zero)
    They vary from 0 , O1 , O2 , O3 , Os
    I recommend using 02 . It determine the level of optimization. Using higher might break codes So they are not recommended. Using O = no optimization. 0s = 02 optimization with smaller binaries.

    cat /proc/cpuinfo | grep flag
    This command print additional flags available for use as C flags or CXX flags ( in layman terms c & c++). If you don't give out | grep flag it will print whole info about your cpu. Flags are switches for optimizing your gcc compiled codes.
    Some of the flags you can use from among them are :
    -msse, -msse2, -msse3, -msse4 , -mssse3,-mmmx, -m3dnow
    pni= sse3
    I have put -m as it should be . So now your Cflags
    CFLAGS="-march=core2 -O2 -pipe -msse -msse2 -msse3 -mssse3 -mmmx"
    ( depending upon your arch)

    -fomit-frame-pointer & -pipe
    Former decreases the code size & latter increases the speed of compiling.

    So now your Cflags should loook like this:
    CFLAGS="-march=core2 -O2 -pipe -msse -msse2 -msse3 -mssse3 -mmmx -fomit-frame-pointer"

    CXX flags
    They are same as Cflags.
    CXXFLAGS="${CFLAGS}"

    Scroll down to
    MAKEOPTS options:

    They are -j2 , -j3 ,.... They should be one more than your total number of cores. If you have core2duo then
    MAKEOPTS="-j3"
    If you have icore 7 use this ( as it has 8 cores considering 4 virtuals + 4 real)
    MAKEOPTS="-j7"

    Next time we are gonna compile something. Bye.

    PS: Don't plagiarize.

    For more reference see GCC manual.
    Last edited by Luke Skywalker; 02-03-10 at 10:42 PM. Reason: typo
    History is on the move,my friends.Those who cannot keep up will be left behind, to watch from distance.And those who stand in its way will not watch at all.
    To view links or images in signatures your post count must be 100 or greater. You currently have 0 posts.

    People are going to tell stories about me none of which change who I really am.

  2. #2
    Silver Member
    Join Date
    Dec 2008
    Liked
    0 times
    Posts
    370

    Default

    I know (hope most linux users know) that the kernel is not optimised for for anybody's system. If we compile the same on our system it will perform better than the pre-compiled one coming in the form of ISO or physical optical disk, etc. I have compiled linux few times to configure according to my hardware (for not including unnecessary kernel modules). But I don't feel this is recommended for everybody. Those who are familiar and are power users can do this. Others need not follow this (some resource will be wasted). Nowadays ther are people who use computer regularly but don't know about the unnecessary services working and eating up resources behind the scene still are satisfied with their need from the system.

    This is what the option available to every linux (open source) user which we can never dream in M$ world.

  3. #3
    Jedi knight Luke Skywalker's Avatar
    Join Date
    Jul 2009
    Age
    23
    Liked
    0 times
    Posts
    2,175

    Default

    This article change your environment variables for all things you compile.It is quite safe easy to compile your kernel & in some distro it is a default. You have to compile everything. I don't why ubuntu is warning against it. ( I have given them a new name duh-buntu). You don't need intrafs & initrd.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 02-05-10, 09:10 PM
  2. Replies: 0
    Last Post: 02-04-10, 10:26 PM