Pádraig Brady wrote: > Sorry to be clear, the default coreutils build is OK, > it's only when you specify CFLAGS explicitly it fails. > I.e this fails: make CFLAGS='-g -O3' > while make with same CFLAGS in Makefile is OK.
Indeed, I can reproduce like this: $ ./configure --enable-gcc-warnings $ make CFLAGS='-g -O2' V=1 Analysis -------- The failing command is: gcc -ftrapv -DEXEEXT=\"\" -I. -I../lib -DIN_COREUTILS_GNULIB_TESTS=1 -I. -I. -I.. -I./.. -I../lib -I./../lib -fstrict-flex-arrays -Wall -Warith-conversion -Wbad-function-cast -Wcast-align=strict -Wdate-time -Wdouble-promotion -Wduplicated-cond -Wextra -Wformat-signedness -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wnull-dereference -Wold-style-definition -Wopenmp-simd -Woverlength-strings -Wpacked -Wpointer-arith -Wshadow -Wstrict-flex-arrays -Wstrict-overflow -Wstrict-prototypes -Wsuggest-attribute=malloc -Wsuggest-attribute=noreturn -Wsuggest-final-methods -Wsuggest-final-types -Wsync-nand -Wtrampolines -Wuninitialized -Wunknown-pragmas -Wunsafe-loop-optimizations -Wvariadic-macros -Wvector-operation-performance -Wvla -Wwrite-strings -Warray-bounds=2 -Wattribute-alias=2 -Wbidi-chars=any,ucn -Wformat=2 -Wimplicit-fallthrough=5 -Wshift-overflow=2 -Wuse-after-free=3 -Wunused-const-variable=2 -Wvla-larger-than=4031 -Wswitch-enum -Wno-sign-compare -Wno-format-nonliteral -Werror -g -O2 -MT vma-iter.o -MD -MP -MF $depbase.Tpo -c -o vma-iter.o vma-iter.c &&\ gnulib-tests/Makefile contains the following variable definitions: COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) AM_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS) $(WERROR_CFLAGS) CFLAGS = -Wno-error $(GL_CFLAG_GNULIB_WARNINGS) -g -O2 GNULIB_TEST_WARN_CFLAGS = -fstrict-flex-arrays -Wall -Warith-conversion -Wbad-function-cast -Wcast-align=strict -Wdate-time -Wdouble-promotion -Wduplicated-cond -Wextra -Wformat-signedness -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wnull-dereference -Wold-style-definition -Wopenmp-simd -Woverlength-strings -Wpacked -Wpointer-arith -Wshadow -Wstrict-flex-arrays -Wstrict-overflow -Wstrict-prototypes -Wsuggest-attribute=malloc -Wsuggest-attribute=noreturn -Wsuggest-final-methods -Wsuggest-final-types -Wsync-nand -Wtrampolines -Wuninitialized -Wunknown-pragmas -Wunsafe-loop-optimizations -Wvariadic-macros -Wvector-operation-performance -Wvla -Wwrite-strings -Warray-bounds=2 -Wattribute-alias=2 -Wbidi-chars=any,ucn -Wformat=2 -Wimplicit-fallthrough=5 -Wshift-overflow=2 -Wuse-after-free=3 -Wunused-const-variable=2 -Wvla-larger-than=4031 -Wswitch-enum -Wno-sign-compare -Wno-format-nonliteral WERROR_CFLAGS = -Werror GL_CFLAG_GNULIB_WARNINGS = -Wno-cast-qual -Wno-conversion -Wno-float-equal -Wno-sign-compare -Wno-undef -Wno-unused-function -Wno-unused-parameter -Wno-float-conversion -Wimplicit-fallthrough -Wno-pedantic -Wno-sign-conversion -Wno-type-limits -Wno-unused-const-variable -Wno-unsuffixed-float-constants The '-Wno-error' and related options belong between $(AM_CFLAGS) and $(CFLAGS). Since introducing an extra variable for this would be cumbersome (need to override COMPILE etc.), I chose to put them at the front of $(CFLAGS). But the user is allowed to specify e.g. CFLAGS on the command-line, see [1]. Therefore the better choice would have been to put them at the end of $(AM_CFLAGS). Proposed fix ------------ gnulib-tool with option --makefile-name will be changed to append the '-Wno-error' and related options also to AM_CFLAGS. This will break coreutils and some other packages, which don't initialize the necessary variables, mentioned in [2]. But this is easy to fix in coreutils: Swap lines 1 and 3 of coreutils/gnulib-tests/Makefile.am. (These lines originated in coreutils commit 3c7112104daf8f7095048a3c5b2ee6f3e600521f from 2010-10-17 and were not updated when the documentation section in the Gnulib manual was added on 2017-12-10.) Also, a similar change will be done to AM_CXXFLAGS, if the Gnulib files contain some *.cc or *.cxx or *.cpp file. Up to 35 packages might be affected [3]. I'll follow up with each of them. Bruno [1] https://www.gnu.org/software/automake/manual/html_node/User-Variables.html [2] https://www.gnu.org/software/gnulib/manual/html_node/Modified-build-rules.html [3] https://codesearch.debian.net/search?q=+--makefile-name&literal=1&perpkg=1