For a variety of reasons, we would like to be able to specify
individual compilation switches *within* individual files.

When building we specify a large number of compilation options.  But,
some files need tweaks of one sort or another to the generic set of
options.

Most of the tweaks involve turning selected warnings off.  But, there
are others as well -- turning warnings on, changing optimization
levels, turning selected optimizations on or off, and so on.

We'd like to be able to specify the tweaks to the individual
compilation flags *within* the individual files.

One of the advantages we see is that it would simplify some of the
makefile logic -- rather than having logic (as we do now) to record
the individual compilation switches and comparing that against what
the options were the last time the file was successfully compiled, we
could just look at the time stamp of the file.

[The logic in question compensates for the lack of .KEEP_STATE support
in GNU make.]

Additionally, solutions such as .KEEP_STATE have potential problems
when doing nested distributed builds.

To change the individual compilation switches (as opposed to the
generic compilation switches), you could then just edit the
corresponding *.c file.

(If you change a generic compilation switch, then *EVERYTHING* needs
to be rebuilt and that is handled separately in our system (by having
a depdendency of every *.o file upon the makefile fragment holding
such information).)

The options to be customized do NOT involve options handled by the gcc
driver, only ones handled by the compiler proper (i.e., cc1 and
friends).

Some questions come to mind:

. For starters, does this sound reasonable?  That is, if I implemented
this, and we contributed it back, would it be considered?  Or would it
likely be rejected out of hand?

. Next, if it would not be rejected on the "we don't want to have such
functionality" basis, then the question becomes one of what should the
interface look like?  Some possibilities include:

    #pragma GCC command-line -Wprecision-mismatch

  unilaterally set -Wprecision-mismatch

or possibly:

    #pragma GCC command-line push(-Wprecision-mismatch)

  set -Wprecision-mismatch, remember previous values

and

    #pragma GCC command-line pop(-Wprecision-mismatch)

  reset -Wprecision-mismatch to its previous value

or maybe:

    #pragma GCC warnings Wprecision-mismatch

(with some similiar syntax for other, non warning, options).

Or possibly some other syntax?

. Additionally, are there options you would emphatically *NOT* want to
ever be allowed to be set this way?

I would personally favor not supporting any options that take file
names -- from a security perspective.  And probably a command line
option to enable / disable support for the pragma at all.

Comments?

David
--
David Taylor
[EMAIL PROTECTED]

Reply via email to