[llvm-dev] ld.lld on MacOS question
Peter Kriens via llvm-dev
llvm-dev at lists.llvm.org
Thu May 11 10:37:46 PDT 2017
Thanks for the answer. However, this means I need a different linker for MacOS as for Windows/Linux?
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 … :-)
Kind regards,
Peter Kriens
> On 6 May 2017, at 19:57, Lang Hames <lhames at gmail.com> wrote:
>
> 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.
>
> - Lang.
>
>
> On Thu, Apr 27, 2017 at 11:06 AM, Rui Ueyama <ruiu at google.com <mailto:ruiu at google.com>> wrote:
> Cc'ing people who are working on macOS.
>
> On Thu, Apr 27, 2017 at 9:05 AM, Peter Kriens via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote:
> 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)
>
> 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.)
>
> 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
>
> -undefined dynamic_lookup
>
> I get no errors or warnings but then when I try to link the shared library to a main program I get the error:
>
> ld: malformed dylib has MH_NO_REEXPORTED_DYLIBS flag
> but no LC_REEXPORT_DYLIB load commands: ./libhello.dylib file './libhello.dylib'
>
> I’ve included the shell file that makes the hello shared lib and the command that I use to link the file.
>
> Thanks for any help, this looks like an amazing solution if it can get to work on all supported platforms.
>
> Kind regards,
>
> Peter Kriens
>
> $ /usr/local/Cellar/llvm/4.0.0_1/bin/clang \
> -target x86_64-apple-darwin16.5.0 \
> -Ienvs/x86_64/apple/macos/darwin/16.5.0/include \
> -v \
> -nostdinc \
> -fPIC \
> -c \
> -Wno-nullability-completeness \
> hello.c x.c
>
> $ file hello.o
> hello.o: Mach-O 64-bit object x86_64
>
> $ /usr/local/Cellar/llvm/4.0.0_1/bin/ld.lld \
> -flavor darwin \
> -v \
> -sdk_version 10.5.0 \
> -demangle \
> -arch x86_64 \
> -undefined dynamic_lookup \
> -dylib \
> -dynamic \
> -o libhello.dylib \
> hello.o
>
> $ file libhello.dylib
> libhello.dylib: Mach-O 64-bit dynamically linked shared library x86_64
>
> $ gcc x.c -L. -lhello
> ld: malformed dylib has MH_NO_REEXPORTED_DYLIBS flag but no LC_REEXPORT_DYLIB load commands: ./libhello.dylib file ‘./libhello.dylib'
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170511/d1a9bf72/attachment.html>
More information about the llvm-dev
mailing list