After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 721782 - Fail to build with clang because of --no-warn option
Fail to build with clang because of --no-warn option
Product: anjuta
Classification: Applications
Component: plugins: language-support-vala
git master
Other Linux
: Normal normal
: ---
Assigned To: Abderrahim Kitouni
Anjuta maintainers
Depends on:
Reported: 2014-01-08 12:23 UTC by Ting-Wei Lan
Modified: 2014-01-15 22:14 UTC
See Also:
GNOME target: ---
GNOME version: 3.11/3.12

Description Ting-Wei Lan 2014-01-08 12:23:23 UTC
Clang does not have option --no-warn. Can we remove --no-warn in AM_CPPFLAGS or move it to libtool option?
Comment 1 Abderrahim Kitouni 2014-01-10 19:38:53 UTC
I think it can be replaced with -w (this seems to work on both gcc and clang).
Comment 2 Ting-Wei Lan 2014-01-11 01:13:55 UTC
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.
Comment 3 Abderrahim Kitouni 2014-01-11 12:26:23 UTC
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).
Comment 4 Ting-Wei Lan 2014-01-11 16:01:33 UTC
Options -w and -W are not defined in POSIX standard. FreeBSD /usr/bin/c99 rejects both -w and -W.
Comment 5 Abderrahim Kitouni 2014-01-12 21:36:15 UTC
I'm not against your idea, I was just trying to find an easier solution. Anyway, patches welcome :-)
Comment 6 Ting-Wei Lan 2014-01-13 07:07:28 UTC
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
  CFLAGS="$CFLAGS $option"
  AC_MSG_CHECKING([whether gcc understands $option])
  AC_TRY_COMPILE([], [],
  if test $has_option = yes; then
    tested_warning_flags="$tested_warning_flags $option"
  unset has_option
  unset save_CFLAGS

It try to compile an empty file to check whether the compiler understands an option.
Comment 7 Allison Karlitskaya (desrt) 2014-01-15 04:57:17 UTC
dconf uses -w unconditionally (and for the same reason) and it seems to work fine on FreeBSD...
Comment 8 Ting-Wei Lan 2014-01-15 06:38:32 UTC
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.
Comment 9 Allison Karlitskaya (desrt) 2014-01-15 06:51:44 UTC
I suppose this is strictly true... but are you going out of your way to make trouble for yourself, or what? :)
Comment 10 Ting-Wei Lan 2014-01-15 17:14:35 UTC
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.
Comment 11 Sébastien Granjoux 2014-01-15 22:14:40 UTC
I have changed the option to -w, thank you for all your comments.