<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Eli,<div><br></div><div>Can you change this back to somehow use some sort of #ifdeffery on linux? We had a working version for Mac OS X, there must be an easy way to do this for linux.</div><div><br></div><div>Shared libraries at Apple are not supposed to have any global init constructors in them (we have an build exception for this right now for other things inside LLVM that have global init ctors) but we would like to avoid adding any in the LLDB codebase if at all possible. Also we would like to avoid defining a constant in a header file.</div><div><br></div><div>We should probably modify the Host.h time to somehow autodetect this and set the define appropriately.</div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; text-indent: -12px; font: normal normal normal 11px/normal Menlo; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; text-indent: -12px; font: normal normal normal 11px/normal Menlo; ">We currently add the "-Wglobal-constructors" to all C++ compiles to see these issues as they arise.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; text-indent: -12px; font: normal normal normal 11px/normal Menlo; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; text-indent: -12px; font: normal normal normal 11px/normal Menlo; ">/Volumes/work/gclayton/Documents/src/lldb/include/lldb/lldb-enumerations.h:86:0 /Volumes/work/gclayton/Documents/src/lldb/include/lldb/lldb-enumerations.h:86: warning: 'lldb::eByteOrderHost' requires global construction</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; text-indent: -12px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; text-indent: -12px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; text-indent: -12px; font: normal normal normal 11px/normal Menlo; min-height: 13px; ">You will see some code (which can sometimes get ugly) around LLDB that deals with avoiding global constructors. </div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; text-indent: -12px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; text-indent: -12px; font: normal normal normal 11px/normal Menlo; min-height: 13px; font-family: Helvetica; font-size: medium; "><div><br></div><div>The above example below from SymbolFileDWARF.cpp shows a way to have a static variable in a source file without having to have a global init ctor:</div><div><br></div></div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 12px; text-indent: -12px; font: normal normal normal 11px/normal Menlo; min-height: 13px; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(200, 0, 163); ">static<span style="color: #000000"> </span>const<span style="color: #000000"> </span><span style="color: #418289">ConstString</span><span style="color: #000000">&</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">GetSectionNameDebugInfo()</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">{</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">    <span style="color: #c800a3">static</span> <span style="color: #c800a3">const</span> <span style="color: #418289">ConstString</span> g_sect_name(<span style="color: #e00000">"__debug_info"</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">    <span style="color: #c800a3">return</span> g_sect_name;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">}</div><div><br></div><div>There are also some ugly examples where multiple functions must access a static and a GetAndSet function is made. One such example is in Log.cpp:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; color: rgb(200, 0, 163); ">static<span style="color: #000000"> </span><span style="color: #418289">Stream</span><span style="color: #000000"> *</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">StreamForSTDOUTAccess (<span style="color: #c800a3">bool</span> <span style="color: #7822ac">set</span>, <span style="color: #418289">StreamSP</span> &stream_sp);</div></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">Let me know if you can make the changes for linux, else I might need to back out the change.</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Menlo; ">Greg Clayton</div><div><br></div></div></div><div><br><div><div>On Jun 9, 2010, at 12:26 PM, Eli Friedman wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Author: efriedma<br>Date: Wed Jun  9 14:26:51 2010<br>New Revision: 105746<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=105746&view=rev">http://llvm.org/viewvc/llvm-project?rev=105746&view=rev</a><br>Log:<br>Use portable endianness routine from LLVM.<br><br><br>Modified:<br>    lldb/trunk/include/lldb/lldb-enumerations.h<br><br>Modified: lldb/trunk/include/lldb/lldb-enumerations.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=105746&r1=105745&r2=105746&view=diff">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=105746&r1=105745&r2=105746&view=diff</a><br>==============================================================================<br>--- lldb/trunk/include/lldb/lldb-enumerations.h (original)<br>+++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Jun  9 14:26:51 2010<br>@@ -10,6 +10,8 @@<br> #ifndef LLDB_enumerations_h_<br> #define LLDB_enumerations_h_<br><br>+#include "llvm/System/Host.h"<br>+<br> namespace lldb {<br><br> //----------------------------------------------------------------------<br>@@ -71,18 +73,18 @@<br>     eByteOrderInvalid   = 0,<br>     eByteOrderLittle    = 1234,<br>     eByteOrderBig       = 4321,<br>-    eByteOrderPDP       = 3412,<br>-#if   defined (__LITTLE_ENDIAN__)<br>-    eByteOrderHost      = eByteOrderLittle<br>-#elif defined (__BIG_ENDIAN__)<br>-    eByteOrderHost      = eByteOrderBig<br>-#elif defined (__PDP_ENDIAN__)<br>-    eByteOrderHost      = eByteOrderPDP<br>-#else<br>-#error unable to detect endianness<br>-#endif<br>+    eByteOrderPDP       = 3412<br> } ByteOrder;<br><br>+inline ByteOrder getHostByteOrder() {<br>+  if (llvm::sys::isLittleEndianHost())<br>+    return eByteOrderLittle;<br>+  return eByteOrderBig;<br>+}<br>+<br>+// FIXME: Replace uses of eByteOrderHost with getHostByteOrder()!<br>+const ByteOrder eByteOrderHost = getHostByteOrder();<br>+<br> //----------------------------------------------------------------------<br> // Register encoding definitions<br> //----------------------------------------------------------------------<br><br><br>_______________________________________________<br>lldb-commits mailing list<br><a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits<br></div></blockquote></div><br></div></body></html>