[LLVMdev] Usage of getenv() inside LLVM and thread safety

Chris Lattner clattner at apple.com
Thu May 23 14:52:48 PDT 2013


On May 23, 2013, at 11:30 AM, Sean Silva <silvas at purdue.edu> wrote:

> On Thu, May 23, 2013 at 8:13 AM, Justin Holewinski <justin.holewinski at gmail.com> wrote:
> That sounds like a missed multi-threading issue with LLVM.  I can't imagine why the user should be forced to serialize creation of MCContext objects. I would suggest filing a bug for this.  A simple lock probably wouldn't be too detrimental to performance here, since MCContext objects shouldn't be created too often.
> 
> The deeper question is why we are even checking a "global" here in the first place? It goes against LLVM's library-based design. So I don't think introducing locking around this is the "right" solution. Can we just make this value an argument to the constructor?

MCContext should definitely not be calling getenv.  Yes, it should just be an argument to the ctor, or perhaps a "setter" method on mccontext, used by clients who care.

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130523/c1080b67/attachment.html>


More information about the llvm-dev mailing list