Module rustc_target::spec[][src]

Expand description

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

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

Bare MIPS32r2, little endian, softfloat, O32 calling convention

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

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

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.

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

Structs

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

Optional aspects of a target specification.

Warnings encountered when parsing the target json.

Enums

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

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

Constants

List of supported targets

Traits

Functions

Type Definitions