Link time checking for incompatible flags
Jim Wilson
wilson@specifixinc.com
Thu Apr 22 10:40:00 GMT 2004
Rahul Joshi wrote:
> Would it be possible to add such link-time
> checking for incompatible compiler options?
It is possible in theory. You can set flags in object files, and then
check the flags at link time. However, this requires coordinated
compiler, assembler, and linker changes, and may also require ABI
changes to reserve the flags. Generally, it is only done when ABIs
specify incompatible alternatives, for instance some targets support
multiple ABIs such as 32-bit and 64-bit code, and you will get a linker
error if you mix them. In this case, the ABI will reserve flags in the
object files for this purpose.
Since -fshort-enums is not part of any ABI, there are no standard flags
to use for it.
An alternative to use flags would be to use comment sections, but that
likely has other problems. For instance, comment sections can be
stripped, and then you don't get the warnings anymore. This is easier
in the sense that we don't have to worry about ABI problems with object
file flags.
Most gcc work is done by volunteers, so this won't get done unless a
volunteer submits a patch for it, and it is unlikely anyone will
volunteer to do this, unless you want to try.
--
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com
More information about the Gcc
mailing list