GNOME Bugzilla – Bug 721782
Fail to build with clang because of --no-warn option
Last modified: 2014-01-15 22:14:40 UTC
Clang does not have option --no-warn. Can we remove --no-warn in AM_CPPFLAGS or move it to libtool option?
I think it can be replaced with -w (this seems to work on both gcc and clang).
Is --no-warn a required option to compile anjuta? If the answer is no, I think it should be checked in configure before using it, so using different compiler will not cause error. If the compiler does not support it (either --no-warn or -w), we can just skip adding the option.
It's not strictly required, but it helps when someone wants to use -Werror (treat warnings as errors) since the C code generated by the Vala compiler causes warnings. I think it's easier to use a standard option, if there is one, rather than checking if the compiler supports it (I don't know how to do that).
Options -w and -W are not defined in POSIX standard. FreeBSD /usr/bin/c99 rejects both -w and -W.
I'm not against your idea, I was just trying to find an easier solution. Anyway, patches welcome :-)
gnome-compiler-flags.m4 in gnome-common can test whether GCC supports an option. Clang reports that itself is GCC, so we can use the same method to test whether the compiler (GCC or Clang) supports an option. Some relevant code: for option in $warning_flags; do save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $option" AC_MSG_CHECKING([whether gcc understands $option]) AC_TRY_COMPILE([], [], has_option=yes, has_option=no,) CFLAGS="$save_CFLAGS" AC_MSG_RESULT([$has_option]) if test $has_option = yes; then tested_warning_flags="$tested_warning_flags $option" fi unset has_option unset save_CFLAGS done It try to compile an empty file to check whether the compiler understands an option.
dconf uses -w unconditionally (and for the same reason) and it seems to work fine on FreeBSD...
FreeBSD /usr/bin/c99 only accepts options which are specified in POSIX. FreeBSD /usr/bin/cc does not has this problem because it is just a hard link of clang. It will work fine on FreeBSD if --no-warn is changed to -w. However, it seems -w is not a standard option.
I suppose this is strictly true... but are you going out of your way to make trouble for yourself, or what? :)
I think we can close this bug by changing --no-warn to -w. I just want to say that -w is also not a standard thing, but it may be fine if most compilers support it. It is also possible to check whether a compiler support the option, but it is more complex.
I have changed the option to -w, thank you for all your comments.