5.18.14 FTBFS on unknown compiler warnings
Brought to you by:
bkorb
On macOS (10.11/Xcode8.2), 5.18.14 fails on new flags -Wno-format-contains-nul and -Wstrict-aliasing=3. 5.18.12 built fine and passed tests.
Compiler: clang
Compiler flags: -g -O2 -Wno-format-contains-nul -fno-strict-aliasing
Host System Type: x86_64-apple-darwin15.6.0
...
libtool: compile: clang -DHAVE_CONFIG_H -I. -I../../autoopts -I.. -I.. -I../.. -I../autoopts -I../../autoopts -I/sw/include -DPKGDATADIR=\"/sw/share/autogen\" -g -O2 -Wno-format-contains-nul -fno-strict-aliasing -Wall -Werror -Wcast-align -Wmissing-prototypes -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings -Wstrict-aliasing=3 -Wextra -Wno-cast-qual -g -O2 -Wno-format-contains-nul -fno-strict-aliasing -MT libopts_la-libopts.lo -MD -MP -MF .deps/libopts_la-libopts.Tpo -c libopts.c -fno-common -DPIC -o .libs/libopts_la-libopts.o
error: unknown warning option '-Wno-format-contains-nul' [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wstrict-aliasing=3'; did you mean '-Wstring-plus-int'? [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Wno-format-contains-nul' [-Werror,-Wunknown-warning-option]
make[4]: *** [libopts_la-libopts.lo] Error 1
This is not the same as #185 since that's an actual build error, whereas this is -Werror failing on unknown flags.
Distinguishing "clang" from "GCC" is non-trivial. Or, I haven't been told how and haven't used it. Autoconf ought to not say it is GCC, which is why those GCC warning types are there. I wrote the "format-contains-nul" warning type TWO decades ago. Clang should not fall that far behind.
You can identify whether the compiler is clang by checking for the preprocessor define
__clang__. But it might be better instead to check whether each flag is supported by the compiler before using it, since you never know when someone might compile your code with a compiler, or a compiler version, you did not expect, which may not support all the flags you want to use.It would also be great if you could distribute source that doesn't use
-Werrorby default, because you never know when a new compiler will come around that contains new warnings.I'll think about this. Clang lies and says it is GCC when it is not. If it wants to masquerade as GCC, then it needs to handle options that are two decades old. Warning over format strings containing a NUL byte is dumb anyway. NUL bytes don't appear by accident.