Unsupported gpu with nvcc fatal - makefile

when i run make
I got
nvcc fatal : Unsupported gpu architecture 'compute_30'
nvcc fatal : Unsupported gpu architecture 'compute_30'
CMake Error at libgromacs_generated_nbnxn_cuda.cu.o.Release.cmake:219 (message):
Error generating
/home/user/Desktop/gromacs-2019.6/build/src/gromacs/CMakeFiles/libgromacs.dir/mdlib/nbnxn_cuda/./libgromacs_generated_nbnxn_cuda.cu.o
I've nvidia rtx 2060 with ubuntu 18.4.5 and cuda-11.1
if there is anything i should write please tell me
Edit
line 219 of Makefile is
# Target rules for targets named missing-phys-val-phys
# Build rule for target.
missing-phys-val-phys: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 missing-phys-val-phys
.PHONY : missing-phys-val-phys
# fast build rule for target.
missing-phys-val-phys/fast:
$(MAKE) -f CMakeFiles/missing-phys-val-phys.dir/build.make CMakeFiles/missing-phys-val-phys.dir/build
.PHONY : missing-phys-val-phys/fast
Edit 2
when i ran
cmake .. -DGMX_BUILD_MDRUN_ONLY=on -DGMX_FFT_LIBRARY=fftw3
-DGMX_MPI=off -DGMX_GPU=on -DCMAKE_INSTALL_PREFIX=../install
i got
-- /usr/bin/nvcc standard error: 'In file included from /usr/include/host_config.h:50:0,
from /usr/include/cuda_runtime.h:78,
from <command-line>:0:
/usr/include/crt/host_config.h:121:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
#error -- unsupported GNU version! gcc versions later than 6 are not supported!
^~~~~

For building GROMACS on CUDA 11.x, use GROMACS 2020.4 or later and use a fresh, clean build.
In a fresh, empty directory on linux, with CUDA 11.1 installed, following these directions, I did:
mkdir gmxtest
cd gmxtest
wget --no-check-certificate http://ftp.gromacs.org/pub/gromacs/gromacs-2020.4.tar.gz
tar xfz gromacs-2020.4.tar.gz
cd gromacs-2020.4
mkdir build
mkdir install
cd build
cmake .. -DGMX_BUILD_MDRUN_ONLY=on -DGMX_FFT_LIBRARY=fftw3 -DGMX_MPI=off -DGMX_GPU=on -DCMAKE_INSTALL_PREFIX=../install
make
and I didn't have any trouble with the make command. For example it was definitely using nvcc to compile CUDA code successfully:
...
[ 30%] Generating baseversion-gen.cpp
[ 30%] Building NVCC (Device) object src/gromacs/CMakeFiles/libgromacs.dir/nbnxm/cuda/libgromacs_generated_nbnxm_cuda.cu.o
[ 30%] Building NVCC (Device) object src/gromacs/CMakeFiles/libgromacs.dir/nbnxm/cuda/libgromacs_generated_nbnxm_cuda_data_mgmt.cu.o
[ 30%] Building NVCC (Device) object src/gromacs/CMakeFiles/libgromacs.dir/nbnxm/cuda/libgromacs_generated_nbnxm_cuda_kernel_F_noprune.cu.o
...
Note, I'm not suggesting the above is the exact recipe you should use. In particular, modify the -Dxxx switches passed to the cmake command to match your desired build configuration.

I had the same problem installing gromacs 2018.3 in a computer with GTX1650, with NVCC (CUDA 11.0).
CMake could also not generate "build\src\gromacs\CMakeFiles\libgromacs.dir\mdlib\nbnxn_cuda.\libgromacs_generated_nbnxn_cuda.cu.o"
I found that in gmxManageNvccConfig.cmake is not stated the sm_75 which is the architecture of GTX1650. So, to solve this I copied an updated version (gromacs 2020.4) of this file that contains the architecture sm_75 to the same folder "gromacs-2018.3\cmake" and the problem was solved.

Related

How to resolve linker path error when using home-brew clang 13 in CMake project on macOS 12

In order to make use of newer C++ 17 and 20 features, I want to switch from Apple clang to a homebrew installed vanilla clang. I installed it via brew install llvm.
When trying to build a minimal CMake based test project like
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/local/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -G Ninja testProject
CMake fails with
-- The C compiler identification is Clang 13.0.0
-- The CXX compiler identification is Clang 13.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang
-- Check for working C compiler: /usr/local/opt/llvm/bin/clang - broken
CMake Error at /Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.20/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/usr/local/opt/llvm/bin/clang"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/me/Projects/testProject/build/CLion/Debug/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/local/bin/ninja cmTC_d2d4b && [1/2] Building C object CMakeFiles/cmTC_d2d4b.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_d2d4b
FAILED: cmTC_d2d4b
: && /usr/local/opt/llvm/bin/clang -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_d2d4b.dir/testCCompiler.c.o -o cmTC_d2d4b && :
ld: library not found for -lSystem
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
So it seems that it fails to locate the correct library search path out of the box.
When trying to build a simple hello world program from the command line like
/usr/local/opt/llvm/bin/clang++ main.cpp -isysroot /Library/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
It fails with even not finding some headers.
Supplying the header and library search path explicitly to the build command like
/usr/local/opt/llvm/bin/clang++ main.cpp -I"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include" -L"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"
makes it work. However, both are no solutions to make the built-in CMake compiler check work and they don't seem like the correct way to go.
Once this is working correctly, I'm furthermore interested in being able to compile ObjectiveC++ code which currently fails with even more errors.
I think I understand the problem that the compiler does not know the correct search paths, but I'm lacking some understanding about how it would normally figure out those search paths in a CMake project.
I finally managed to get it working by supplying a few linker flags through the LDFLAGS environment variable:
-L/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/usr/lib
In order to find the system libraries needed by the C compiler check
-L/usr/local/opt/llvm/lib
In order to find the C++ libraries as needed by the C++ compiler check
In order to successfully compile Objective-C code that links to Apple frameworks, I furthermore needed to add
-F/Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/System/Library/Frameworks -lobjc
With those flags, I now can successfully build my projects. Still, I'm not 100% sure if this is the right way, especially if the libraries linked from /usr/local/opt/llvm/lib can be expected to be present on all target systems?

CMake reports broken g++ and missing libiconv-2.dll

I have some strange problem with CMake when I press Configure button.
It reports me all the time that libiconv-2.dll is missing and fails to finish operation. However, this library is present in MinGW/bin folder.
I am using CodeBlocks-MinGW Makefiles and CMake version 3.6.1 - 32 bit version (although this same problem is with 64 bit version).
One interesting thing is that in consol it shows:
The CXX compiler identification is unknown
Check for working CXX compiler: C:/MinGW/bin/g++.exe
Check for working CXX compiler: C:/MinGW/bin/g++.exe -- broken
MinGW is correctly added to the system path and I was able to check version (GNU 4.8.1) and also compile simple hello world from command line using:
g++ test.cpp -o test
Testing this same CMakeLists file on another machine with this same configuration, but older CMake version 3.2.3 everything works. Doing some research online I've found that problem with this file is not new, so I doubt this is version problem.
Anyone has any idea what can be done more?
EDIT 1
This is the content of CMakeError.log
Compiling the CXX compiler identification source file
"CMakeCXXCompilerId.cpp" failed. Compiler: C:/MinGW/bin/g++.exe Build
flags: Id flags:
The output was: 1
Compiling the CXX compiler identification source file
"CMakeCXXCompilerId.cpp" failed. Compiler: C:/MinGW/bin/g++.exe Build
flags: Id flags: -c
The output was: 1
Checking whether the CXX compiler is IAR using "" did not match "IAR
.+ Compiler": g++.exe: fatal error: no input files compilation
terminated. Determining if the CXX compiler works failed with the
following output: Change Dir:
C:/Users/testuser/Desktop/build/CMakeFiles/CMakeTmp
Run Build Command:"C:/MinGW/bin/mingw32-make.exe" "cmTC_c9a03/fast"
C:/MinGW/bin/mingw32-make.exe -f CMakeFiles\cmTC_c9a03.dir\build.make
CMakeFiles/cmTC_c9a03.dir/build
mingw32-make.exe1: Entering directory
'C:/Users/testuser/Desktop/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_c9a03.dir/testCXXCompiler.cxx.obj
C:\MinGW\bin\g++.exe -o
CMakeFiles\cmTC_c9a03.dir\testCXXCompiler.cxx.obj -c
C:\Users\testuser\Desktop\build\CMakeFiles\CMakeTmp\testCXXCompiler.cxx
CMakeFiles\cmTC_c9a03.dir\build.make:64: recipe for target
'CMakeFiles/cmTC_c9a03.dir/testCXXCompiler.cxx.obj' failed
mingw32-make.exe1: ***
[CMakeFiles/cmTC_c9a03.dir/testCXXCompiler.cxx.obj] Error 1
mingw32-make.exe1: Leaving directory
'C:/Users/testuser/Desktop/build/CMakeFiles/CMakeTmp'
Makefile:125: recipe for target 'cmTC_c9a03/fast' failed
mingw32-make.exe: *** [cmTC_c9a03/fast] Error 2
I have manually compiled the file testCXXCompiler.cpp with g++ and it worked. There was no error during compilation.
EDIT 2
I have created SSCCE to test if problem isn't with some dependencies or some other code-related things. But testing this file:
test.cpp
#include <iostream>
int main()
{
std::cout << "Test" << std::endl;
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(Test)
add_executable(Test test.cpp)
I have still problems with missing library. The console output changed however slightly and now it is:
The C compiler identification is unknown
The CXX compiler identification is unknown
Check for working C compiler: C:/MinGW/bin/gcc.exe
Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
I suppose I have found the answer. At least it is working for me.
Apparently I needed to run the CMake on the other machine as an Administrator. This way I assume it could accessed to GCC files correctly. However, I am not completely sure why on the other machine it wasn't required and worked just fine.
You might need to reinstall the lib
mingw-get install --reinstall mingw32-libiconv-dll
I had a very similar problem, and it was fixed this way.

caffe cmake error by ccache

When I successfully 'cmake ..' caffe build, I preceed with 'make all' command but came up with an error below. I don't know if there is something wrong with NVCC or gcc.
[ 1%] Built target proto
[ 1%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/layers/cuda_compile_generated_split_layer.cu.o
/usr/bin/ccache: invalid option -- 'E'
Usage:
ccache [options]
ccache compiler [compiler options]
compiler [compiler options] (via symbolic link)
Options:
-c, --cleanup delete old files and recalculate size counters
(normally not needed as this is done automatically)
-C, --clear clear the cache completely
-F, --max-files=N set maximum number of files in cache to N (use 0 for
no limit)
-M, --max-size=SIZE set maximum size of cache to SIZE (use 0 for no
limit; available suffixes: G, M and K; default
suffix: G)
-s, --show-stats show statistics summary
-z, --zero-stats zero statistics counters
-h, --help print this help text
-V, --version print version and copyright information
See also <http://ccache.samba.org>.
CMake Error at cuda_compile_generated_split_layer.cu.o.cmake:206 (message):
Error generating
/home/gpuusr/lpq/caffe-332/build/src/caffe/CMakeFiles/cuda_compile.dir/layers/./cuda_compile_generated_split_layer.cu.o
make[2]: *** [src/caffe/CMakeFiles/cuda_compile.dir/layers/cuda_compile_generated_split_layer.cu.o] Error 1
make[1]: *** [src/caffe/CMakeFiles/caffe.dir/all] Error 2
make: *** [all] Error 2
I had a similar issue trying to build OpenCV with CUDA support. There's some odd interaction between CMake, CUDA, and ccache that I don't understand, it's trying to call ccache with invalid arguments. You can bypass this by specifying your system compiler for CUDA instead:
cmake -DCUDA_HOST_COMPILER=/usr/bin/g++ ..
(Or whatever compiler you're using.)
This used to be a bug in CMake. It was fixed with CMake release 3.4.0.
Proof
The code from here can be compiled with the following CMakeLists.txt.
cmake_minimum_required (VERSION 2.8.9 FATAL_ERROR)
project(CudaTest)
find_package(CUDA REQUIRED)
cuda_add_executable(hello_cuda hello.cu)
With /usr/lib/ccache on the PATH.
Building once with CMake 3.2 and once with CMake 3.7.1.
CMake 3.2:
$ make
...
/path/to/build-3.2
[100%] Building NVCC (Device) object CMakeFiles/hello_cuda.dir/hello_cuda_generated_hello.cu.o
/usr/bin/ccache: invalid option -- 'E'
...
CMake 3.7.1:
$ make
[ 50%] Building NVCC (Device) object CMakeFiles/hello_cuda.dir/hello_cuda_generated_hello.cu.o
[100%] Linking CXX executable hello_cuda
[100%] Built target hello_cuda
For the record
A small git bisect run over CMake 3.2.2 -- 3.7.1 shows that this is the commit that fixed it:
commit b405f01daaeaeda98d448e2f0d71ea685757a5bd
Author: Bill Hoffman <bill.hoffman#kitware.com>
Date: Fri Jun 12 14:16:09 2015 -0400
FindCUDA: Resolve a host compiler symlink only if it is Apple cc - clang
Otherwise using a "cc -> ccache" or similar symlink as the compiler
causes FindCUDA to select ccache as the host compiler. Update the logic
added by commit v3.1.0-rc1~354^2 (FindCUDA: Fix OSX Clang & no C
language enabled, 2014-06-12) to apply only in the specific case it is
needed.
This commit went into CMake 3.4.0. Compare git rev-list v3.4.0 | grep b405f01 with git rev-list v3.3.2 | grep b405f01.

Caffe compilation fails due to unsupported gcc compiler version

I struggle with Caffe compilation. Unfortunately I failed to compile it.
Steps I followed:
git clone https://github.com/BVLC/caffe.git
cd caffe
mkdir build
cd build
cmake ..
make all
Running make all fails with the following error message:
[ 2%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/util/cuda_compile_generated_im2col.cu.o
In file included from /usr/include/cuda_runtime.h:59:0,
from <command-line>:0:
/usr/include/host_config.h:82:2: error: #error -- unsupported GNU version! gcc 4.9 and up are not supported!
#error -- unsupported GNU version! gcc 4.9 and up are not supported!
^
CMake Error at cuda_compile_generated_im2col.cu.o.cmake:207 (message):
Error generating /mydir/caffe/build/src/caffe/CMakeFiles/cuda_compile.dir/util/./cuda_compile_generated_im2col.cu.o
Software version:
OS: Debian.
gcc version: 5.3.1.
nvcc version: 6.5.12.
cat /proc/driver/nvidia/version result:
NVRM version: NVIDIA UNIX x86_64 Kernel Module 352.63 Sat Nov 7 21:25:42 PST 2015
GCC version: gcc version 4.8.5 (Debian 4.8.5-3)
Attempts to solve the problem
1st try
Simple solutions are often best ones, so (as suggested here) I tried to comment out macro checking gcc version from /usr/include/host_config.h (line 82). Unfortunately it doesn't work and compilation fails badly:
1 catastrophic error detected in the compilation of "/tmp/tmpxft_000069c2_00000000-4_im2col.cpp4.ii".
2nd try
I tried to run:
cmake -D CMAKE_CXX_COMPILER=g++-4.8 ..
make
but it fails with exactly the same error message (even though g++-4.8 should be accepted).
3rd try
I've found similar problem (though not related to Caffe) and I tried to solve it as suggested in the accepted answer.
What I did:
I've ran grep -iR "find_package(CUDA" caffe command and found Cuda.cmake file which has find_package(CUDA 5.5 QUIET) in line 225.
I added set(CUDA_HOST_COMPILER /usr/bin/gcc-4.8) to Cuda.cmake, line before line: find_package(CUDA 5.5 QUIET).
I removed everything from build directory and ran cmake and make again - with and without -D CMAKE_CXX_COMPILER=g++-4.8.
Unfortunately result is exactly the same. Caffe probably overwrites it somehow - I didn't figure it out how.
make VERBOSE=1 2>&1 | grep -i compiler-bindir returns nothing.
What's interesting, make VERBOSE=1 prints command that fails, which is:
/usr/bin/nvcc -M -D__CUDACC__ /mydir/caffe/src/caffe/util/im2col.cu -o /mydir/caffe/build/src/caffe/CMakeFiles/cuda_compile.dir/util/cuda_compile_generated_im2col.cu.o.NVCC-depend -ccbin /usr/bin/cc -m64 -DUSE_LMDB -DUSE_LEVELDB -DUSE_OPENCV -DWITH_PYTHON_LAYER -DGTEST_USE_OWN_TR1_TUPLE -Xcompiler ,\"-fPIC\",\"-Wall\",\"-Wno-sign-compare\",\"-Wno-uninitialized\",\"-O3\",\"-DNDEBUG\" -gencode arch=compute_20,code=sm_21 -Xcudafe --diag_suppress=cc_clobber_ignored -Xcudafe --diag_suppress=integer_sign_change -Xcudafe --diag_suppress=useless_using_declaration -Xcudafe --diag_suppress=set_but_not_used -Xcompiler -fPIC -DNVCC -I/usr/include -I/mydir/caffe/src -I/usr/include -I/mydir/caffe/build/include -I/usr/include/hdf5/serial -I/usr/include/opencv -I/usr/include/atlas -I/usr/include/python2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/mydir/caffe/include -I/mydir/caffe/build
when I add --compiler-bindir /usr/bin/gcc-4.8 flag manually, it prints error:
nvcc fatal : redefinition of argument 'compiler-bindir'
which may be related to this bug report.
Edit: I didn't notice that --compiler-bindir and -ccbin are the same options, and the latter is already set in above command that failed. When I changed -ccbin /usr/bin/cc to -ccbin /usr/bin/gcc-4.8 in above command that failed, it completes successfully. Now I need to find option in Caffe's CMake file that overwrite -ccbin in all subsequent Caffe's CMakes. Looking at cmake/Cuda.cmake:252:list(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_EXTRA} seems to be good way to go.
How can I successfully complete my compilation? Any help is appreciated.
Related SO questions:
host_config.h:unsupported GNU version! gcc versions later than 4.9 are not supported.
CUDA 6.5 complains about not supporting gcc 4.9 - what to do?.
cmake -D CUDA_NVCC_FLAGS="-ccbin gcc-4.8" .. && make causes successful compilation.
Now another problem showed up: linking Google's libgflags or libprotobuf fails probably due to fact that it was compiled with newer gcc version but it's not related to asked question.
My machine runs Ubuntu 15.10, and my default compiler version is gcc 5.2.1 .
Commenting out the #error directive in line 115 of file
/usr/local/cuda-7.5/include/host_config.h
(or whatever the path on your system is) did the trick for me. Caffe compiled fine, all tests ran smoothly.
On the other hand, if one chooses to ignore this and proceed to compile part of the project with one compiler version, part of the project with another (for me it was gcc-4.8 and gcc-5.2.1), linking problems will arise. The linking problems of protobuf and libgflags another answer mentions are not unrelated to this.

Building and packaging LLVM clang 3.4 with cmake

I started studying cmake about 2 weeks ago and like it. Thus far, I have been successful in building and packaging (with the native system packaging format) libc++abi, libc++, llvm 3.4 all with cmake (libc++abi with my own cmake setup) for RHEL 6.x, Fedora 20+, and Ubuntu 12.04 LTS+.
I would like to create a C++ build environment that
Frees us from dependency on GNU GCC and libstdc++ completely (thus we don't want any LLVM RPM/DEB from these aforementioned distros or the LLVM Debian/Ubuntu nightly packages download site)
Enables us to explore fully C++11 and C++1y. In other words, we can try even the bleeding edge LLVM/clang anytime we want to while keeping all our build systems clean with package management systems.
Nevertheless, I hit a snag in attempting to build clang 3.4 with cmake, on a build host running Ubuntu 12.04 LTS 64bit, with a pure clang 3.3 built by me without any dependency on GNU libstdc++, together with libc++ 3.3 and libc++abi. The later two have no libstdc++ dependency either. I built both that way too.
I know of the Clang - Getting Started Web page really well and have used the instructions there successfully. But these are exactly what I don't want to use. They are incorrect too: the CMakeLists.txt of clang 3.4 clearly states the following:
1 # If we are not building as a part of LLVM, build Clang as an
2 # standalone project, using LLVM as an external library:
3 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
4 project(Clang)
5 cmake_minimum_required(VERSION 2.8)
6
7 set(CLANG_PATH_TO_LLVM_SOURCE "" CACHE PATH
8 "Path to LLVM source code. Not necessary if using an installed LLVM.")
9 set(CLANG_PATH_TO_LLVM_BUILD "" CACHE PATH
10 "Path to the directory where LLVM was built or installed.")
See line 1 and 2. But, I have not found any LLVM documentation regarding how to set the CLANG_PATH_TO_LLVM_BUILD. I tried the following:
cmake -DCLANG_PATH_TO_LLVM_BUILD="../../llvm-3.4/build" ..
and got the following errors:
$ clang3.4/_tars/clang-3.4/build$ cmake -DCLANG_PATH_TO_LLVM_BUILD="../../llvm-3.4/build" ..
-- The C compiler identification is Clang 3.3.0
-- The CXX compiler identification is Clang 3.3.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at CMakeLists.txt:39 (include):
include could not find load file:
AddLLVM
CMake Error at CMakeLists.txt:40 (include):
include could not find load file:
TableGen
-- Performing Test C_SUPPORTS_FLAG
-- Performing Test C_SUPPORTS_FLAG - Success
-- Performing Test CXX_SUPPORTS_FLAG
-- Performing Test CXX_SUPPORTS_FLAG - Success
-- Building with -fPIC
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG
-- Performing Test SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG - Success
-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.7.8")
-- Clang version: 3.4
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG - Success
CMake Error at utils/TableGen/CMakeLists.txt:3 (add_tablegen):
Unknown CMake command "add_tablegen".
-- Configuring incomplete, errors occurred!
But that's not right! The LLVM + compiler-rt has been installed on the build host with our own DEB. And,
$ llvm/clang3.4/_tars/clang-3.4/build$ ls /usr/share/llvm/cmake
AddLLVM.cmake ChooseMSVCCRT.cmake linux_issue.cmake LLVMConfigVersion.cmake pkg.cmake
AddLLVMDefinitions.cmake GetSVN.cmake LLVM-Config.cmake LLVMParseArguments.cmake TableGen.cmake
arch.cmake HandleLLVMOptions.cmake LLVMConfig.cmake LLVMProcessSources.cmake
So, all required cmake modules are there - right on the system!
I would appreciate a hint as to how to coerce clang 3.4 to build with cmake, with an already installed LLVM 3.4 + compiler-rt 3.4.
Update:
I decided to do the following:
$ llvm/clang3.4/_tars/clang-3.4/build$ cmake -DCLANG_PATH_TO_LLVM_BUILD="/usr" ..
-- Building with -fPIC
-- Clang version: 3.4
-- Found Subversion: /usr/bin/svn (found version "1.6.17")
-- Configuring done
-- Generating done
-- Build files have been written to: ../llvm/clang3.4/_tars/clang-3.4/build
../llvm/clang3.4/_tars/clang-3.4/build$ make -j 2
Scanning dependencies of target ClangDriverOptions
Scanning dependencies of target clang-tblgen
[ 0%] Building Options.inc...
[ 0%] ../llvm/clang3.4/_tars/clang-3.4/include/clang/Driver/Options.td:15:9: error: Could not find include file 'llvm/Option/OptParser.td'
include "llvm/Option/OptParser.td"
^
.../llvm/clang3.4/_tars/clang-3.4/include/clang/Driver/Options.td:15:9: Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangASTNodesEmitter.cpp.o
error: Unexpected input at top level
include "llvm/Option/OptParser.td"
^
make[2]: *** [include/clang/Driver/Options.inc.tmp] Error 1
make[1]: *** [include/clang/Driver/CMakeFiles/ClangDriverOptions.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 0%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangAttrEmitter.cpp.o
[ 0%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentCommandInfoEmitter.cpp.o
[ 0%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangCommentHTMLTagsEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangDiagnosticsEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangSACheckersEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/NeonEmitter.cpp.o
[ 1%] Building CXX object utils/TableGen/CMakeFiles/clang-tblgen.dir/TableGen.cpp.o
Linking CXX executable ../llvm/clang3.4/_tars/llvm-3.4/build/bin/clang-tblgen
[ 1%] Built target clang-tblgen
make: *** [all] Error 2
That's better. Looks like clang 3.4's default CMakeLists.txt is not even QA-ed x-( Yikes x-(
I decided to tough it out as any self-respecting engineer would do :) I simply vi-ed the following two files and add full path to the offending include, and then that's that.
Options.td
CC1AsOptions.td
Now I can build all desired LLVM main projects without libstdc++ dependency, all linked with libc++ and libc++abi. Hooray :)
So, I have confirmed that
Some instructions given in Getting Started: Building and Running Clang are misleading, e.g. 7.
All main LLVM projects (except compiler-rt AFAIK) can be built with cmake. There is no need to lump them together under the LLVM source tree for building. You definitely can build nearly all of them separately on Linux, unlike what these "official" documentation may lead you to believe :>
The LLVM team should really think through and minimize the apparent cyclic dependency among all projects. Bootstrapping LLVM/clang on various Linux distros (especially older ones such as RHEL 5.x) without GNU libstdc++ dependency is too tedious - speaking from my first hand experience. They can be done (I have done it :) but it's not for the faint of heart.
I think this project does what you're trying to do:
https://github.com/rsmmr/install-clang
I've used it on FC16+, but did run into bootstrapping issues on RHEL5.x.
I tried many ways and find that just copy llvm/include/llvm to this Driver dir and it will work.

Resources