Project

General

Profile

Actions

Feature #1186

closed

Implement a "--enable-werror" configure option

Added by Simon Marchi over 5 years ago. Updated over 2 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Target version:
Start date:
05/27/2019
Due date:
% Done:

0%

Estimated time:

Description

Commit: 5510757134071e2bb6b554e7d0aaf29676150065
Configured with: /home/smarchi/src/userspace-rcu/configure 'CFLAGS=-g3 -O0 -Werror -fmax-errors=1 -fdiagnostics-color=always -fsanitize=address -Wall' 'CXXFLAGS=-g3 -O0 -fsanitize=address' 'CC=ccache gcc' 'CXX=ccache g++' '--prefix=/tmp/userspace-rcu'

Expected behavior: it builds
Actual behavior: it does not build

ccache gcc -DHAVE_CONFIG_H   -include config.h  -Wall -Wextra -Wno-unused-parameter  -pthread -I/home/smarchi/src/userspace-rcu/include -I../../include -I/home/smarchi/src/userspace-rcu/src -I/home/smarchi/src/userspace-rcu/tests/common -g -g3 -O0 -Werror -fmax-errors=1 -fdiagnostics-color=always -fsanitize=address -Wall -MT test_urcu.o -MD -MP -MF .deps/test_urcu.Tpo -c -o test_urcu.o /home/smarchi/src/userspace-rcu/tests/benchmark/test_urcu.c
In file included from /home/smarchi/src/userspace-rcu/tests/benchmark/test_urcu.c:36:0:
/home/smarchi/src/userspace-rcu/tests/common/cpuset.h:40:0: error: "CPU_SET" redefined [-Werror]
 # define CPU_SET(cpu, cpuset) do { *(cpuset) |= (1UL << (cpu)); } while(0)

In file included from /usr/include/pthread.h:23:0,
                 from /home/smarchi/src/userspace-rcu/tests/benchmark/test_urcu.c:24:
/usr/include/sched.h:83:0: note: this is the location of the previous definition
 # define CPU_SET(cpu, cpusetp)  __CPU_SET_S (cpu, sizeof (cpu_set_t), cpusetp)

Actions #1

Updated by Simon Marchi over 5 years ago

Most likely cause, from config.log:

3181 configure:15491: checking whether CPU_SET works
3182 configure:15506: gcc -c -g3 -O0 -Werror -fmax-errors=1 -fsanitize=address -Wall  conftest.c >&5
3183 conftest.c: In function 'main':
3184 conftest.c:61:19: error: unused variable 'mask' [-Werror=unused-variable]
3185     cpu_set_t foo, mask; CPU_SET(0, &foo);
3186                    ^~~~
3187 cc1: all warnings being treated as errors
3188 configure:15506: $? = 1

The test program used for checking for CPU_SET support has an unused variable, and it fails to compile when -Wunused-variable is used.

Actions #2

Updated by Michael Jeanson over 5 years ago

Expecting autotools C code tests snippets to work with "-Werror" is rather optimistic. My understanding is that projects that use -Werror will add it to the CFLAGS at the end of the configure script when the autotools C tests have passed.

Actions #3

Updated by Mathieu Desnoyers over 5 years ago

I've cleaned up this particular instance of unused variable because it was within a check code implemented within urcu configure.ac. However, there are plenty of other instances where autotools checks fail when built with -Wall -Werror: 4x unused-but-set-variable, 2x unused-variable, 1x overflow, 1x address.

Having the wrong result for those tests can generate unexpected results at compilation or runtime.

The upstream autotools check don't seem to expect -Werror.

We should rather consider implementing a "--enable-werror" configure option to add -Werror at build only, without adding it for the autotools check.

Actions #4

Updated by Mathieu Desnoyers over 4 years ago

  • Tracker changed from Bug to Feature
Actions #5

Updated by Mathieu Desnoyers over 4 years ago

  • Subject changed from Build error: "CPU_SET" redefined to Implement a "--enable-werror" configure option
Actions #6

Updated by Michael Jeanson over 2 years ago

  • Status changed from New to Resolved
  • Target version set to 0.14

Merged in master.

Actions

Also available in: Atom PDF