Build and app using compiler optimization flags

Hello there,

I would like to compile an application from source, using compiler optimizations for my specific CPU. Searching the web hasn’t proved very useful and though I’ve found some information I still have many blank spots.
e.g I read about some CFLAGS and CXXFLAGS. But I don’t know if it should be used before or after ./configure or perhaps is done during ? as in

 ./configure --export CFLAGS=" - 03 march ?? "

Moreover I don’t know what options to specify other than “O” which if I’m correct is the optimization level, and “march” which I believe allows me to specify my CPU architecture.

if someone could perhaps point me to some article or tutorial or even some technical manual on the gcc compiler flags I’d be forever indebted.
The application I’m trying to compile is Wine. My system has an AMD AthlonX2 7850, an Nvidia 6150 chipset, a 9800GT video card and 4GB ddr2-800c of RAM.

Thank you very much.

Hi,

On Tue, 17 Jan 2012, Hanzdersion wrote:

>
> Hello there,
>
> I would like to compile an application from source, using compiler
> optimizations for my specific CPU. Searching the web hasn’t proved very
> useful and though I’ve found some information I still have many blank
> spots.
> e.g I read about some CFLAGS and CXXFLAGS. But I don’t know if it
> should be used before or after ./configure or perhaps is done during ?
> as in
> Code:
> --------------------
> ./configure --export CFLAGS=" - 03 march ?? "
> --------------------
>
> Moreover I don’t know what options to specify other than “O” which if
> I’m correct is the optimization level, and “march” which I believe
> allows me to specify my CPU architecture.
>
> if someone could perhaps point me to some article or tutorial or even
> some technical manual on the gcc compiler flags I’d be forever
> indebted.
> The application I’m trying to compile is Wine. My system has an AMD
> AthlonX2 7850, an Nvidia 6150 chipset, a 9800GT video card and 4GB
> ddr2-800c of RAM.
>
> Thank you very much.
>
>
> –
> Hanzdersion
> ------------------------------------------------------------------------
> Hanzdersion’s Profile: http://forums.opensuse.org/member.php?userid=42712
> View this thread: http://forums.opensuse.org/showthread.php?t=471325
>
>

In my, limited, experience of compiling from source the makefile normally already specifies the -O2 optimisation flag, and I doubt you’re going to get any speed benefits from changing that.

The GCC website is an excellent source of information if you want to learn more about compiling with GCC and can be found at http://gcc.gnu.org/

Why do you even want to try to apply any of this to compiling Wine? Maybe it just doesn’t handle the Windows application you want to use it to run very well? If this is the case, you could try running the program in VirtualBox; dual boot or look at the Linux alternatives of this program.

Kind regards,
Barry D. Nichols

Hi
These are the standard ‘optflags’ added to rpm builds on the Open Build
Service


CFLAGS='-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables'

Just run man gcc and search for flags, it will explain them all…


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 12.1 (x86_64) Kernel 3.1.0-1.2-desktop
up 1 day 10:03, 8 users, load average: 0.03, 0.09, 0.11
CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU

Thank you for your answers,
I’ve read the documentation in both the gcc website and in the manuals installed with my system.

I discovered I needed to export the Variables first. I used teh following options before configuring:

export CFLAGS='-O3 -fomit-frame-pointer -march=k8 -mfpmath=both  -ffast-math -finline-functions -finline-functions-called-once'
export CXXFLAGS=$CFLAGS

Right now I’m compiling lets see how much of an improvement I get. :slight_smile:

thank you.