<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Sep 19, 2013, at 10:24 AM, Chandler Carruth <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">On Wed, Sep 18, 2013 at 9:03 PM, Andrew Trick <span dir="ltr"><<a href="mailto:atrick@apple.com" target="_blank" class="cremed">atrick@apple.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div class="h5"><br><div><div>On Sep 18, 2013, at 5:51 PM, Chris Lattner <<a href="mailto:clattner@apple.com" target="_blank" class="cremed">clattner@apple.com</a>> wrote:</div>
<br><blockquote type="cite"><div style="word-wrap:break-word"><div>On Sep 18, 2013, at 4:54 PM, Chandler Carruth <<a href="mailto:chandlerc@google.com" target="_blank" class="cremed">chandlerc@google.com</a>> wrote:</div>
<blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Andy, this really feels like a hack, and a bad hack at that.</div><div><br></div><div>Where is the requirement for the core library to have no static initializers coming from? What is the support plan here? What problem are you actually trying to fix?</div>

</div></div></div></blockquote><div><br></div><div>Just for clarity, I have read the llvmdev thread, and I understand the *general* goal, but this patch itself doesn't seem like a clean incremental step toward that goal, doesn't reference any of the constructs under discussion in that thread.</div>
</div></div></div></blockquote><div><br></div>I totally agree.  This seems like a hack that would be resolved by making cl::opt's get compiled out in non-assert builds, which you already described.</div></blockquote>
<div><br></div></div></div></div><div><div>I'll coalesce my responses to Chris and Chandler here:</div><div><br></div><div>This fixes a particularly horrible bug where LLVM crashes during PassRegistry::removeRegistrationListener when a multi-threaded process exits while compiler threads are running.</div>
</div></div></blockquote><div><br></div><div>OK, to make sure I understand correctly, this is the classical problem where threads are live at the moment exit is called, and thus global destructors are run out from under the threads?</div></div></div></div></blockquote><div><br></div><div>Yes.</div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto;"><div style="word-wrap:break-word"><div><br></div><div>This patch was meant to</div><div>(a) fix a bug</div>
<div>(b) handle one of the handful of special cl::opt cases that won't be covered by the general approach I outlined in the RFC.</div><div><br></div><div>The proposal talked about handling the majority of options incrementally without enormous churn. This case is an exception that I wanted to get out of the way first.</div>
<div><br></div><div>This case is special because we want the PassManager options to be availabe in non-assert builds, or so I thought. These are clearly "tool" options that need to be exported to a number of LLVM-based tools.</div>
<div><br></div><div>What about this patch is a hack, other than being a special case? Having tools call initializePassManager()? I can't think of any long-term solution where that can be avoided.</div><div><br></div><div>
I thought this fix would be general all-around goodness, but I'd be happy to revert this patch and wrap the whole thing in #ifndef LLVM_NO_STATICINIT if Chris and Chandler prefer.</div></div></blockquote><div><br>
</div><div>I'd like to first figure out what the end state actually looks like. Maybe that's better done on the original thread.</div></div></div></div>
</blockquote></div><br><div>Agreed. I reverted and will follow up on the original thread.</div><div><br></div><div>-Andy</div></body></html>