Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
-fomit-frame-pointer seems to be impliede in -O > 0 on am
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on AMD64
View previous topic :: View next topic  
Author Message
secondshadow
Guru
Guru


Joined: 23 Jun 2003
Posts: 362

PostPosted: Wed Mar 03, 2004 4:28 am    Post subject: -fomit-frame-pointer seems to be impliede in -O > 0 on am Reply with quote

So an interesting subject came up in the #gentoo-amd64 room on freenode tonight. I thought that -fomit-frame-pointer was implied in -O3... but brad seemed to think that this was not the case...and the documentation on gcc.gnu.org is a bit ambiguious on this point as it says that -fomit-frame-pointer in -O, -O2, -O3, and -Os. But elsewhere it stated that it was only enabled in certain archs...so we were a bit confused. I decided to do some testing. First I wrote a simple hello world program.

[code="hello.c"]
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 1;
}
[/code]

This was compiled a number of times....starting with gcc -O3 working down...though there are really only 4 builds that were relavent:

for Comparison #1
gcc -O0 hello.c
gcc -O0 -fomit-frame-pointer hello.c


for Comparison #2
gcc -O1 hello.c
gcc -O1 -fomit-frame-pointer hello.c


What I found was that in comparison #1 the binaries generated differed, which was to be expected. What was somewhat surprising is that in comparison #2 they did not differ. This was surprising to me because (supposedly) in the 32-bit x86 arch -fomit-frame-pointer is NOT implied by optimization and must be explicitly used...again...supposedly. Just to be safe, however, I tried a slightly more complex program:

[code="copy.c"]
#include <stdio.h>

int main()
{
FILE *infile;
FILE *outfile;
unsigned char byte;
infile=fopen("copy.c","r");
outfile=fopen("copied.c","r");
byte=fgetc(infile);
while(!feof(infile))
{
fputc(byte,outfile);
byte=fgetc(infile);
}
fclose(infile);
fclose(outfile);
return 1;
}
[/code]

Again, the results were the same, so in short, if appears that I can now reduce my CFLAGS from: "-O3 -pipe -fomit-frame-pointer" to "-O3 -pipe".

I just thought that the community might be interested in this, if for not other reason than, if you are going to emerge something but you want to keep that pesky frame-pointer around for debugging purposes then perhaps using -fnoomit-frame-pointer would be called for.
Back to top
View user's profile Send private message
thumper
Guru
Guru


Joined: 06 Dec 2002
Posts: 554
Location: Venice FL

PostPosted: Thu Mar 04, 2004 7:41 pm    Post subject: Reply with quote

According to this it's implied by -O1

Interesting read:
http://www.coyotegulch.com/acovea/


George
Back to top
View user's profile Send private message
secondshadow
Guru
Guru


Joined: 23 Jun 2003
Posts: 362

PostPosted: Fri Mar 05, 2004 1:24 am    Post subject: Reply with quote

Yup...I thought that was clear when I said -O > 0....'cause -O0 means no optimizations... :D

EDIT: Oh and supposedly -fomit-frame-pointer should NOT be turned on EVER by default on the x86 arch as it makes it nearly impossible to debug anything....though I should probably check on that
Back to top
View user's profile Send private message
thumper
Guru
Guru


Joined: 06 Dec 2002
Posts: 554
Location: Venice FL

PostPosted: Fri Mar 05, 2004 1:49 am    Post subject: Reply with quote

I was under the impression that x86 does not enable the flag by default, or so the gcc docs imply.

Anyway, I saw that document, though you might enjoy the read. :)

George
Back to top
View user's profile Send private message
secondshadow
Guru
Guru


Joined: 23 Jun 2003
Posts: 362

PostPosted: Fri Mar 05, 2004 3:41 am    Post subject: Reply with quote

yeah, I've read it. It was cool...I just assumed that since x86_64 is an extension of x86 that -fomit-frame-pointer would be turned off in it as well......very odd IMO...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on AMD64 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum