Option -fkeep-static-consts vs. -fno-keep-static-consts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

What does the "-fkeep-static-consts" and "-fno-keep-static-consts" switch for GCC 3.4.3 do ?


If I write something like:

--------------------------------- x.c ------------------------------------
static const int blah=27;
static const int yunk=93;

int foo(int num)
{
   return blah*num;
}

int bar(int num)
{
   return blah+num+foo(blah+num);
}
--------------------------------- x.c ------------------------------------

and compile it with:
   $> gcc -O2 -fkeep-static-consts -c x.c
   $> nm x.o
   00000010 T bar
   00000000 T foo

Then, GCC removes my static constants and optimizes them.
If I compile like this:
   $> gcc -c x.c
   $> nm x.o
   0000000e T bar
   00000000 r blah
   00000000 T foo
   00000004 r yunk

Then my static constansts are in the output file.
And finally, using the following compilation line:
   $> gcc -fno-keep-static-consts -c x.c
   $> nm x.o
   0000000e T bar
   00000000 r blah
   00000000 T foo
   00000004 r yunk

Give the same reasult than just before.

So, can anyone tell me what that "-fno-keep-static-consts" and "-fkeep-static-consts" GCC flag do ???

Best regards,
Guillaume.


ps: Using GCC 3.2.2, those static constants are always kept in the output file regardless of optimizations/-fno-keep-static-consts


--
=======================================
Guillaume Autran
IMAGO Laboratory - Department of Computing and Information Science
University of Guelph
Tel: (519)824-4120 x56645
E-mail: gautran@xxxxxxxxxxx
Home page: http://draco.cis.uoguelph.ca/~gautran
=======================================




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux