[cfe-dev] Problem with Tooling system

Alp Toker alp at nuanti.com
Fri Nov 22 13:26:58 PST 2013


On 22/11/2013 21:00, Armand Leclercq wrote:
> Hello everyone,
>
> I am currently using clang tooling for a tool on my own, and I 
> recently started to develop it again.
> I have a strange error while launching my binary
>
> I got a lot of the followin
> <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!
> <premain>: CommandLine Error: Argument 'debug-only' defined more than 
> once!

Hi Armand,

This almost certainly indicates that some static initializers of 
cl::opt<> are getting linked into your binary multiple times, and 
getting run repeatedly as a result.

I remember a similar problem existed even with the standard clang 
examples like PrintFunctionNames at some point.

Some details on your configuration will be useful: Is this a shared or 
static build? Is it a fresh LLVM checkout? Which platform?

Assuming you're using the CMake build system, can you try removing 
entries from target_link_libraries() and/or add_dependencies() in your 
tool's CMakeLists.txt and reporting back? Pretty sure that used to fix it.

If we can collect more data, it'd be nice to revisit and try to fix this 
properly.

Alp.


>
> So I tested back the example code from file:
> ~/llvm/tools/clang/include/clang/Tooling/CommonOptionsParser.h
>
> Corrected for compilation errors:
> #include <clang/Frontend/FrontendActions.h>
> #include <clang/Tooling/Tooling.h>
> #include <clang/Tooling/CommonOptionsParser.h>
> #include <llvm/Support/CommandLine.h>
>
> using namespace clang::tooling;
> using namespace llvm;
>
> static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
> static cl::extrahelp MoreHelp("\nMore help text...");
> int main(int argc, const char **argv) {
>   CommonOptionsParser OptionsParser(argc, argv);
>   ClangTool Tool(OptionsParser.getCompilations(),
>                  OptionsParser.getSourcePathList());
>   return Tool.run(newFrontendActionFactory<clang::SyntaxOnlyAction>());
> }
>
> And the errors still occurs.
>
> I searched a little where it could came from, but I didn't find out.
> I'll continue to search, but any help is welcome
>
> Thanks,
>
> -- 
> Armand Leclercq
> EPITA 2013 Assistant C/Unix
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-- 
http://www.nuanti.com
the browser experts




More information about the cfe-dev mailing list