mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-04 16:41:43 +00:00

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
See docs/CMake.html for instructions on how to build LLVM with CMake.