I am building llvm-clang cross tool chain for arm target, after successful build for Linux host now I am now building toolchain for arm target. However, I am getting below error message which seems to be confusing and not getting any idea how to resolve this issue.
#CC=‘clang’ CXX=‘clang++’ cmake -G Ninja /home/iiita/crossbuild/llvm -DLLVM_ENABLE_LIBCXX=ON -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX=/home/iiita/crossbuild/build -DLLVM_TABLEGEN=/home/iiita/llvm-3.8/build/bin/llvm-tblgen -DCLANG_TABLEGEN=/home/iiita/llvm-3.8/build/bin/clang-tblgen -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM -DCMAKE_CXX_FLAGS=‘-target armv7a-linux-gnueabihf -mcpu=cortex-a9 -I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/ -I/usr/arm-linux-gnueabihf/include/ -mfloat-abi=hard -ccc-gcc-name arm-linux-gnueabihf-gcc’
CMake Error at cmake/modules/CheckAtomic.cmake:33 (message):
Host compiler must support std::atomic!
Call Stack (most recent call first):
– Configuring incomplete, errors occurred!
See also “/home/iiita/crossbuild/build/CMakeFiles/CMakeOutput.log”.
See also “/home/iiita/crossbuild/build/CMakeFiles/CMakeError.log”.
Does anyone know how to resolve this issue or any other way to build tool chain for arm from source code?
CMakeError.log (12.6 KB)
It's possible that you don't have the required ARM libraries in your system?
I can think of two things:
1. You're using a triple that is different from your gcc name:
You should use the target as "arm-linux-gnueabihf".
2. You're not including the GCC headers or libraries.
You need to find where GCC keeps its libraries (normally
/usr/lib/gcc/arm-linux-gnueabihf) and headers (if necessary).
In your case, just adding -L"where your gcc libs are" should be enough.
Thanks a lot Renoto,
I really appreciate your help.
As you mentioned I have modified the command to include gcc libs path(-L ) option in cmake command as below :
cmake -G Ninja /home/iiita/crossbuild/llvm -DLLVM_ENABLE_PIC=False -DLLVM_ENABLE_LIBCXX=ON -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX=/home/iiita/crossbuild/build -DLLVM_TABLEGEN=/home/iiita/llvm-3.8/build/bin/llvm-tblgen -DCLANG_TABLEGEN=/home/iiita/llvm-3.8/build/bin/clang-tblgen -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM -DCMAKE_CXX_FLAGS=‘-target arm-linux-gnueabihf-gcc -mcpu=cortex-a9 -I/usr/arm-linux-gnueabihf/include/c++/4.7.3/arm-linux-gnueabihf/ -I/usr/arm-linux-gnueabihf/include/ -L/usr/lib/gcc/arm-linux-gnueabihf -mfloat-abi=hard -ccc-gcc-name arm-linux-gnueabihf-gcc’
However, I am still facing the issue since cmake not able to find header file path as per CMakeError.log (attached for email for reference) error message.
Do you have any idea about how to include header file path in cmake command line or is there any other thing I am missing?
CMakeError.log (14.5 KB)
The easiest way is to use "find /usr -name <header>" and then use the
directory that is the base for <header>.
Also, I couldn't find anywhere in my system (including ARM and AArch64
directories) the following headers:
* malloc/malloc.h (my malloc.h is directly that the include path, ie,
* ndir.h / sys/ndir.h / mach/mach.h / mach-o/dyld.h / histedit.h
(seems to be Apple specific?)
If you're moving your source from Apple to Linux you *will* need to
make it portable, and that includes choosing headers, defining macros,
I *did* find:
* cxxabi.h (it was directly on the include path, at
/usr/arm-none-eabi/include/c++/5.3.0/cxxabi.h, but you may have to add
that to -I)
* valgrind/valgrind.h (but only on my x86 include path, you may have
to install valgrind-dev:armhf)
Also, the error:
/usr/bin/ld: cannot find -lz
shows me that you don't have Zlib installed, you'll need that.