clang currently requires the native linker on Solaris:
- It passes -C to ld which GNU ld doesn't understand.
- To use gld, one needs to pass the correct -m EMU option to select the right emulation. Solaris ld cannot handle that option.
So far I've worked around this by passing -DCLANG_DEFAULT_LINKER=/usr/bin/ld
to cmake. However, if someone forgets this, it depends on the user's PATH whether
or not clang finds the correct linker, which doesn't make for a good user experience.
While it would be nice to detect the linker flavor at runtime, this is more involved.
Instead, this patch defaults to /usr/bin/ld on Solaris. This doesn't work on its own,
however: a link fails with
clang-12: error: unable to execute command: Executable "x86_64-pc-solaris2.11-/usr/bin/ld" doesn't exist!
I avoid this by leaving absolute paths alone in ToolChain::GetLinkerPath.
Tested on amd64-pc-solaris2.11.
Ok for master?
swap then and else branches to avoid !