[all-commits] [llvm/llvm-project] f59bec: [clang][Driver] Default to /usr/bin/ld on Solaris

rorth via All-commits all-commits at lists.llvm.org
Thu Aug 13 13:44:01 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: f59bec7acb8228fc215fca3ee1e524c38083c50b
      https://github.com/llvm/llvm-project/commit/f59bec7acb8228fc215fca3ee1e524c38083c50b
  Author: Rainer Orth <ro at gcc.gnu.org>
  Date:   2020-08-13 (Thu, 13 Aug 2020)

  Changed paths:
    M clang/lib/Driver/ToolChain.cpp
    M clang/lib/Driver/ToolChains/Solaris.h
    A clang/test/Driver/solaris-ld-sld.c
    M llvm/utils/lit/lit/llvm/config.py

  Log Message:
  -----------
  [clang][Driver] Default to /usr/bin/ld on Solaris

`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`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

Differential Revision: https://reviews.llvm.org/D84029




More information about the All-commits mailing list