You are not logged in.

#1 2009-04-20 02:40:47

Raccoon1400
Member
From: Ontario, Canada
Registered: 2008-04-14
Posts: 853

optimize build

how would I optimize the build with makepkg? I was told that there was the -O3 option for gcc, but how can this be used in a pkgbuild?

What do these optimization flags gain me anyways?


Fustrated Windows users have two options.
1. Resort to the throwing of computers out of windows.
2. Resort to the throwing of windows out of computers.

Offline

#2 2009-04-20 05:37:29

Stefan Husmann
Member
From: Germany
Registered: 2007-08-07
Posts: 1,391

Re: optimize build

You can add that option to the CCFLAGS in makepkg.conf. But I do not recommend that.

Offline

#3 2009-04-20 15:59:58

Raccoon1400
Member
From: Ontario, Canada
Registered: 2008-04-14
Posts: 853

Re: optimize build

why don't you recommend it?


Fustrated Windows users have two options.
1. Resort to the throwing of computers out of windows.
2. Resort to the throwing of windows out of computers.

Offline

#4 2009-04-20 16:15:45

foutrelis
Developer
From: Athens, Greece
Registered: 2008-07-28
Posts: 705
Website

Re: optimize build

Raccoon1400 wrote:

how would I optimize the build with makepkg? I was told that there was the -O3 option for gcc, but how can this be used in a pkgbuild?

Probably in /etc/makepkg.conf, by changing the CFLAGS/CXXFLAGS variables. You can also override any of those variables by defining your own in ~/.makepkg.conf (~ is your home directory).

Raccoon1400 wrote:

What do these optimization flags gain me anyways?

There is a great optimization guide in Gentoo's documentation that explains the most common GCC flags.

Last edited by foutrelis (2009-04-20 16:16:18)

Offline

#5 2009-04-20 18:15:05

Stefan Husmann
Member
From: Germany
Registered: 2007-08-07
Posts: 1,391

Re: optimize build

Raccoon1400 wrote:

why don't you recommend it?

-O3 sometimes causes problems, and IMHO the speed gain is not worth it.

Offline

#6 2009-04-20 18:43:31

Wintervenom
Member
Registered: 2008-08-20
Posts: 1,011

Re: optimize build

-03:
- Produces larger binaries that use more memory, more CPU cache misses.
- More likely to break programs.
- Takes more time to compile.
- Insignificant gain, if any.

Last edited by Wintervenom (2009-04-20 18:44:00)

Offline

#7 2009-04-20 19:10:05

Raccoon1400
Member
From: Ontario, Canada
Registered: 2008-04-14
Posts: 853

Re: optimize build

are there any optimization options that are worth using?


Fustrated Windows users have two options.
1. Resort to the throwing of computers out of windows.
2. Resort to the throwing of windows out of computers.

Offline

#8 2009-04-20 20:30:07

Raccoon1400
Member
From: Ontario, Canada
Registered: 2008-04-14
Posts: 853

Re: optimize build

would it be better if only -march was used and not -mtune as well?


Fustrated Windows users have two options.
1. Resort to the throwing of computers out of windows.
2. Resort to the throwing of windows out of computers.

Offline

#9 2009-04-20 20:57:00

Wintervenom
Member
Registered: 2008-08-20
Posts: 1,011

Re: optimize build

-march=native -O2 -pipe is fine for just about everyone.  It will automatically choose the best optimizations for the processor you have in your machine.

Last edited by Wintervenom (2009-04-20 20:57:50)

Offline

#10 2009-04-20 21:04:01

Raccoon1400
Member
From: Ontario, Canada
Registered: 2008-04-14
Posts: 853

Re: optimize build

I have this
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe"
CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe"


Fustrated Windows users have two options.
1. Resort to the throwing of computers out of windows.
2. Resort to the throwing of windows out of computers.

Offline

#11 2009-04-20 21:50:24

Wintervenom
Member
Registered: 2008-08-20
Posts: 1,011

Re: optimize build

So you'd want:
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="$CFLAGS"

Offline

#12 2009-04-20 21:59:13

Xi0N
Member
From: Bilbao - Spain
Registered: 2007-11-29
Posts: 832
Website

Re: optimize build

Wintervenom wrote:

So you'd want:
CFLAGS="-march=native -O2 -pipe"
CXXFLAGS="$CFLAGS"

Is it better to leave everything to autodetection instead of setting explicitly the optimal settings for your processor model? - the ones given in here i mean

Last edited by Xi0N (2009-04-20 22:02:50)

Offline

#13 2009-04-22 01:21:13

adamlau
Member
Registered: 2009-01-30
Posts: 418

Re: optimize build

Or you can add LDFLAGS with makepkg-git as such:

CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
LDFLAGS="-Wl,-O1,--as-needed,--hash-style=gnu"


Arch Linux + sway
Debian Testing + GNOME/sway
NetBSD 64-bit + Xfce

Offline

#14 2009-04-24 08:00:26

buddabrod
Member
From: Germany
Registered: 2007-02-25
Posts: 220

Re: optimize build

You can just add the LDFLAGS to you CFLAGS line so you dont need makepkg-git. LDFLAGS improve things imo more than playing around with CFLAGS.

I myself use only -march=native -Os -pipe -fomit-frame-pointer -Wl,O1,--as-needed,--hash-style=gnu,--sort-common -s
hash-style=gnu is there because by default it's hash-style=both which I dont need. Even when the gnu hash style was considered unstable I never had any problems with it.

Offline

#15 2009-04-28 08:52:42

shagrath
Member
Registered: 2008-12-23
Posts: 15

Re: optimize build

I have a serious question smile
Do the optimization strings in makepkg.conf influence when building with cmake? because I don't see any strings with "-march=native....".
For example when building kde.


ArchLinux x86-64 KDE 4.3 Beta

Offline

#16 2009-04-28 14:09:33

buddabrod
Member
From: Germany
Registered: 2007-02-25
Posts: 220

Re: optimize build

Yes, they should. Try cmake VERBOSE=1 this should give you much more output.

Offline

#17 2009-04-28 18:50:57

shagrath
Member
Registered: 2008-12-23
Posts: 15

Re: optimize build

oh, thank you smile
I set -DCMAKE_VERBOSE_MAKEFILE=ON, and I can see them now! (lines i mean) big_smile


ArchLinux x86-64 KDE 4.3 Beta

Offline

#18 2009-04-29 16:56:28

blasse
Member
From: Poland
Registered: 2008-04-24
Posts: 303

Re: optimize build

adamlau wrote:

Or you can add LDFLAGS with makepkg-git as such:

CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
LDFLAGS="-Wl,-O1,--as-needed,--hash-style=gnu"

LDFLAGS=" " works just fine with recent makepkg, when added to makepkg.conf smile


Proud ex-maintainer of firefox-pgo

Offline

Board footer

Powered by FluxBB