Cross compile x64 to AArch64 issues


I am trying to cross compile release-10.x to AArch64
(target=aarch64-linux-gnu), and the directions listed at [1] are not
completing the initial cmake step. I'm currently running Manjaro,
with the aarch64-linux-gnu package (and associated binutils, headers,
and glibc packages). My cmake command is

install` -DLLVM_TABLEGEN=`realpath
-DCMAKE_CXX_FLAGS="-target aarch64-linux-gnu
-L/usr/lib/gcc/aarch64-linux-gnu/10.1.0" -DCMAKE_C_COMPILER=`realpath
../build-10.x/install/bin/clang` -DCMAKE_CXX_COMPILER=`realpath
-DLLVM_INCLUDE_TESTS=False -G Ninja ../llvm

Does anyone see any obvious misconfiguration? Cmake fails at the
early test for a working CXX compiler:

/usr/bin/aarch64-linux-gnu-ld: cannot find crtbegin.o: No such file or directory

I have confirmed that crtbegin.o exists in /usr/lib/gcc/aarch64-linux-gnu/10.1.0

If I copy /usr/lib/gcc/aarch64-linux-gnu/10.1.0/{crtbegin,crtend}.o to
/usr/aarch64-linux-gnu/lib the check passed, but then the
LLVM_LIBSTDCXX_MIN check fails. However, checking CMakeErrors.log,
the failing program can be compiled with my system
aarch64-linux-gnu-g++. Barring any misconfiguration, I think that the
build system is not correctly using the sysroot and gcc-toolchain
paths correctly.



I would recommend checking the CMake documentation about cross compiling and creating a CMake toolchain file.

The current flags you pass are not instructing CMake about the config checks.

Hope this helps!


I often cross compile and there’s also some issue! Have you tried passing your library path to -DCMAKE_EXE_LINKER_FLAGS? I’ve sometimes also used the -B option to override the default paths.