RE: Testing for unknown flags in different compilers

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

 



Thomas:

Your concerns make sense. I was deliberately vague about the context and purpose of the macro, since I wanted the list community to focus on whether the algorithm I was proposing is the best way of accomplishing the stated goal of adding a compiler/linker flag *only* if it is known to the compiler.

If you follow the link to the autoconf-patches discussion I provided earlier, it gives the context, which I'll describe here. I am attempting to modify and port macros from autoconf-archive and gnulib-warnings to modify the default behavior of AC_PROG_CC, AC_PROG_CXX and AC_PROG_FC to add option flags to turn on compiler warnings. E.g., in gcc and clang, -Wall would be added.

Since not all developers would be happy with this new default, a way is provided to restore the previous behavior (not adding the warning options). *In addition*, a new macro will be provided to make it easy for configure.ac authors to add flags to the CXXFLAGS, CFLAGS, or FCFLAGS as appropriate by context. For example, a team may be happy with -Wall except for the fact that it includes warnings about the contents of comments, and so could invoke AC_ADD_CXXFLAG_IFVALID([-Wno-comment]) in order to turn that warning off. (A better name than AC_WARN_ADD, as David Wheeler pointed out.)

Your point about clx makes sense. I was not aware of its different usage of -W (documented at http://pic.dhe.ibm.com/infocenter/comphelp/v121v141/index.jsp?topic=%2Fcom.ibm.xlcpp121.aix.doc%2Fcompiler_ref%2Fopt_w_upper.html).  My goal is to make the AC_PROG_* changes as cross-compiler as possible. There is probably always going to be some compiler which does its various command-line options different than the others. The AC_ADD_*FLAG_IFVALID macro would be very much a "buyer beware" macro, and almost by definition, people are going to placing flags there that will be specific to a given compiler, hence the desire to detect ones unknown to the current compiler and reject them.

Best regards,
Dale Visser

Date: Thu, 20 Feb 2014 11:26:35 +0100
From: jahns@xxxxxxx
To: autoconf@xxxxxxx
Subject: Re: Testing for unknown flags in different compilers

Hello all,
 
On 02/19/14 22:05, Dale Visser wrote:
> I have been working on a changes whereby an autoconf user can invoke a macro like
> 
> AC_WARN_ADD([-Wextra])
> 
> to add user-specified flags to the compiler/linker invocations. Ideally we would like 
 
I'm unclear what tool(s) you want to affect (is the flag going to be added to
CFLAGS, CXXFLAGS, FCFLAGS? depending on language mode or CFLAGS only? if the
latter shouldn't the name have something like CC in it).
 
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 suggest your macro at least try to make sure
your compiler is GNU CC before modifying CFLAGS in any way.
 
Also users should have an option to deselect this because software tends to get
distributed to systems where system headers cause one warning or another.
 
In my opinion you are trying to solve a development issue with a tool that has
the explicit purpose of being useful for non-developers.
 
Regards, Thomas
-- 
Thomas Jahns
DKRZ GmbH, Department: Application software
 
Deutsches Klimarechenzentrum
Bundesstraße 45a
D-20146 Hamburg
 
Phone: +49-40-460094-151
Fax: +49-40-460094-270
Email: Thomas Jahns <jahns@xxxxxxx>
 

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf 		 	   		  
_______________________________________________
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