facebook / infer

A static analyzer for Java, C, C++, and Objective-C
http://fbinfer.com/
MIT License
14.96k stars 2.02k forks source link

Unable to build facebook-clang-plugins due to `CMAKE_LINKER-NOTFOUND` #1534

Open aytey opened 3 years ago

aytey commented 3 years ago

I'm trying to build infer @ 23a915e (well, #1532) but my build fails with:

: && /usr/bin/cmake -E rm -f /home/avj/tmp/clang-setup.LYj2xK/build/lib/clang/12.0.1/lib/linux/libclang_rt.fuzzer_
interceptors-x86_64.a && /home/avj/tmp/clang-setup.LYj2xK/build/bin/llvm-ar qc /home/avj/tmp/clang-setup.LYj2xK/bu
ild/lib/clang/12.0.1/lib/linux/libclang_rt.fuzzer_interceptors-x86_64.a  lib/fuzzer/CMakeFiles/RTfuzzer_intercepto
rs.x86_64.dir/FuzzerInterceptors.cpp.o && /home/avj/tmp/clang-setup.LYj2xK/build/bin/llvm-ranlib /home/avj/tmp/cla
ng-setup.LYj2xK/build/lib/clang/12.0.1/lib/linux/libclang_rt.fuzzer_interceptors-x86_64.a && cd /home/avj/tmp/clan
g-setup.LYj2xK/build/tools/clang/runtime/compiler-rt-bins/lib/fuzzer/cxx_x86_64_merge.dir && CMAKE_LINKER-NOTFOUND
 --whole-archive /home/avj/tmp/clang-setup.LYj2xK/build/lib/clang/12.0.1/lib/linux/libclang_rt.fuzzer_interceptors
-x86_64.a --no-whole-archive /home/avj/tmp/clang-setup.LYj2xK/build/tools/clang/runtime/compiler-rt-bins/lib/fuzze
r/libcxx_fuzzer_x86_64/lib/libc++.a -r -o fuzzer_interceptors.o && /home/avj/tmp/clang-setup.LYj2xK/build/bin/llvm
-objcopy --localize-hidden fuzzer_interceptors.o && /usr/bin/cmake -E remove /home/avj/tmp/clang-setup.LYj2xK/buil
d/lib/clang/12.0.1/lib/linux/libclang_rt.fuzzer_interceptors-x86_64.a && /home/avj/tmp/clang-setup.LYj2xK/build/bi
n/llvm-ar qcs /home/avj/tmp/clang-setup.LYj2xK/build/lib/clang/12.0.1/lib/linux/libclang_rt.fuzzer_interceptors-x86_64.a fuzzer_interceptors.o
/bin/sh: line 1: CMAKE_LINKER-NOTFOUND: command not found

I'm yet to try it, but it seems there's two causes:

  1. You don't have lld installed: https://gitlab.kitware.com/cmake/cmake/-/issues/22500#note_993575
  2. Your CMake is "too old" (it was only fixed in August 2021 and so is in CMake 3.21.2; https://gitlab.kitware.com/cmake/cmake/-/commit/788b7afff20a59bada4dbb21418d9f83290996c6)

This is more of an FYI if other people hit the same issue.

aytey commented 3 years ago

Doing 2 (i.e., updating to CMake 3.21.3) resolves the issue (i.e., CMAKE_LINKER is set to /usr/bin/ld not CMAKE_LINKER-NOTFOUND).

aytey commented 3 years ago

Seems pretty conclusive: