[llvm-dev] llvm cross compilation issue

Martin Storsjö via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 17 07:48:29 PDT 2020


On Thu, 17 Sep 2020, Денис Онищенко via llvm-dev wrote:

> I am trying to compile llvm using a toolchain file where I have
> specified the target system and compilers as suggested at
> https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compilation-tool
> chain:
>
> set(CMAKE_SYSTEM_NAME Linux)
> set(CMAKE_SYSTEM_PROCESSOR arm)
>
> set(CMAKE_C_COMPILER arm-unknown-linux-gnueabi-gcc)
> set(CMAKE_CXX_COMPILER arm-unknown-linux-gnueabi-g++)
>
> But the problem is that native tools like llvm-config, llvm-tblgen and
> clang-tblgen, which must be built by the native compiler, are also
> created by the target compiler.
>
> What cmake / "toolchain file" options should I use to use the native
> (host) compiler for these native tools (which are placed in the NATIVE
> subdirectory), and target compilers for other binaries and libraries?

You need to pass -DCROSS_TOOLCHAIN_FLAGS_NATIVE="" during the cross build, 
to fix your build of the llvm-config/llvm-tblgen/clang-tblgen native 
tools.

The reason for this is that if CROSS_TOOLCHAIN_FLAGS_NATIVE isn't set, 
it's default initialized to pass on your CMAKE_CXX_COMPILER to the native 
build process as well, which won't do the right thing in this kind of 
cross setup.

// Martin


More information about the llvm-dev mailing list