Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old January 10, 2011, 02:08   #1
camlost
Sangband 1.x Maintainer
 
camlost's Avatar
 
Join Date: Apr 2007
Posts: 522
camlost is on a distinguished road
GCC compilations

Huh, I just debugged a problem that showed up depending on the compilation flags I set. For debugging, I don't compile for speed, and I compile with gcc (mingw32) with no flags. For release, I set -O3 for increased performance.

It turns out the problem was due to failure to initialize variables; do compilation flags affect variable initialization? Or was this just random?
__________________
a chunk of Bronze {These look tastier than they are. !E}
3 blank Parchments (Vellum) {No french novels please.}
camlost is offline   Reply With Quote
Old January 10, 2011, 04:14   #2
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,936
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by camlost View Post
Huh, I just debugged a problem that showed up depending on the compilation flags I set. For debugging, I don't compile for speed, and I compile with gcc (mingw32) with no flags. For release, I set -O3 for increased performance.

It turns out the problem was due to failure to initialize variables; do compilation flags affect variable initialization? Or was this just random?
Higher levels of optimisation tend to create more compact code using cleverer reasoning about your code, so sometimes stuff like this happens where previously you were relying on some undefined behaviour and that behaviour changes. With enough warnings turned on this should be exceedingly rarre.
__________________
takkaria whispers something about options. -more-
takkaria is offline   Reply With Quote
Old January 10, 2011, 05:50   #3
camlost
Sangband 1.x Maintainer
 
camlost's Avatar
 
Join Date: Apr 2007
Posts: 522
camlost is on a distinguished road
Quote:
Originally Posted by takkaria View Post
Higher levels of optimisation tend to create more compact code using cleverer reasoning about your code, so sometimes stuff like this happens where previously you were relying on some undefined behaviour and that behaviour changes. With enough warnings turned on this should be exceedingly rarre.
Fair enough. I usually fix a dozen or so of these errors when I get around to compiling on Linux. I should figure out why CodeBlocks is suppressing so many errors; it'd save me time in the long run.
__________________
a chunk of Bronze {These look tastier than they are. !E}
3 blank Parchments (Vellum) {No french novels please.}
camlost is offline   Reply With Quote
Old January 10, 2011, 21:40   #4
pav
Administrator
 
pav's Avatar
 
Join Date: Apr 2007
Location: Prague, Czech republic
Age: 39
Posts: 782
pav is on a distinguished road
Send a message via ICQ to pav
I'd suggest avoiding -O3 unless you do all the debugging with it (impractical). Certainly turn based text game does not need to worry about cpu performance. GCC is known to miscompile some otherwise perfectly valid C code with -O3, especially when output target is something else than i686/linux.

In the rather large open source C-written project I participate on (FreeBSD) we settled with -O2 -fno-strict-alignment as practical highest possible level. Even achieving that required some changes in code. Hiighest safe optimization in GCC is -O.
__________________
See the elves and everything! http://angband.oook.cz
pav is offline   Reply With Quote
Old January 10, 2011, 21:50   #5
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Even the Linux kernel uses -O2 rather than -O3.
Magnate is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:50.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.