[LLVMdev] multithreaded use of llvm::sys::RemoveFileOnSignal

Vikas Bhargava vikasbhargava at gmail.com
Wed Feb 26 16:50:57 PST 2014


Hi,
I am using clang::ToolInvocation class to compile some code in-memory:

   clang::tooling::ToolInvocation ti
      (
       compilerArgs,
       new clang::EmitBCAction(),
       new clang::FileManager(clang::FileSystemOptions())
      );
   //filename is the name of the source file, e.g. "Somefile.cpp"
   //sourcecode contains the source of the file
   ti.mapVirtualFile( filename, sourcecode );
   bool ret = ti.run();

In order to speed up compilation of several sources, I call the above code
concurrently in separate threads, with each thread compiling its own source
code. However, this does not work because clang::CompilerInstance calls
llvm::Sys::RemoveFileOnSignal which in turn calls RegisterHandlers() which
is not re-entrant.

Is there a way to make RegisterHandlers() re-entrant? I do call
llvm::start_multi_threaded() before any of this, hoping that it will make
llvm routines thread-safe, but to no avail.

Also, is there any other way of doing parallel compilation?

thx
Vikas.
=========
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140226/61077bd4/attachment.html>


More information about the llvm-dev mailing list