[cfe-dev] Loading Static Analyzer plugin fails with CommandLine Errors

Gábor Kozár kozargabor at gmail.com
Tue Sep 3 04:06:26 PDT 2013


Hi Laszlo,

do you use 64 bit machine, right? (was confused about the 32 bit
> virtual machine story.)
>
Yes, the machine is 64-bit (both the processor and the OS - using Linux
Mint 14 Cinnamon btw).

#1 you should not link any Clang
> library against when you make your plugin
>
How do I not link against any Clang library when I'm writing a Clang
plugin? I need to use Clang's classes extensively.

#2 try not to use the
> LLVM command line classes. (llvm::cl) Do the command line parsing
> without those classes.
>
I do not use llvm::cl - I'm, in fact, not doing any command line arg
processing. All my plugin does is register a bunch of custom checkers to
Clang Static Analyzer.

Thanks for the response though!

In the meanwhile, I realize that I have done it all with the assumption
that GCC 4.7.2 and Clang 3.3 generate compatible binaries. Could this be
the source of the issue? I'll try self-hosting Clang 3.3 and see what
happens then.

Gabor


2013/9/3 Laszlo Nagy <rizsotto.mailinglist at gmail.com>

> Hi Gabor,
>
> do you use 64 bit machine, right? (was confused about the 32 bit
> virtual machine story.)
>
> My experience on plugins is, that #1 you should not link any Clang
> library against when you make your plugin. And #2 try not to use the
> LLVM command line classes. (llvm::cl) Do the command line parsing
> without those classes.
>
> Regards,
> Laszlo
>
> On Mon, Sep 2, 2013 at 5:04 PM, Gábor Kozár <kozargabor at gmail.com> wrote:
> > (My apologies, I sent this e-mail first from the wrong e-mail account.)
> >
> > I'm using Clang 3.3. I have a Clang Static Analyzer plugin that contains
> the
> > following symbols:
> >
> >
> > extern "C" const char clang_analyzerAPIVersionString[] =
> > CLANG_ANALYZER_API_VERSION_STRING;
> > extern "C" void clang_registerCheckers(clang::ento::CheckerRegistry&
> > registry)
> >
> >
> > However, when I try to do something with it, like:
> >
> > clang++ -c test.cpp -Xclang -load -Xclang plugin.so
> >
> >
> > I get the following output:
> >
> > <premain>: CommandLine Error: Argument 'view-background' defined more
> than
> > once!
> > <premain>: CommandLine Error: Argument 'debug-only' defined more than
> once!
> > <premain>: CommandLine Error: Argument 'debug-buffer-size' defined more
> than
> > once!
> > <premain>: CommandLine Error: Argument 'debug' defined more than once!
> > <premain>: CommandLine Error: Argument 'version' defined more than once!
> > <premain>: CommandLine Error: Argument 'print-all-options' defined more
> than
> > once!
> > <premain>: CommandLine Error: Argument 'print-options' defined more than
> > once!
> > <premain>: CommandLine Error: Argument 'help-hidden' defined more than
> once!
> > <premain>: CommandLine Error: Argument 'help' defined more than once!
> > <premain>: CommandLine Error: Argument 'help-list-hidden' defined more
> than
> > once!
> > <premain>: CommandLine Error: Argument 'help-list' defined more than
> once!
> > clang: CommandLine Error: Argument 'view-background' defined more than
> once!
> > clang: CommandLine Error: Argument 'debug-only' defined more than once!
> > clang: CommandLine Error: Argument 'debug-buffer-size' defined more than
> > once!
> > clang: CommandLine Error: Argument 'debug' defined more than once!
> > clang: CommandLine Error: Argument 'version' defined more than once!
> > clang: CommandLine Error: Argument 'print-all-options' defined more than
> > once!
> > clang: CommandLine Error: Argument 'print-options' defined more than
> once!
> > clang: CommandLine Error: Argument 'help-hidden' defined more than once!
> > clang: CommandLine Error: Argument 'help' defined more than once!
> > clang: CommandLine Error: Argument 'help-list-hidden' defined more than
> > once!
> > clang: CommandLine Error: Argument 'help-list' defined more than once!
> >
> >
> > I have never encountered such an error before, and this works perfectly
> on a
> > different machine, although with 32-bit binaries (it being a 32-bit
> system
> > inside a VirtualBox).
> >
> > The plugin was compiled using Clang 3.3, as a shared library, with -fPIC
> and
> > -fno-rtti. 'file plugin.so' output:
> >
> > ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically
> > linked, not stripped
> >
> >
> > 'file clang' output:
> >
> > ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically
> linked
> > (uses shared libs), for GNU/Linux 2.6.24,
> > BuildID[sha1]=0xb08840ba88f98740a0e3f4b6448e1c4b70ad57ce, not stripped
> >
> >
> > Clang (again, version 3.3) was configured with --enable-optimized, and
> was
> > built using GCC 4.7.2.
> >
> > Any idea what could be the issue here?
> > Thanks!
> >
> > --
> > Gábor Kozár
> > kozargabor at fastmail.fm
> >
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130903/ceb60f6c/attachment.html>


More information about the cfe-dev mailing list