[llvm-dev] Unable to parse command line more than once using llvm libraries?
Carl Peto via llvm-dev
llvm-dev at lists.llvm.org
Sun Nov 17 07:16:53 PST 2019
Hi,
I am running a server that does regular builds using llc. To begin with I was doing a fork/exec to launch llc, passing the files to compile and other switches as command line, etc. then waiting for the subprocess to complete. This was fine but seemed an unnecessary overhead. After all llc is mostly a fairly thin front end over the llc libraries, which do the actual work right?
So I took llc.cpp, and the llvm-c and llvm headers and llvm libraries and linked them all into my server program (which is a C based server). I modified llc.cpp to change...
int llcmain(int argc, char **argv) {
...
}
...to...
extern "C" int llcmain(int argc, char **argv) {
...
}
Now I am calling this function directly from my server code. This works fine for the first build, however any other builds fail in
CommandLine.cpp:1101
CommandLineParser::ParseCommandLineOptions
assert(hasOptions() && "No options specified!"); <--fails here
I'm trying to work out why this is breaking, I am assuming there is some global state left after processing that llc.cpp doesn't normally need to worry about?
Is there a way to reset this global state cleanly? I'm assuming there's something about command line processing that is written to only work once, not repeatedly?
Thanks for any advice/help.
More information about the llvm-dev
mailing list