<div dir="ltr">LLD work on Darwin is stalled out at the moment. Patches are welcome (and I'll try to find time to review them), but I'd recommend ld64 for any real-world linking.<div><br></div><div>- Lang.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 27, 2017 at 11:06 AM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</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">Cc'ing people who are working on macOS.</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Apr 27, 2017 at 9:05 AM, Peter Kriens via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div style="word-wrap:break-word">Hopefully the right list … otherwise pointers appreciated (I’ve spent days trying to find a solution but could not find sufficient documentation, could not find a proper list of -flavor darwin commands)<div><br></div><div>I am setting up an environment for cross compiling shared libraries using LLVM. Overall this works perfectly for many unix like environments but MacOS is a pain in the ass despite that I am running on MacOS. (I’ve not tried windows yet.)</div><div><br></div><div>I seem to be able to compile with clang a proper mach object file for a hello function. However, when I link this function into a shared library I (surprisingly for a shared lib?) get undefined symbols like _printf, stub runtime: dyld_stub_binder, _main, etc. Using the flag </div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap"> </span>-undefined dynamic_lookup</div></div><div><br></div><div>I get no errors or warnings but then when I try to link the shared library to a main program I get the error:</div><div><br></div><div><div><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">      </span>ld: malformed dylib has MH_NO_REEXPORTED_DYLIBS flag </div><div><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">      </span>but no LC_REEXPORT_DYLIB load commands: ./libhello.dylib file './libhello.dylib'</div><div><br></div></div><div>I’ve included the shell file that makes the hello shared lib and the command that I use to link the file.</div><div><br></div><div>Thanks for any help, this looks like an amazing solution if it can get to work on all supported platforms.</div><div><br></div><div>Kind regards,</div><div><br></div><div><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">     </span>Peter Kriens</div><div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal">$ /usr/local/Cellar/llvm/4.0.0_1<wbr>/bin/<span style="color:#ff934f">clang</span> \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">       </span>-target x86_64-apple-darwin16.5.0 \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">  </span>-Ienvs/x86_64/apple/macos/darw<wbr>in/16.5.0/include  \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">       </span>-v \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap"> </span>-nostdinc \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">  </span>-fPIC \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">      </span>-c \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap"> </span>-Wno-nullability-completeness \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">      </span>hello.c x.c</div><div style="margin:0px;font-size:11px;line-height:normal;min-height:15px"><br></div><div style="margin:0px;line-height:normal;min-height:15px"><div style="margin:0px;line-height:normal;min-height:15px"><span style="font-size:11px">$ file hello.o</span></div><div style="margin:0px;line-height:normal;min-height:15px"><span style="font-size:11px">hello.o: Mach-O 64-bit object x86_64</span></div><div style="margin:0px;line-height:normal;min-height:15px"><span style="font-size:11px"><br></span></div><div style="margin:0px;line-height:normal;min-height:15px"><span style="font-size:11px">$ /usr/local/Cellar/llvm/4.0.0_1<wbr>/bin/ld.lld \</span></div></div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">   </span>-flavor darwin \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">     </span>-v \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap"> </span>-sdk_version 10.5.0 \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">        </span>-demangle \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">  </span>-<span style="color:#ff934f">arch</span> x86_64 \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">      </span>-undefined dynamic_lookup \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">  </span>-dylib \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">     </span>-dynamic \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">   </span>-o libhello.dylib \</div><div style="margin:0px;font-size:11px;line-height:normal"><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">  </span>hello.o</div></div><div><div style="margin:0px;line-height:normal;min-height:15px"><div style="margin:0px;line-height:normal;min-height:15px"><span style="font-size:11px"><br></span></div><div style="margin:0px;line-height:normal;min-height:15px"><span style="font-size:11px">$ file libhello.dylib </span></div><div style="margin:0px;line-height:normal;min-height:15px"><span style="font-size:11px">libhello.dylib: Mach-O 64-bit dynamically linked shared library x86_64</span></div><div><br></div></div></div><div>$ gcc x.c -L. -lhello</div><div>ld: malformed dylib has MH_NO_REEXPORTED_DYLIBS flag but no LC_REEXPORT_DYLIB load commands: ./libhello.dylib file ‘./libhello.dylib'</div><div><br></div><div><br></div><div><br></div></div><br></div></div>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>