<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jul 10, 2014 at 8:43 AM, Jonas Wagner <span dir="ltr"><<a href="mailto:jonas.wagner@epfl.ch" target="_blank">jonas.wagner@epfl.ch</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div class="gmail_extra"><div class="gmail_quote"><div class=""><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">


Are you setting DYLD_LIBRARY_PATH when running on OS X? The linker on<br>
OS X uses that to find libLTO.dylib.<br></blockquote><div><br></div></div><div>This indeed solves the problem! Thanks for the hint. Although I had used custom versions of Clang for a while, this is the first time I encountered incompatibilities with the system linker, and so I wasn't aware of the need to set DYLD_LIBRARY_PATH.</div>


<div><br></div><div><div><div class=""><blockquote class="gmail_quote" style="font-family:arial,sans-serif;font-size:13px;margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">


<blockquote 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" class="gmail_quote">The llvm-dis/llvm-as operation should be a no-op, yet the global_ctors get lost in the process. This happens also with other operations that affect global_ctors, e.g., with "opt -insert-gcov-profiling".<br>


</blockquote></blockquote><div style="font-family:arial,sans-serif;font-size:13px"> </div></div><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">


This isn't strictly true.  Deserializing old bitcode will auto-upgrade it.  In this case, it will be auto-upgraded to the 3-field form of llvm.global_ctors.</blockquote><div><br></div><div>I see. I wonder if this is what's happening. Clang and llvm-as are built against the same version of LLVM, so Clang should not emit old bitcode. On the other hand, the fact that the system linker understands Clang-generated bitcode probably means it used the old format.</div>
</div></div></div></div></div></blockquote><div><br></div><div>I think I see what's going on: Clang will emit the new, 3-field form for C++, but you're compiling C.  That means there are no ctors until LLVM runs, at which point it creates a 2-field form ctor array.  It's likely that C++ LTO with TOT clang and the system linker doesn't work right now, but that's OK.</div>
</div></div></div>