<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>autoconf seems to set GCC = yes for clang.  I believe clang supports Wunused-variable instead of Wunused-but-set-variable. We could use the former, which is also supported by gcc.   For other unsupported options, we can work around with -Wno-unknown-warning-option or -Xclang-only=</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Apr 2, 2019 at 8:02 AM Dan Williams <<a href="mailto:dcbw@redhat.com" target="_blank">dcbw@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Tue, 2019-04-02 at 15:34 +0200, Torsten Hilbrich wrote:<br>
> Hello,<br>
> <br>
> I tried to compile libmbim (1.16.0), libqmi (1.20.0) and ModemManager<br>
> (1.8.0) with clang and got strange results.<br>
> <br>
> I set the environment variables CC=clang and CXX=clang++ and ran the<br>
> autogen.sh, configure, and make steps.<br>
> <br>
> Then the configure noticed that clang was used and checked for the<br>
> supported warning options:<br>
> <br>
> CC='clang'<br>
> configure:3408: checking for gcc<br>
> configure:3435: result: clang<br>
> ...<br>
> configure:17644: checking whether gcc understands -Wno-unused-but-<br>
> set-variable<br>
> configure:17657: clang -c -Wall -std=gnu89 -g -O2 -Wmissing-<br>
> declarations -Wmissing-prototypes -Wdeclaration-after-statement<br>
> -Wstrict-prototypes -Wno-unused-parameter -Wno-sign-compare -Wno-<br>
> deprecated-declarations -Wno-unused-but-set-variable  conftest.c >&5<br>
> warning: unknown warning option '-Wno-unused-but-set-variable'; did<br>
> you mean '-Wno-unused-const-variable'? [-Wunknown-warning-option]<br>
> 1 warning generated.<br>
> configure:17657: $? = 0<br>
> configure:17666: result: yes<br>
<br>
I think -Wno-unused-but-set-variable is actually a mistake and it<br>
should be "-Wunused-but-set-variable". But that causes build errors<br>
that we should fix.<br>
<br>
Does clang support -Wunused-but-set-variable?<br>
<br>
Also, does making this change in m4/compiler_warnings.m4 of<br>
ModemManager sources help?<br>
<br>
-               CFLAGS="$CFLAGS $option"<br>
+               CFLAGS="$CFLAGS $option -Werror"<br>
<br>
Dan<br>
<br>
> <br>
> However, when compiling the code I got the following error messages:<br>
> <br>
> make[4]: Entering directory<br>
> '/build/client/clang/freedesktop/modemmanager/work/modemmanager/libqc<br>
> dm/src'<br>
>   CC       libqcdm_la-com.lo<br>
> error: unknown warning option '-Wno-unused-but-set-variable'; did you<br>
> mean '-Wno-unused-const-variable'?<br>
>       [-Werror,-Wunknown-warning-option]<br>
> Makefile:516: recipe for target 'libqcdm_la-com.lo' failed<br>
> make[4]: *** [libqcdm_la-com.lo] Error 1<br>
> <br>
> I assume that checking in configure is done without -Werror, but<br>
> compilation at least in libqdcdm is done with -Werror.<br>
> <br>
> <br>
> It this a known problem? Are fixes welcome to support compilation<br>
> with clang?<br>
> <br>
> The same problem happened in libmbim and libqmi.<br>
> <br>
> With regards,<br>
> <br>
>       Torsten Hilbrich<br>
> <br>
> <br>
> _______________________________________________<br>
> ModemManager-devel mailing list<br>
> <a href="mailto:ModemManager-devel@lists.freedesktop.org" target="_blank">ModemManager-devel@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel</a><br>
<br>
_______________________________________________<br>
ModemManager-devel mailing list<br>
<a href="mailto:ModemManager-devel@lists.freedesktop.org" target="_blank">ModemManager-devel@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel</a></blockquote></div></div></div></div>