[cfe-dev] Consult how to cross compile clang for arm on x86 linux ubuntu box

Dongdong Yang via cfe-dev cfe-dev at lists.llvm.org
Wed Aug 19 19:15:28 PDT 2020

I can get llvm source code and the information “cross-compiling from x86_64
to ARM” from https://llvm.org/docs/HowToCrossCompileLLVM.html. However, I
still fail to build clang for ARM. It is strange, I have already set a
target with "   -target arm-linux-gnueabihf  "  .  I am describing the
failure progress as below. Expecting any idea.

The build steps:
cd llvm-project
mkdir build
cd build
cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles"
// After I built host llvm-tblgen  and clang-tblgen, I begin to return to
build arm target clang as below steps:
cd ..
mkdir build_arm_onx86
cd build_arm_onx86
mkdir stall_prefix
cmake -G "Unix Makefiles" -DCMAKE_CROSSCOMPILING=True
arm-linux-gnueabihf  -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi"
../llvm    2>&1
| tee out_cofiguration.txt
make  2>&1 | tee out_make.txt

The result:
build_arm_onx86$ file bin/clang-12
bin/clang-12: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux),
dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux
2.6.32, BuildID[sha1]=3b669c10e300bb5d9bb96cfb77f927ce95728ca6, not stripped

build_arm_onx86$ bin/clang --version
clang version 12.0.0 (https://github.com/llvm/llvm-project.git
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home_2t/workspace/llvm_clang/llvm-project/build_arm_onx86/bin

Seems it failed from the configuration as attached cmake output log.
-- LLVM host triple: x86_64-unknown-linux-gnu
-- LLVM default target triple: x86_64-unknown-linux-gnu

Thanks in advance

Best Regards,

On Thu, Aug 13, 2020 at 7:32 PM Dongdong Yang <contribute.kernel at gmail.com>

> May I ask how to build clang for arm on x86 linux ubuntu box? And how to
> use  sysroot  to cross compile clang  libc++  for arm on x86
> linux?   Appreciate any guidance.
> Thanks,
> Andy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200820/98d85322/attachment-0001.html>

More information about the cfe-dev mailing list