llvm-project/llvm
Kevin Gleason b052eead95 Fix -fuse-ld to be linker flag in feature detection check
Discovered an issue working in StableHLO when attempting to build with `-Wall -Werror`:
https://github.com/openxla/stablehlo/pull/137

Currently, if `LLVM_USE_LLD` and `-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -Wall -Werror"`
are both specified for build, the build will error with:

```
-- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Failed
CMake Error at /usr/local/google/home/gleasonk/Coding/llvm-build/lib/cmake/llvm/HandleLLVMOptions.cmake:309 (message):
  Host compiler does not support '-fuse-ld=lld'
...

$ cat <build_dir>/CMakeFiles/CMakeError.log
...
clang: error: argument unused during compilation: '-fuse-ld=lld' [-Werror,-Wunused-command-line-argument]
```

It looks like other repos have hit this same issue:
- https://github.com/golang/go/issues/41527 (mentioned in comment)
- https://github.com/iree-org/iree/pull/7450

This can be reproduced in llvm-project with the following build command:

```
# Compile command taken from https://mlir.llvm.org/getting_started/
# and modified for use case
cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_BUILD_EXAMPLES=ON \
   -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DCMAKE_CXX_COMPILER=clang++ \
   -DCMAKE_C_COMPILER=clang \
   -DLLVM_ENABLE_LLD=ON \
   -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -Wall -Werror"
```

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D134206
2022-09-21 04:01:57 +00:00
..
benchmarks
bindings [ConstantExpr] Remove fneg expression 2022-09-08 10:24:55 +02:00
cmake Fix -fuse-ld to be linker flag in feature detection check 2022-09-21 04:01:57 +00:00
docs [RISCV] Remove support for the unratified Zbt extension. 2022-09-20 20:26:48 -07:00
examples
include [RISCV] Remove support for the unratified Zbt extension. 2022-09-20 20:26:48 -07:00
lib [RISCV] Remove support for the unratified Zbt extension. 2022-09-20 20:26:48 -07:00
projects
resources
runtimes [NFC] Fix typo in comment 2022-09-20 17:22:08 -04:00
test [RISCV] Remove support for the unratified Zbt extension. 2022-09-20 20:26:48 -07:00
tools [AIX] llvm-nm support environment "OBJECT_MODE" for option -X on AIX OS 2022-09-19 11:27:19 -04:00
unittests Change isLittleEndian to follow llvm style and add an accessor 2022-09-20 17:00:47 -07:00
utils [GISel] TreeMatcher: always skip leaves if they don't care 2022-09-20 20:55:02 +00:00
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt [llvm] Remove libcxx, libcxxabi and libunwind from supported LLVM_ENABLE_PROJECTS 2022-09-20 11:12:51 -04:00
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in

README.txt

The LLVM Compiler Infrastructure
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.