Feature #1186
closedImplement a "--enable-werror" configure option
0%
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)
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.
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.
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.
Updated by Mathieu Desnoyers over 4 years ago
- Tracker changed from Bug to Feature
Updated by Mathieu Desnoyers over 4 years ago
- Subject changed from Build error: "CPU_SET" redefined to Implement a "--enable-werror" configure option
Updated by Michael Jeanson over 2 years ago
- Status changed from New to Resolved
- Target version set to 0.14
Merged in master.