configure tests for gcc builtins with CFLAGS=-Werror
We've run into a problem trying to compile openvswitch with CFLAGS=-Werror.
I don't think it's an openvswitch problem. It appears to be a
openvswitch has a test to detect the library that implements
__atomic_load_8 which boils down to "AC_SEARCH_LIBS([__atomic_load_8],
[atomic])". The problem is when configure is invoked with
"CFLAGS=-Werror ./configure" conftest.c fails to compile because the
dummy prototype used doesn't match the builtin definition. This in turn
causes openvswitch to fail to link because -latomic isn't included in LIBS.
Here is a small patch that illustrates the problem
$ autoreconf -fvi
$ CFLAGS=-Werror ./configure | grep atomic_load
checking for library containing __atomic_load_8... no
Looking at config.log we can see the following
generated by GNU Autoconf 2.69.
configure:2742: checking for C compiler version
configure:2751: gcc --version >&5
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
configure:3478: checking for library containing __atomic_load_8
configure:3509: gcc -o conftest -Werror conftest.c >&5
conftest.c:18:6: error: conflicting types for built-in function
char __atomic_load_8 ();
cc1: all warnings being treated as errors
Any thoughts on how we can get -latomic detected and -Werror passed
through to the build?
Re: configure tests for gcc builtins with CFLAGS=-Werror
On 05/25/2016 02:05 AM, Chris Packham wrote:
> We've run into a problem trying to compile openvswitch with CFLAGS=-Werror.
That's never a good thing to do. We explicitly recommend that you avoid
CFLAGS=-Werror during configure tests, and that configure files that
WANT to (possibly conditionally) enable error flags during the main
compile should probe that setting independently during configure.ac.
GNU Coreutils is a good example for how to do this, using gnulib's
> I don't think it's an openvswitch problem. It appears to be a
> autoconf/gcc issue.
On the contrary, it IS an openvswitch problem, as you should never run
configure with -Werror set for the majority of the probes.
> Any thoughts on how we can get -latomic detected and -Werror passed
> through to the build?
As suggested above, make the probing of whether -Werror works
independent from the rest of configure, and set it in a separate
variable (not CFLAGS), then use that separate variable in your Makefiles
but not the rest of configure.
That said, there is an open patch to autoconf to promote gnulib's
gl_WARN_ADD logic into a formal autoconf macro, and that's one of the
remaining things that needs to be merged in before I can release
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Re: [ovs-discuss] configure tests for gcc builtins with CFLAGS=-Werror
On 05/26/2016 11:58 AM, Ben Pfaff wrote:
> On Wed, May 25, 2016 at 08:05:38AM +0000, Chris Packham wrote:
>> We've run into a problem trying to compile openvswitch with CFLAGS=-Werror.
> Use "configure --enable-Werror", as documented in Open vSwitch's
> INSTALL.md file.