[][src]Module rustc_target::spec

Flexible target specification.

Rust targets a wide variety of usecases, and in the interest of flexibility, allows new target triples to be defined in configuration files. Most users will not need to care about these, but this is invaluable when porting Rust to a new platform, and allows for an unprecedented level of control over how the compiler works.

Using custom targets

A target triple, as passed via rustc --target=TRIPLE, will first be compared against the list of built-in targets. This is to ease distributing rustc (no need for configuration files) and also to hold these built-in targets as immutable and sacred. If TRIPLE is not one of the built-in targets, rustc will check if a file named TRIPLE exists. If it does, it will be loaded as the target configuration. If the file does not exist, rustc will search each directory in the environment variable RUST_TARGET_PATH for a file named TRIPLE.json. The first one found will be loaded. If no file is found in any of those directories, a fatal error will be given.

Projects defining their own targets should use --target=path/to/my-awesome-platform.json instead of adding to RUST_TARGET_PATH.

Defining a new target

Targets are defined using JSON. The Target struct in this module defines the format the JSON file should take, though each underscore in the field names should be replaced with a hyphen (-) in the JSON file. Some fields are required in every target specification, such as llvm-target, target-endian, target-pointer-width, data-layout, arch, and os. In general, options passed to rustc with -C override the target's settings, though target-feature and link-args will add to the list specified by the target, rather than replace.

Modules

aarch64_apple_darwin
aarch64_apple_ios
aarch64_apple_tvos
aarch64_fuchsia
aarch64_linux_android
aarch64_pc_windows_msvc
aarch64_unknown_cloudabi
aarch64_unknown_freebsd
aarch64_unknown_hermit
aarch64_unknown_linux_gnu
aarch64_unknown_linux_musl
aarch64_unknown_netbsd
aarch64_unknown_none
aarch64_unknown_none_softfloat
aarch64_unknown_openbsd
aarch64_unknown_redox
aarch64_uwp_windows_msvc
aarch64_wrs_vxworks
abi
android_base
apple_base
apple_sdk_base
arm_base
arm_linux_androideabi
arm_unknown_linux_gnueabi
arm_unknown_linux_gnueabihf
arm_unknown_linux_musleabi
arm_unknown_linux_musleabihf
armebv7r_none_eabi
armebv7r_none_eabihf
armv4t_unknown_linux_gnueabi
armv5te_unknown_linux_gnueabi
armv5te_unknown_linux_musleabi
armv6_unknown_freebsd
armv6_unknown_netbsd_eabihf
armv7_apple_ios
armv7_linux_androideabi
armv7_unknown_cloudabi_eabihf
armv7_unknown_freebsd
armv7_unknown_linux_gnueabi
armv7_unknown_linux_gnueabihf
armv7_unknown_linux_musleabi
armv7_unknown_linux_musleabihf
armv7_unknown_netbsd_eabihf
armv7_wrs_vxworks_eabihf
armv7a_none_eabi
armv7a_none_eabihf
armv7r_none_eabi
armv7r_none_eabihf
armv7s_apple_ios
asmjs_unknown_emscripten
avr_gnu_base
avr_unknown_gnu_atmega328
cloudabi_base
crt_objects

Object files providing support for basic runtime facilities and added to the produced binaries at the start and at the end of linking.

dragonfly_base
freebsd_base
fuchsia_base
haiku_base
hermit_base
hermit_kernel_base
hexagon_unknown_linux_musl
i386_apple_ios
i586_pc_windows_msvc
i586_unknown_linux_gnu
i586_unknown_linux_musl
i686_apple_darwin
i686_linux_android
i686_pc_windows_gnu
i686_pc_windows_msvc
i686_unknown_cloudabi
i686_unknown_freebsd
i686_unknown_haiku
i686_unknown_linux_gnu
i686_unknown_linux_musl
i686_unknown_netbsd
i686_unknown_openbsd
i686_unknown_uefi
i686_uwp_windows_gnu
i686_uwp_windows_msvc
i686_wrs_vxworks
illumos_base
l4re_base
linux_base
linux_kernel_base
linux_musl_base
mips64_unknown_linux_gnuabi64
mips64_unknown_linux_muslabi64
mips64el_unknown_linux_gnuabi64
mips64el_unknown_linux_muslabi64
mips_unknown_linux_gnu
mips_unknown_linux_musl
mips_unknown_linux_uclibc
mipsel_sony_psp
mipsel_unknown_linux_gnu
mipsel_unknown_linux_musl
mipsel_unknown_linux_uclibc
mipsisa32r6_unknown_linux_gnu
mipsisa32r6el_unknown_linux_gnu
mipsisa64r6_unknown_linux_gnuabi64
mipsisa64r6el_unknown_linux_gnuabi64
msp430_none_elf
msvc_base
netbsd_base
nvptx64_nvidia_cuda
openbsd_base
powerpc64_unknown_freebsd
powerpc64_unknown_linux_gnu
powerpc64_unknown_linux_musl
powerpc64_wrs_vxworks
powerpc64le_unknown_linux_gnu
powerpc64le_unknown_linux_musl
powerpc_unknown_linux_gnu
powerpc_unknown_linux_gnuspe
powerpc_unknown_linux_musl
powerpc_unknown_netbsd
powerpc_wrs_vxworks
powerpc_wrs_vxworks_spe
redox_base
riscv32gc_unknown_linux_gnu
riscv32i_unknown_none_elf
riscv32imac_unknown_none_elf
riscv32imc_unknown_none_elf
riscv64gc_unknown_linux_gnu
riscv64gc_unknown_none_elf
riscv64imac_unknown_none_elf
riscv_base
s390x_unknown_linux_gnu
solaris_base
sparc64_unknown_linux_gnu
sparc64_unknown_netbsd
sparc64_unknown_openbsd
sparc_unknown_linux_gnu
sparcv9_sun_solaris
thumb_base
thumbv4t_none_eabi

Targets the ARMv4T, with code as t32 code by default.

thumbv6m_none_eabi
thumbv7a_pc_windows_msvc
thumbv7a_uwp_windows_msvc
thumbv7em_none_eabi
thumbv7em_none_eabihf
thumbv7m_none_eabi
thumbv7neon_linux_androideabi
thumbv7neon_unknown_linux_gnueabihf
thumbv7neon_unknown_linux_musleabihf
thumbv8m_base_none_eabi
thumbv8m_main_none_eabi
thumbv8m_main_none_eabihf
uefi_msvc_base
vxworks_base
wasm32_base
wasm32_unknown_emscripten
wasm32_unknown_unknown

A "bare wasm" target representing a WebAssembly output that makes zero assumptions about its environment.

wasm32_wasi

The wasm32-wasi target is a new and still (as of April 2019) an experimental target. The definition in this file is likely to be tweaked over time and shouldn't be relied on too much.

windows_gnu_base
windows_msvc_base
windows_uwp_gnu_base
windows_uwp_msvc_base
x86_64_apple_darwin
x86_64_apple_ios
x86_64_apple_ios_macabi
x86_64_apple_tvos
x86_64_fortanix_unknown_sgx
x86_64_fuchsia
x86_64_linux_android
x86_64_linux_kernel
x86_64_pc_windows_gnu
x86_64_pc_windows_msvc
x86_64_rumprun_netbsd
x86_64_sun_solaris
x86_64_unknown_cloudabi
x86_64_unknown_dragonfly
x86_64_unknown_freebsd
x86_64_unknown_haiku
x86_64_unknown_hermit
x86_64_unknown_hermit_kernel
x86_64_unknown_illumos
x86_64_unknown_l4re_uclibc
x86_64_unknown_linux_gnu
x86_64_unknown_linux_gnux32
x86_64_unknown_linux_musl
x86_64_unknown_netbsd
x86_64_unknown_openbsd
x86_64_unknown_redox
x86_64_unknown_uefi
x86_64_uwp_windows_gnu
x86_64_uwp_windows_msvc
x86_64_wrs_vxworks

Structs

Target

Everything rustc knows about how to compile for a specific target.

TargetOptions

Optional aspects of a target specification.

Enums

CodeModel
LinkOutputKind

Everything is flattened to a single enum to make the json encoding/decoding less annoying.

LinkerFlavor
LldFlavor
LoadTargetError
MergeFunctions
PanicStrategy
RelocModel
RelroLevel
TargetTriple

Either a target triple string or a path to a JSON file.

TlsModel

Constants

TARGETS

List of supported targets

Traits

HasTargetSpec

Functions

get_targets
load_specific

Type Definitions

LinkArgs
TargetResult