Newer gcc swallow version control keywords

Newer gcc swallow version control keywords

Oleg Goldshmidt pub at goldshmidt.org
Tue Oct 18 12:41:02 IST 2011


On Tue, Oct 18, 2011 at 11:16 AM, Elazar Leibovich <elazarl at gmail.com> wrote:
> I guess that it doesn't apply to libraries, which must include this global
> variable.

The whole point is that the constants are not global but have file
scope. Therefore the optimizer can figure out they are not really
used.

> Excuse the idiotic solution, but can't you just add an option to print it
> out?
> int main(int argc,char**argv) {if (argc == 2 && strcmp(argv[1],"--ident")
> puts(ident);...}

This is fine for the main() routine of a regular application. What
about other files? Headers? What about daemons that have no I/O?

> It seems like a good idea anyhow, to have a stable way of extracting this
> ident string from the executable

That's the function of ident(1) - and that's what is not working
because the compiler eats the strings.

> (what happens for instance if by accident
> you have rcsident and rcs_ident? How would you know from the stripped
> executable which one to trust?).

It's the version control system's function to expand the keywords with
the right data - if I have multiple strings they will be consistent.

-- 
Oleg Goldshmidt | oleg at goldshmidt.org



More information about the Linux-il mailing list