INCLUDE_CONFIG_FILE broken?

Bruce Evans bde at zeta.org.au
Fri Apr 15 17:20:39 PDT 2005


On Sat, 16 Apr 2005, Roland Smith wrote:

> On Fri, Apr 15, 2005 at 12:27:44PM -0700, Peter Wemm wrote:
>> gcc-3.4 does entire-file optimization, while 3.3 and earlier look at
>> functions at a time.  As a result, gcc is now very good at finding
>> static unused things.

This doesn't explain it.  Variables declared as "static const char []" have
been specially handled by gcc for 15 years ago.  gcc doesn't warn about
ones that are not used in the source file, unlike ones declared as
"static char []".  This behaviour hasn't changed.  What has changed is
the removal of all unused static variables at optimization -O2 and higher.
Removing the "static const char []" ones is just a bug, especially since
it is done without warning.

>> We might need to do something different.  I'd almost like to insert
>> the config file into its own ELF section via objcopy...

You could just use the existing mechanism __IDSTRING(), preferably
after fixing it to actually work.  (__IDSTRING() generates invalid
asm if the string has a newline in it.  Among other bugs, this breaks
most uses of __COPYRIGHT().)

> Why not use gcc's __attribute__ ((unused))?

Because it is unportable and backwards.  __attribute__((used)) works.
Putting the string in a separate section is better for an id string,
but the attribute would be better than bogusly exporting the symbol
for things like functions that are only intended to be called from
debuggers.

Bruce


More information about the freebsd-amd64 mailing list