Currently when we do -fuse-ld=lld for apple targets this invokes the gnu frontend because of the ld.lld alias
This creates a new alias for ld64 as ld64.lld to avoid this.
Details
- Reviewers
rnk ruiu rsmith - Commits
- rGe5639e9dd9d5: Driver: use ld64.lld when -fuse-ld=lld for darwin
rG1603fe281308: MACHO: ld64.lld alias for the MACHO LLD target
rLLD315865: MACHO: ld64.lld alias for the MACHO LLD target
rC315867: Driver: use ld64.lld when -fuse-ld=lld for darwin
rL315867: Driver: use ld64.lld when -fuse-ld=lld for darwin
rL315865: MACHO: ld64.lld alias for the MACHO LLD target
Diff Detail
- Repository
- rL LLVM
Event Timeline
I have a patch that does a bunch of updates for testing lld correctly in clang and this was a part of it but I didn't want the patch to get too involved so I separated this out.
I have seen this issue raised on various forums such as stackoverflow here and figured I would just fix it for users.
https://stackoverflow.com/questions/44106329/lld-unknown-argument-arch
tools/clang/lib/Driver/ToolChain.cpp | ||
---|---|---|
394 ↗ | (On Diff #116697) | Space between if and ( |
Is this for cross-compilation? If you invoke lld on macOS, it should act as ld64.
macOS lld is not actively maintained, so I wouldn't make it available more widely.
It is mostly for native compilation on mac but this will work for cross compiling also.
If you invoke lld on macOS, it should act as ld64.
That is if the file name is ld or if you pass the darwin flavour but that is not how clang invokes lld.
-fuse-ld=lld invokes ld.lld which is bound to the gnu frontend only, even on MacOS hosts.
The reason for introducing ld64 is so we can still cross compile from MacOS to linux targets cleanly.
macOS lld is not actively maintained, so I wouldn't make it available more widely.
It seems to be able to link simple programs at least.
A user has to specifically pass -fuse-ld=lld to use lld for apple targets, I'm not making it the default here.
Most importantly though it makes less sense to have users invoking the ELF linker for MACHO targets as I highlighted above.
This patch virtually sets ld64 the linker command name for macOS. I'd be a bit reluctant doing that, because ld64 sounds like a too generic name to indicate "a linker for macOS". But that's probably okay because we don't have a better name.
Can you get an LGTM from someone who owns the clang driver?
CODE_OWNERS.TXT does not have a list of driver owners.
It does have rsmith as an owner for all things not covered by someone else so I added him.
Reid usually reviews driver patches I submit to clang and is on the owner list so I added him here initially.
I think either should be fine.
ping @rnk
It's not a good name, but I do believe it is recognizable as the Darwin linker. It's also consistent with the names we invent on other platforms, which are essentially "native linker binary name plus lld".
Can you get an LGTM from someone who owns the clang driver?
lgtm
Thinking *LONG LONG* term, what I want to see happen is:
- Annotate the exported C++ API of libLLVM.so to ensure that this does not regress clang compilation time (avoids PLT indirection for calls internal to LLVM)
- Build with -fvisibility=hidden, so MachO and ELF builds of LLVM work like COFF
- Make building LLVM.dll/libLLVM.dylib/libLLVM.so the default
- Stop busy-boxing the LLD ports, and have separate executables for each: ld64.lld, lld-link.exe, and ld.lld
This will save disk space and potentially runtime if the loader keeps the LLVM shared object in memory, rather than loading a second copy for every link step in the buidl.