[cfe-dev] Silencing "unused argument" for injected default arguments

Martin Storsjö via cfe-dev cfe-dev at lists.llvm.org
Thu Sep 26 23:11:54 PDT 2019


On Wed, 25 Sep 2019, David Blaikie wrote:

> 
> 
> On Fri, Sep 13, 2019 at 4:02 AM Martin Storsjö via cfe-dev
> <cfe-dev at lists.llvm.org> wrote:
>       Hi,
>
>       In my setups with clang, I'm using a thin frontend wrapper which
>       passes a
>       bunch of custom defaults (allowing using any stock clang
>       executable,
>       without requiring it to be built with CLANG_DEFAULT_* set to my
>       desired
>       state). The main set of flags I currently use is this:
>
>       -target $TARGET -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld
>       -fuse-cxa-atexit
> 
>
>       Many of them are silent (like -fuse-ld=lld despite only
>       compiling, not
>       linking),
> 
> 
> -fuse-ld=lld when compiling does warn:
> $ clang++-tot foo.cpp -fuse-ld=lld -c
> clang-10: warning: argument unused during compilation: '-fuse-ld=lld'
> [-Wunused-command-line-argument]

Oh, that's surprising. If you add "-target x86_64-w64-mingw32" the warning 
does go away, but not with e.g. "-target x86_64-linux-gnu" - so apparently 
the -fuse-ld flag is unconditionally consumed by the mingw target code.


>       but e.g. -stdlib=libc++ is considered unused if compiling C
>       code.
> 
> 
> Same "argument unused during compilation" here, as you say.
> 
> I don't know that there's much worthwhile to add to Clang to support this
> scenario, but I could be wrong/am but one voice here.
> 
> Usually the way to get different flags to different parts of the build is
> with the various build variables (like CFLAGS, CXXFLAGS, CC, CXX, LDFLAGS,
> etc).

Yeah, but those are more for the user/buildsystem to set than for the 
toolchain installation itself.

I guess I could try implementing --start-no-unused-arguments and 
--end-no-unused-arguments and see how palatable it ends up being. If it's 
not too bad it'd hopefully be tolerable even though it's a fringe usecase.

// Martin


More information about the cfe-dev mailing list