[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    Re: [cfe-dev] multithreaded use of clang::tooling::ToolInvocation
From:       vikasbhargava <vikasbhargava () gmail ! com>
Date:       2014-02-28 17:40:52
Message-ID: CAD2aN0k5iZuX5Pbar0Nequnw43-zhmX_g7LDT-z5vNUKdO8YOg () mail ! gmail ! com
[Download RAW message or body]

The fix in llvm seems straightforward. llvm::sys::RemoveFileOnSignal
releases a mutex too soon. It should hold it till RegisterHandlers()
returns. I will try this out and see if it fixes this issue (and doesn't
break anything else).

thx
Vikas.
=======


On Fri, Feb 28, 2014 at 1:53 AM, Manuel Klimek [via Clang Developers] <
ml-node+s42468n4038165h73@n3.nabble.com> wrote:

> On Thu, Feb 27, 2014 at 2:07 AM, vikasbhargava <[hidden \
> email]<http://user/SendEmail.jtp?type=node&node=4038165&i=0>
> > wrote:
> 
> > 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 of making this parallel compilation work? I do call
> > llvm::start_multi_threaded() before any of this, hoping that it will make
> > llvm routines thread-safe, but to no avail. Are there any other classes
> > that
> > do not set llvm::Sys::RemoveFileOnSignal to true?
> > 
> 
> All of this is currently not thread-safe. We usually use multiprocessing
> to solve the problem. Patches to help making it thread-compatible would be
> welcome :)
> 
> 
> > 
> > thx
> > Vikas.
> > =========
> > 
> > 
> > 
> > --
> > View this message in context:
> > http://clang-developers.42468.n3.nabble.com/multithreaded-use-of-clang-tooling-ToolInvocation-tp4038119.html
> >  Sent from the Clang Developers mailing list archive at Nabble.com.
> > _______________________________________________
> > cfe-dev mailing list
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4038165&i=1>
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> > 
> 
> 
> _______________________________________________
> cfe-dev mailing list
> [hidden email] <http://user/SendEmail.jtp?type=node&node=4038165&i=2>
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> 
> 
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> 
> http://clang-developers.42468.n3.nabble.com/multithreaded-use-of-clang-tooling-ToolInvocation-tp4038119p4038165.html
>  To unsubscribe from multithreaded use of clang::tooling::ToolInvocation, click
> here<http://clang-developers.42468.n3.nabble.com/template/NamlServlet.jtp?macro=unsu \
> bscribe_by_code&node=4038119&code=dmlrYXNiaGFyZ2F2YUBnbWFpbC5jb218NDAzODExOXwtNTUwNDUyODkx>
>                 
> .
> NAML<http://clang-developers.42468.n3.nabble.com/template/NamlServlet.jtp?macro=macr \
> o_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicName \
> space-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespac \
> e&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>  




--
View this message in context: \
http://clang-developers.42468.n3.nabble.com/multithreaded-use-of-clang-tooling-ToolInvocation-tp4038119p4038168.html
 Sent from the Clang Developers mailing list archive at Nabble.com.
_______________________________________________
cfe-dev mailing list
cfe-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic