Re: Testing for unknown flags in different compilers

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

 



Thomas Jahns said:
> >> Also this is going to cause all sorts problems for compilers that use -W for
> >> something else entirely, for example on PowerPC xlc has
> >> -W<program>,<options_list>
> >> so simply adding some arbitrary -Wsomecharactersequence might easily cause
> >> catastrophic results later on.

I said:
> > I think that's the whole point of the macro; instead of just adding arbitrary flags,
> > it tests to make sure there are *not* catastrophic effects, but instead, that
> > the flag is recognized.

Eric Blake added:
> Or at least has no observable negative effects even if it is a no-op to
> a particular compiler by including the flag.

Yes, that's fair point.

It appears to me that the code to work out the *default* warning flags goes further and intentionally checks for flag sets known to work (or not work) for a larger set of specific compilers, so that shouldn't be a problem for the default case anyway.

But as for Dale Visser's macro to check if a possible additional compiler flag is "okay", I looked at the listed HTML page for the IBM compiler mentioned earlier: http://pic.dhe.ibm.com/infocenter/comphelp/v121v141/index.jsp?topic=%2Fcom.ibm.xlcpp121.aix.doc%2Fcompiler_ref%2Fopt_w_upper.html
where it shows "-W..." doing all sorts of things, using examples such as "-Wl,-berok".    That's an unfortunate overload of "-W...".

I think that problem can be addressed in many cases by forcing the macro to test for a successful *compile* and *link*, instead of just *compile*.  That way, the linker will have a chance to complain, which the macro can then detect.  Then the flag will only be added if it causes no observable negative effects in compiler or link... which seems like an improvement.

Also, if Dale Visser adds a macro that just *detects*, but doesn't necessarily *add*, then people can easily implement sequences like, "if '-pedantic -Wall' works, then try to add flag '-Wall'".  That should make it much easier to portably add option flags when a particular flag sequence has different meanings between compilers.   That's what the code for computing the default warning flags does anyway; this change would make that functionality easily accessible to users.


--- David A. Wheeler

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf




[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux