Code: Select all
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 1;
}
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: Select all
#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;
}
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.
