-target
option. That makes it a lot easier for programmers wishing to compile todifferent platforms and architectures, and for compiler developers thatonly have to maintain one build system, and for OS distributions, thatneed only one set of main packages.compiler-rt
, libcxx
, libgcc
, libm
, etc), so you’ll have tofind and make available to the build system, every other library requiredto build your software, that is specific to your target. It’s not enough tohave your host’s libraries installed.--sysroot
(whicheffectively changes the logical root for headers and libraries), assumeall your binaries and libraries are in the same directory, which may nottrue when your cross-compiler was installed by the distribution’s packagemanagement. So, for each specific case, you may use more than oneoption, and in most cases, you’ll end up setting include paths (-I
) andlibrary paths (-L
) manually.-target<triple>
. If you don’t specify the target, CPU names won’tmatch (since Clang assumes the host triple), and the compilation willgo ahead, creating code for the host platform, which will break lateron when assembling or linking.<arch><sub>-<vendor>-<sys>-<abi>
, where:arch
= x86_64
, i386
, arm
, thumb
, mips
, etc.sub
= for ex. on ARM: v5
, v6m
, v7a
, v7m
, etc.vendor
= pc
, apple
, nvidia
, ibm
, etc.sys
= none
, linux
, win32
, darwin
, cuda
, etc.abi
= eabi
, gnu
, android
, macho
, elf
, etc.unknown
and the defaults will be used. If you choose a parameterthat Clang doesn’t know, like blerg
, it’ll ignore and assumeunknown
, which is not always desired, so be careful.-mcpu=<cpu-name>
, like x86-64, swift, cortex-a15-mfpu=<fpu-name>
, like SSE3, NEON, controlling the FP unit available-mfloat-abi=<fabi>
, like soft, hard, controlling which registersto use for floating-pointarm-none-eabi
, the default CPU willbe arm7tdmi
using soft float, which is extremely slow on modern cores,whereas if your triple is armv7a-none-eabi
, it’ll be Cortex-A8 withNEON, but still using soft-float, which is much better, but still notgreat.--sysroot
, -I
, and -L
. The two last ones are well known,but they’re particularly important for additional librariesand headers that are specific to your target.--sysroot=<path>
. The path is theroot directory where you have unpacked your file, and Clang willlook for the directories bin
, lib
, include
in there.-I
and -L
).libxml
or libz
etc) will matchagainst the host platform, not the target.-I
and -L
pointing to them.-ccc-gcc-namearmv7l-linux-gnueabihf-gcc
(whichuses hard-float), Clang will pick the armv7l-linux-gnueabi-ld
(which uses soft-float) and linker errors will happen.gnueabi
and androideabi
, and might even link and run, but produce run-timeerrors, which are much harder to track down and fix.