[all-commits] [llvm/llvm-project] d39a9e: [Driver] Support GNU ld on Solaris

rorth via All-commits all-commits at lists.llvm.org
Fri Sep 1 12:43:03 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d39a9e3b4d4afc0321fea72b9d6b8a3908c45fc1
      https://github.com/llvm/llvm-project/commit/d39a9e3b4d4afc0321fea72b9d6b8a3908c45fc1
  Author: Rainer Orth <ro at gcc.gnu.org>
  Date:   2023-09-01 (Fri, 01 Sep 2023)

  Changed paths:
    M clang/lib/Driver/ToolChains/CommonArgs.cpp
    M clang/lib/Driver/ToolChains/Solaris.cpp
    M clang/lib/Driver/ToolChains/Solaris.h
    M clang/test/Driver/hip-link-bundle-archive.hip
    M clang/test/Driver/solaris-ld-sanitizer.c
    M clang/test/Driver/solaris-ld.c
    M compiler-rt/cmake/config-ix.cmake
    M compiler-rt/test/asan/TestCases/global-location-nodebug.cpp
    M flang/test/Driver/linker-flags.f90
    M llvm/cmake/modules/AddLLVM.cmake

  Log Message:
  -----------
  [Driver] Support GNU ld on Solaris

This patch supports GNU ld on Solaris in addition to Solaris ld, the
default.

- Linker selection is dynamic: one can switch between Solaris ld and GNU ld
  at runtime, with the default selectable with `-DCLANG_DEFAULT_LINKER`.

- Testcases have been adjusted to test both variants in case there are
  differences.

- The `compiler-rt/cmake/config-ix.cmake` and
  `llvm/cmake/modules/AddLLVM.cmake` changes to restrict the tests to
  Solaris ld are necessary because GNU accepts unknown `-z` options, but
  warns every time they are used, creating a lot of noise.  Since there
  seems to be no way to check for those warnings in
  `llvm_check_compiler_linker_flag` or `llvm_check_compiler_linker_flag`, I
  restrict the cmake tests to Solaris ld in the first place.

- The changes to `clang/test/Driver/hip-link-bundle-archive.hip` and
  `flang/test/Driver/linker-flags.f90` are required when LLVM is built with
  `-DCLANG_DEFAULT_LINKER=gld` on Solaris: `MSVC.cpp`
  `visualstudio::Linker::ConstructJob` ultimately calls
  `GetProgramPath("gld")`, resulting in a search for `gld`, which exists in
  `/usr/bin/gld` on Solaris.  With `-fuse-ld=`, this doesn't happen and the
  expected `link` is returned.

- `compiler-rt/test/asan/TestCases/global-location-nodebug.cpp` needs to
  enforce the Solaris ld, otherwise the test would `XPASS` with GNU ld
  which has the `-S` semantics expected by the test.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11` with both
`-DCLANG_DEFAULT_LINKER=gld` and the default, and `x86_64-pc-linux-gnu`.
No regressions in either case.

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




More information about the All-commits mailing list