李阳 via llvm-dev
2016-Apr-25 09:39 UTC
[llvm-dev] bug: cross-compile Clang/LLVM for ARM using Clang/LLVM
Hi all, I'm new to LLVM project and now I need to cross-compile Clang/LLVM for ARM. My host is Ubuntu 14.04 and I could compile Clang/LLVM for X86, however when I cross-compile Clang/LLVM for ARM, I come across a few problems. My build structure is in the picture. [llvm-source-code] is from github llvm-mirror; [build4x86] is that I follow the guide [Clang Getting Started] and build clang/llvm to produce it; [build4arm] is that I try to cross-compile clan/llvm for arm on x86 PC, the problem exist here. Sorry to finish reading, thanks. My command is as follows: CC='clang' CXX='clang++' cmake -G Ninja ../llvm-source-code -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX=./llvm -DLLVM_TABLEGEN=/home/lab/workspace/llvm/build4x86/bin/llvm-tblgen -DCLANG_TABLEGEN=/home/lab/workspace/llvm/build4x86/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/ -I/home/lab/workspace/llvm/llvm-source-code/lib4arm/ -I/home/lab/workspace/llvm/llvm-source-code/lib2ubuntu/ -I/usr/lib/gcc/x86_64-linux-gnu/4.8/libatomic.so -I/usr/lib/gcc/x86_64-linux-gnu/4.8/libatomic.so -L/usr/lib/gcc/x86_64-linux-gnu/4.8/libatomic.so -L/usr/lib/gcc/x86_64-linux-gnu/4.8/libatomic.a -mfloat-abi=hard -ccc-gcc-name arm-linux-gnueabihf-gcc' -DLLVM_ENABLE_LIBCXX=ON -DLLVM_ENABLE_PIC=False The error is as follows: 1. Host compiler appears to require libatomic, but cannot find it. 2. Host Clang must be able to find libstdc++4.7 or newer! Could anyone give me some suggestions? Thanks in advance! Best, Liyang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160425/192555b8/attachment-0001.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot from 2016-04-25 17:03:03.png Type: image/png Size: 17474 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160425/192555b8/attachment-0001.png>
Renato Golin via llvm-dev
2016-Apr-25 10:33 UTC
[llvm-dev] bug: cross-compile Clang/LLVM for ARM using Clang/LLVM
On 25 April 2016 at 10:39, 李阳 via llvm-dev <llvm-dev at lists.llvm.org> wrote:> CC='clang' CXX='clang++' cmake -G Ninja ../llvm-source-code > -DCMAKE_CROSSCOMPILING=True > -DCMAKE_INSTALL_PREFIX=./llvm > -DLLVM_TABLEGEN=/home/lab/workspace/llvm/build4x86/bin/llvm-tblgen > -DCLANG_TABLEGEN=/home/lab/workspace/llvm/build4x86/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/ > -I/home/lab/workspace/llvm/llvm-source-code/lib4arm/ > -I/home/lab/workspace/llvm/llvm-source-code/lib2ubuntu/ > -I/usr/lib/gcc/x86_64-linux-gnu/4.8/libatomic.so > -I/usr/lib/gcc/x86_64-linux-gnu/4.8/libatomic.so > -L/usr/lib/gcc/x86_64-linux-gnu/4.8/libatomic.so > -L/usr/lib/gcc/x86_64-linux-gnu/4.8/libatomic.a -mfloat-abi=hard > -ccc-gcc-name arm-linux-gnueabihf-gcc' > -DLLVM_ENABLE_LIBCXX=ON > -DLLVM_ENABLE_PIC=False >Hi Liyang, You have "LLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf" and "CMAKE_CXX_FLAGS='-target armv7a-linux-gnueabihf" which are different, and may confuse Clang when finding tools and libraries. Use whatever is the ARM triple in your system (looks like it's "arm-linux-gnueabihf") and make both target triple and "-target" to be that exact same string. Also, you're including x86_64 libraries (ex. -L/usr/lib/gcc/x86_64-linux-gnu/4.8/libatomic.so) to an ARM compilation job, that won't work. You have to find the ARM version (maybe /usr/lib/gcc/arm-linux-gnueabihf/ ?). Finally, the include paths with -I are only necessary if Clang cannot find it. The first three should be ok, but using -I on a DSO object (libatomic.so) makes no sense. cheers, --renato -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160425/8725b70b/attachment.html>