Looking at the configure.ac file for gnu-coreutils. It is hard-coded to add the -Werror flag to the gcc command line. Here’s how to remove it. Sometimes you just want to compile a different way to see how it compares with the right way.

make distclean
sed -i 's/ \(gl_WARN_ADD([[]-Werror[]], \)/#\1/' configure.ac
make -n lib/randperm.o

The difference between the original and changed configure.ac should be:

$ diff configure.ac ../configure.ac
<   gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
>  #gl_WARN_ADD([-Werror], [WERROR_CFLAGS])

Don’t edit the following very similar line by mistake:

gl_WARN_ADD([-Werror], [CFLAGS])

The result will be a generated Makefile, which is different from the default one as follows:

$ diff Makefile ../Makefile
< PACKAGE_STRING = GNU coreutils 9.0.11-13af8
> PACKAGE_STRING = GNU coreutils 9.0.11-13af8-dirty
< PACKAGE_VERSION = 9.0.11-13af8
> PACKAGE_VERSION = 9.0.11-13af8-dirty
< VERSION = 9.0.11-13af8
> VERSION = 9.0.11-13af8-dirty
< WERROR_CFLAGS =  -Werror

That’s about what I wanted. The only difference in the command for make -n lib/randperm.o is that the -Werror option is no longer present.

But in verifying that, I ran across the option “-Wsuggest-attribute=malloc”. Without changing configure.ac, the build was stopping with this warning:

lib/randperm.c: In function 'sparse_new':
lib/randperm.c:110:1: error: function might be candidate for attribute 'malloc' if it is known to return normally [-Werror=suggest-attribute=malloc]

Maybe some other day I will see if I can just remove that option -Wsuggest-attribute=malloc from the build, instead of disabling -Werror. Another wishlist item is to remove it from just the build of lib/randperm.o.