Search code examples
armclangcross-compilingarm64

Where can I get the latest Clang x64-ARM cross-compiler?


Sorry for such a stupid question, but I guess I'm not alone in this. IMHO, this topic may be of interest to many SO users.

I couldn't find a Clang x64-ARM cross-compiler binaries online.

The official LLVM/Clang documentation says that the compilers can be downloaded from the llvm-project repo, and this is true.

However, it only contains precompiled binaries for native platforms.

No cross-compilers.

For example, it is not possible to load the Clang compiler to build ARM binaries on x86 Intel Linux.


Solution

  • For comprehensive information on installing the LLVM/Clang cross-compiler, refer to the official website:

    For example, to install Clang-18:

    wget https://apt.llvm.org/llvm.sh
    chmod +x llvm.sh
    sudo ./llvm.sh -18
    

    The installed Clang will include backends for various architectures like armv7 or aarch64.

    You can activate a specific backend using the --target= argument.

    To use clang-18 as a cross-compiler for armv7, execute the following command:

    clang-18 --target=armv7-linux-gnu -c main.c