google / google/benchmark

[BUG] -DBENCHMARK_ENABLE_LTO=true fails to configure with XCode toolchain

Open
#1,198 6 comments 0 reactions 0 assignees View on GitHub
os:osx
Dominant language
C++
Stars
10.4k
Forks
1.8k
Avg merge
2d 4h
Merged PRs (30d)
8

Description

**Describe the bug**
Passing -DBENCHMARK_ENABLE_LTO=true to CMake with XCode toolchain results in error:
```
...
-- Performing Test HAVE_CXX_FLAG_FLTO
-- Performing Test HAVE_CXX_FLAG_FLTO - Success
-- Performing Test HAVE_CXX_FLAG_WNO_LTO_TYPE_MISMATCH
-- Performing Test HAVE_CXX_FLAG_WNO_LTO_TYPE_MISMATCH - Failed
CMake Error at /usr/local/Cellar/cmake/3.20.5/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find LLVMAr (missing: LLVMAR_EXECUTABLE)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.20.5/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
cmake/Modules/FindLLVMAr.cmake:9 (find_package_handle_standard_args)
cmake/llvm-toolchain.cmake:1 (find_package)
CMakeLists.txt:230 (include)

-- Configuring incomplete, errors occurred!
```

**System**
- OS: 11.4
- Compiler and version: Apple clang version 12.0.5 (clang-1205.0.22.11)

**To reproduce**
Steps to reproduce the behavior:
1. sync to commit e451e50e9b8af453f076dec10bd6890847f1624e
2. cmake -DBENCHMARK_ENABLE_LTO=true
3. See error

**Expected behavior**
No error, LTO enabled

**Additional context**
Looking at `/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin`, there is only `llvm-nm` tool, but no `llvm-ar` nor `llvm-ranlib`. The existing `ar` and `ranlib` tools do not seem to come from LLVM.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.