[all-commits] [llvm/llvm-project] 2feb72: [cmake] Don't pass -z discard-unused to Illumos ld

rorth via All-commits all-commits at lists.llvm.org
Fri Jun 12 00:57:29 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 2feb72bcd58cabb9f71538cb17fab459b6afc8ef
      https://github.com/llvm/llvm-project/commit/2feb72bcd58cabb9f71538cb17fab459b6afc8ef
  Author: Rainer Orth <ro at gcc.gnu.org>
  Date:   2020-06-12 (Fri, 12 Jun 2020)

  Changed paths:
    M llvm/cmake/modules/AddLLVM.cmake

  Log Message:
  -----------
  [cmake] Don't pass -z discard-unused to Illumos ld

I'm currently working to port `libc++` to Solaris.  There exists a slightly
bitrotten port already, which was done on Illumos, an OpenSolaris
derivative.  In order not to break that port with my work, I need to test
the result on both Solaris and Illumos.  While doing so, it turned out that
Illumos `ld` doesn't support the `-z discard-sections=unused` option
currently used on SunOS unconditionally.

While there exists a patch
<https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/developer/clang-90/patches/02-cmake_modules_AddLLVM.cmake.patch>
for LLVM 9.0 in the OpenIndiana repository, it apparently hasn't been
submitted upstream and is completely wrong: it replaces
`-z discard-sections=unused` with `-z ignore`.  In terms of the equivalent
`gld` options, this means replacing `--gc-sections` with `--as-needed`.

This patch instead tests if the linker actually supports the option before
using it.

Tested on `amd64-pc-solaris2.11` (all of Solaris 11.4, 11.3 and OpenIndiana
2020.04).

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




More information about the All-commits mailing list