Cross-compilation using Clang — Clang 12 documentation

Target option


    target option

    It assumes you already know how to compile the code in question for the host architecture, and that you know how to choose additional include and library paths. Also, it does not cover all the possible options, nor does it contain specific examples for specific architectures.

    target option

    For a concrete example, the instructions for cross-compiling LLVM itself may be of interest. After reading this document, you should be familiar with the main target option related to cross-compilation, and what main compiler options Clang provides for performing cross-compilation.

    That makes it a lot target option for programmers wishing to compile to different platforms and architectures, and for compiler developers that only have to maintain one build system, and for OS distributions, that need only one set of main packages.

    target option

    Finally, not all toolchains are the same, and consequently, not every Clang option will work magically. Most of the time it can be omitted and Unknown will be assumed, which sets the defaults for the specified target option.

    target option

    When a parameter is not important, it can be omitted, or you can choose unknown and the defaults will be used. The path is the root directory where you have unpacked your file, and Clang will look for the directories bin, lib, include in there.

    target option

    In this case, your setup should be pretty much done if no additional headers or libraries are neededas Clang will find all binaries it needs assembler, linker, etc binary options for mobile there. When you have installed via a package manager modern Linux distributions have cross-compiler packages availablemake sure the target triple you set is also the prefix of your cross-compiler toolchain.

    In this case, Clang will find the other binaries assembler, linkerbut not always where the target headers and libraries are. But all dependencies that are normally checked against like libxml or libz etc will match against the host platform, not the target.

    target option

    So, if the build system is not aware that you want to cross-compile your code, it will get every dependency wrong, and your target option will fail during build time, not configure time.

    Also, finding the libraries for your target are not as easy as for your host machine.

    Where do you start? How do you determine which audiences make the most sense for your brand? To help you sift through all the choices, this article will summarize types of targeting you can create in the Audiences section.

    Also, some libraries have different dependencies on different targets, so configuration tools to find dependencies in the host can get the list wrong for the target platform.