[llvm-dev] CMakeTestCCompiler fails

Mehdi AMINI via llvm-dev llvm-dev at lists.llvm.org
Mon Feb 3 21:06:27 PST 2020


On Mon, Feb 3, 2020 at 4:33 PM Itaru Kitayama via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Trunk clang does not pass CMake C Compiler test like below:
>
> CMake Error at
> /home/usr4/c74014i/opt/cmake-3.16.3-Linux-x86_64/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60
> (message):
>   The C compiler
>
>     "/home/usr4/c74014i/opt/clang/current/bin/clang"
>
>   is not able to compile a simple test program.
>
>   It fails with the following output:
>
>     Change Dir:
> /home/usr4/c74014i/work/build/202002040929/CMakeFiles/CMakeTmp
>
>     Run Build Command(s):/home/usr4/c74014i/opt/ninja/bin/ninja cmTC_35cb3
> && [1/2] Building C object CMakeFiles/cmTC_35cb3.dir/testCCompiler.c.o
>     [2/2] Linking C executable cmTC_35cb3
>     FAILED: cmTC_35cb3
>     : && /home/usr4/c74014i/opt/clang/current/bin/clang
>  CMakeFiles/cmTC_35cb3.dir/testCCompiler.c.o  -o cmTC_35cb3   && :
>     /usr/bin/ld: cannot find crtbegin.o: No such file or directory
>     /usr/bin/ld: cannot find -lgcc
>     /usr/bin/ld: cannot find -lgcc_s
>     clang-11: error: linker command failed with exit code 1 (use -v to see
> invocation)
>     ninja: build stopped: subcommand failed.
>
>
>
>
>
>   CMake will not be able to correctly generate this project.
> Call Stack (most recent call first):
>   CMakeLists.txt:49 (project)
>
> My configuration is shown below:
> cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DLLVM_PARALLEL_LINK_JOBS=2
> -DLLVM_ENABLE_LLD=ON -DLLVM_ENABLE_LIBCXX=OFF -DCMAKE_BUILD_TYPE=Release
> -DGCC_INSTALL_PREFIX=/pathto/gcc-7.5.0/ -DLIBOMPTARGET_ENABLE_DEBUG=ON
> -DCMAKE_INSTALL_PREFIX=$HOME/opt/clang/${today} -DCMAKE_C_COMPILER=clang
> -DCMAKE_C_FLAGS="" -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=""
> -DLLVM_ENABLE_PROJECTS="clang;openmp;lld;libcxx;libcxxabi"
> -DCLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_60
> -DLIBOMPTARGET_NVPTX_COMPUTE_CAPABILITIES=60 -DLLVM_TARGETS_TO_BUILD=all
> $HOME/projects/llvm-project/llvm
>

Before running cmake, are you able to compile a trivial C program by
invoking `clang test.c` ?  (create test.c with an empty main function
first).

If not then your clang install is just not working and I'd start by looking
into this. Running `clang -v test.c` will display a bunch of information
about what toolchain your clang driver found and what is it passing to the
linker invocation.

-- 
Mehdi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200203/6048bea5/attachment.html>


More information about the llvm-dev mailing list