autoconf
[Top][All Lists]
Advanced

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

Re: Testing for unknown flags in different compilers


From: David A. Wheeler
Subject: Re: Testing for unknown flags in different compilers
Date: Fri, 21 Feb 2014 17:19:22 -0500 (EST)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]