<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 26, 2015, at 1:34 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Wed, Feb 25, 2015 at 10:31 PM, Vince Harron <span dir="ltr" class=""><<a href="mailto:vharron@google.com" target="_blank" class="">vharron@google.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Hi David,<div class=""><br class=""></div><div class="">There are some LLDB tests that have been failing against clang-3.6 for a long time and just started failing in clang-3.5 when my Ubuntu distro updated clang-3.5.</div><div class=""><br class=""></div><div class="">I tracked it back to a clang CL that you submitted nearly a year ago.</div><div class=""><br class=""></div><div class="">This test passes when compiling with gcc 4.8.2 and clang-3.5 before this CL. I'm very new to the project and I don't really understand what's going on here. Any guidance you can offer would be very much appreciated.</div></div></blockquote><div class=""><br class="">Short answer is that you're probably missing the debug build of your standard library (libstdc++-XXX-dbg).<br class=""><br class="">Long answer: Compilers (both GCC & Clang) try to optimize debug info size by relying on the existence of debug info (especially for types) in other files. They use various signals to make this assumption - both Clang and GCC use vtables as one signal (if a type is dynamic, only emit the debug info for the definition of the type wherever the vtable is emitted). Beyond that, Clang also uses explicit template instantiation declarations as a signal as well (if there's an explicit template instantiation declaration, only emit the full definition of the type where the explicit instantiation definition is).<br class=""><br class="">This allows the compilers to omit definitions in many cases, in favor of them being emitted in one or a small handful of places, reducing debug info size and linker input size.<br class=""><br class="">In the case of std::basic_string<char>, libstdc++ (& other standard library implementations, I'd imagine) has an explicit instantiation declaration to avoid the compiler having to do all the work of instantiating basic_string<char> in every translation unit. The explicit instantiation definition is in the standard library objects (static or dynamic) and that's where the debug info for the type is. If you don't install the debug build of your standard library, you won't have the debug info definition of std::basic_string<char>.<br class=""><br class="">Hope that helps,<br class=""><br class="">- David<br class=""><br class="">I really should write a blog post about this... <br class=""></div></div></div></div></div></blockquote><div><br class=""></div><div>Also here’s a related excerpt from the clang man page:</div><div><br class=""></div><div><div style="margin: 0px; font-family: Menlo; font-size: 11px;" class=""> <b class="">-fstandalone-debug</b> <b class="">-fno-standalone-debug</b></div><div style="margin: 0px; font-family: Menlo; font-size: 11px;" class=""> Clang supports a number of optimizations to reduce the size of debug information in the binary. They work based on the assumption that</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;" class=""> the debug type information can be spread out over multiple compilation units. For instance, Clang will not emit type definitions for</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;" class=""> types that are not needed by a module and could be replaced with a forward declaration. Further, Clang will only emit type info for a</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;" class=""> dynamic C++ class in the module that contains the vtable for the class.</div><div style="margin: 0px; font-family: Menlo; min-height: 16px; font-size: 11px;" class=""><br class=""></div><div style="margin: 0px; font-family: Menlo; font-size: 11px;" class=""> The <b class="">-fstandalone-debug</b> option turns off these optimizations. This is useful when working with 3rd-party libraries that don't come with</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;" class=""> debug information. This is the default on Darwin. Note that Clang will never emit type information for types that are not referenced at</div><div style="margin: 0px; font-family: Menlo; font-size: 11px;" class=""> all by the program.</div><div style="margin: 0px; font-size: 14px; font-family: Menlo; min-height: 16px;" class=""><br class=""></div></div><div>-- adrian</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Vince</div><div class=""><br class=""></div><div class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">------------------------------------------------------------------------</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">r202769 | dblaikie | 2014-03-03 15:48:23 -0800 (Mon, 03 Mar 2014) | 18 lines</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">DebugInfo: Emit only the declaration of a class template that has an explicit instantiation declaration (& always emit such a type when there's an explicit instantiation definition)</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">We should only have this optimization fire when the explicit</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">instantiation definition would cause at least one member function to be</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">emitted, thus ensuring that even a compiler not performing this</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">optimization would still emit the full type information elsewhere.</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">But we should also pessimize output still by always emitting the</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">definition when the explicit instantiation definition appears so that at</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">some point in the future we can depend on that information even when no</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">code had to be emitted in that TU. (this shouldn't happen very often,</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">since people mostly use explicit spec decl/defs to reduce code size -</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">but perhaps one day they could use it to explicitly reduce debug info</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">size too)</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">This was worth about 2% for Clang and LLVM - so not a huge win, but a</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">win. It looks really great for simple STL programs (include <string> and</span><br style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class="">just declare a string - 14k -> 1.4k of .dwo)</span><span class="HOEnZb"><font color="#888888" class=""><br class=""></font></span></div><span class="HOEnZb"><font color="#888888" class=""><div class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><br class=""></span></div><div class=""><span style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:18px" class=""><br class=""></span></div><div class=""><br class=""></div><div class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class=""><div dir="ltr" class=""><br class=""><table cellspacing="0" cellpadding="0" style="font-family:'Times New Roman'" class=""><tbody class=""><tr style="color:rgb(85,85,85);font-family:sans-serif;font-size:small" class=""><td nowrap="" style="border-top-style:solid;border-top-color:rgb(213,15,37);border-top-width:2px" class="">Vince Harron |</td><td nowrap="" style="border-top-style:solid;border-top-color:rgb(51,105,232);border-top-width:2px" class=""> Technical Lead Manager |</td><td nowrap="" style="border-top-style:solid;border-top-color:rgb(0,153,57);border-top-width:2px" class=""> <a href="mailto:vharron@google.com" target="_blank" class="">vharron@google.com</a> |</td><td nowrap="" style="border-top-style:solid;border-top-color:rgb(238,178,17);border-top-width:2px" class=""> <a href="tel:858-442-0868" value="+18584420868" target="_blank" class="">858-442-0868</a></td></tr></tbody></table><br class=""></div></div>
</div></font></span></div>
</blockquote></div><br class=""></div></div>
_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@cs.uiuc.edu" class="">cfe-dev@cs.uiuc.edu</a><br class="">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></body></html>