[lldb-dev] Use of function local statics

Zachary Turner zturner at google.com
Wed Aug 20 14:36:21 PDT 2014


As part of my moving code from Host to HostInfo, I moved some
function-local statics to global class-member statics.  The reason for this
is that MSVC doesn't support thread-safe function local statics until
VS2014, which is still only in technology preview, whereas LLVM, clang, and
by extension LLDB support building as far back as VS2012.

Greg submitted r216080 to convert these global statics back to
function-local statics, but this had a bug in it which broke things for all
platforms, so I reverted it in r216123.  A simple fix would have just been
to address the bug, but my original transition from function-local statics
to global statics was intentional due to the fact that any use of them on a
non-primitive type is undefined behavior on MSVC.

So, I want to see if people have a strong preference one way or the other.
 If the issue is just silencing the compiler warning that clang gives about
global constructors, then we can do that in CMake and/or the Xcode project.
 On the other hand, I understand that global static constructors increase
application startup times.  Is this a concern for anyone?  If so, I can try
to come up with a solution.  I think if we try to keep the use of statics
to a minimum, and make sure that they are generally simple types (e.g
std::string, which simply does a malloc), then there should be no
noticeable performance impact on startup.

Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140820/291c7c0b/attachment.html>


More information about the lldb-dev mailing list