<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="">Thanks for the answer. However, this means I need a different linker for MacOS as for Windows/Linux?<div class=""><br class=""></div><div class="">I guess it is a not a major thing but I was hoping to set up a cross compile env. where only the header files and shared libraries differed :-( I guess we’re not there yet … :-)</div><div class=""><br class=""></div><div class="">Kind regards,</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">  </span>Peter Kriens</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 6 May 2017, at 19:57, Lang Hames <<a href="mailto:lhames@gmail.com" class="">lhames@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">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 class=""><br class=""></div><div class="">- Lang.</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Apr 27, 2017 at 11:06 AM, Rui Ueyama <span dir="ltr" class=""><<a href="mailto:ruiu@google.com" target="_blank" class="">ruiu@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="">Cc'ing people who are working on macOS.</div><div class="gmail_extra"><br class=""><div class="gmail_quote"><div class=""><div class="h5">On Thu, Apr 27, 2017 at 9:05 AM, Peter Kriens via llvm-dev <span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span> wrote:<br class=""></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><div class="h5"><div style="word-wrap:break-word" class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal" class=""><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">       </span>-undefined dynamic_lookup</div></div><div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class=""><div class=""><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap"> </span>ld: malformed dylib has MH_NO_REEXPORTED_DYLIBS flag </div><div class=""><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 class=""><br class=""></div></div><div class="">I’ve included the shell file that makes the hello shared lib and the command that I use to link the file.</div><div class=""><br class=""></div><div class="">Thanks for any help, this looks like an amazing solution if it can get to work on all supported platforms.</div><div class=""><br class=""></div><div class="">Kind regards,</div><div class=""><br class=""></div><div class=""><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap"> </span>Peter Kriens</div><div class=""><br class=""></div><div class=""><div style="margin:0px;font-size:11px;line-height:normal" class="">$ /usr/local/Cellar/llvm/4.0.0_1<wbr class="">/bin/<span style="color:#ff934f" class="">clang</span> \</div><div style="margin:0px;font-size:11px;line-height:normal" class=""><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" class=""><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">       </span>-Ienvs/x86_64/apple/macos/darw<wbr class="">in/16.5.0/include  \</div><div style="margin:0px;font-size:11px;line-height:normal" class=""><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" class=""><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" class=""><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" class=""><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" class=""><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" class=""><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" class=""><br class=""></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-size:11px" class="">$ file hello.o</span></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-size:11px" class="">hello.o: Mach-O 64-bit object x86_64</span></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-size:11px" class=""><br class=""></span></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-size:11px" class="">$ /usr/local/Cellar/llvm/4.0.0_1<wbr class="">/bin/ld.lld \</span></div></div><div style="margin:0px;font-size:11px;line-height:normal" class=""><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" class=""><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" class=""><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" class=""><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" class=""><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">       </span>-<span style="color:#ff934f" class="">arch</span> x86_64 \</div><div style="margin:0px;font-size:11px;line-height:normal" class=""><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" class=""><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" class=""><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" class=""><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" class=""><span class="m_-6203298060670998340m_-1814267315395156145Apple-tab-span" style="white-space:pre-wrap">       </span>hello.o</div></div><div class=""><div style="margin:0px;line-height:normal;min-height:15px" class=""><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-size:11px" class=""><br class=""></span></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-size:11px" class="">$ file libhello.dylib </span></div><div style="margin:0px;line-height:normal;min-height:15px" class=""><span style="font-size:11px" class="">libhello.dylib: Mach-O 64-bit dynamically linked shared library x86_64</span></div><div class=""><br class=""></div></div></div><div class="">$ gcc x.c -L. -lhello</div><div class="">ld: malformed dylib has MH_NO_REEXPORTED_DYLIBS flag but no LC_REEXPORT_DYLIB load commands: ./libhello.dylib file ‘./libhello.dylib'</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div><br class=""></div></div>______________________________<wbr class="">_________________<br class="">
LLVM Developers mailing list<br class="">
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-dev</a><br class="">
<br class=""></blockquote></div><br class=""></div>
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>