[lld] Well lld support some advanced features like gnu linker in macOS?

Hi, llvm developers. I can’t find a lld-dev mail list, so just mail to here.

ld in macOS is legacy, lld a more modern linker. I have test, -fuse-ld=lld, -Wl,--as-needed , but its output is:

/usr/local/bin/ld.lld: error: unknown argument: -dynamic

/usr/local/bin/ld.lld: error: unknown argument: -arch

/usr/local/bin/ld.lld: error: unknown argument: -search_paths_first

/usr/local/bin/ld.lld: error: unknown emulation: acosx_version_min

/usr/local/bin/ld.lld: error: unable to find library -lto_library

/usr/local/bin/ld.lld: error: /usr/local/Cellar/llvm/5.0.0/lib/libLTO.dylib: invalid data encoding

Seems lld is working in progress. I hope lld will support some advanced features like --as-need --start-group --end-group flags in macOS, they are very useful !

I don't think the MachO side of lld is currently being developed.

Cheers,
Rafael

gao ge via llvm-dev <llvm-dev@lists.llvm.org> writes:

Additionally, those errors sound like you invoked the ELF port of LLD. In 6.0, the Mach-O will be called ld64.lld (and clang’s linker selection logic has been updated accordingly), so that the ELF and Mach-O ports can be disambiguated.

ld64 is pretty modern/performant in my experience, which might be part of the reason the LLD Mach-O efforts have stalled. Even if that port were revived, its command line interface would probably mirror ld64’s and not GNU ld’s, so you may not get the options you’re looking for.

I just did a bit of experimentation, and it appears that ld64 doesn’t appear to care about the ordering of static libraries on the command line, in which case --start-group and --end-group are unnecessary. I couldn’t find any direct analog to --as-needed, but you can build a dynamic library with -mark_dead_strippable_dylib, which achieves a similar effect of only pulling in that library when functions from it are referenced.

I don’t think the MachO side of lld is currently being developed.

Cheers,

Rafael

gao ge via llvm-dev llvm-dev@lists.llvm.org writes: