Problems compiling with clang (3.8.21)

Ben Chan benchan at chromium.org
Tue Apr 2 21:00:50 UTC 2019


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=

On Tue, Apr 2, 2019 at 8:02 AM Dan Williams <dcbw at redhat.com> wrote:

> On Tue, 2019-04-02 at 15:34 +0200, Torsten Hilbrich wrote:
> > Hello,
> >
> > I tried to compile libmbim (1.16.0), libqmi (1.20.0) and ModemManager
> > (1.8.0) with clang and got strange results.
> >
> > I set the environment variables CC=clang and CXX=clang++ and ran the
> > autogen.sh, configure, and make steps.
> >
> > Then the configure noticed that clang was used and checked for the
> > supported warning options:
> >
> > CC='clang'
> > configure:3408: checking for gcc
> > configure:3435: result: clang
> > ...
> > configure:17644: checking whether gcc understands -Wno-unused-but-
> > set-variable
> > configure:17657: clang -c -Wall -std=gnu89 -g -O2 -Wmissing-
> > declarations -Wmissing-prototypes -Wdeclaration-after-statement
> > -Wstrict-prototypes -Wno-unused-parameter -Wno-sign-compare -Wno-
> > deprecated-declarations -Wno-unused-but-set-variable  conftest.c >&5
> > warning: unknown warning option '-Wno-unused-but-set-variable'; did
> > you mean '-Wno-unused-const-variable'? [-Wunknown-warning-option]
> > 1 warning generated.
> > configure:17657: $? = 0
> > configure:17666: result: yes
>
> I think -Wno-unused-but-set-variable is actually a mistake and it
> should be "-Wunused-but-set-variable". But that causes build errors
> that we should fix.
>
> Does clang support -Wunused-but-set-variable?
>
> Also, does making this change in m4/compiler_warnings.m4 of
> ModemManager sources help?
>
> -               CFLAGS="$CFLAGS $option"
> +               CFLAGS="$CFLAGS $option -Werror"
>
> Dan
>
> >
> > However, when compiling the code I got the following error messages:
> >
> > make[4]: Entering directory
> > '/build/client/clang/freedesktop/modemmanager/work/modemmanager/libqc
> > dm/src'
> >   CC       libqcdm_la-com.lo
> > error: unknown warning option '-Wno-unused-but-set-variable'; did you
> > mean '-Wno-unused-const-variable'?
> >       [-Werror,-Wunknown-warning-option]
> > Makefile:516: recipe for target 'libqcdm_la-com.lo' failed
> > make[4]: *** [libqcdm_la-com.lo] Error 1
> >
> > I assume that checking in configure is done without -Werror, but
> > compilation at least in libqdcdm is done with -Werror.
> >
> >
> > It this a known problem? Are fixes welcome to support compilation
> > with clang?
> >
> > The same problem happened in libmbim and libqmi.
> >
> > With regards,
> >
> >       Torsten Hilbrich
> >
> >
> > _______________________________________________
> > ModemManager-devel mailing list
> > ModemManager-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
>
> _______________________________________________
> ModemManager-devel mailing list
> ModemManager-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/modemmanager-devel/attachments/20190402/f7c417c6/attachment-0001.html>


More information about the ModemManager-devel mailing list