Skip to content

Commit 679a2e3

Browse files
compiler: Redescribe rustc_target search algo more accurately
1 parent de792eb commit 679a2e3

File tree

1 file changed

+7
-14
lines changed
  • compiler/rustc_target/src/spec

1 file changed

+7
-14
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,15 @@
66
//! to a new platform, and allows for an unprecedented level of control over how
77
//! the compiler works.
88
//!
9-
//! # Using custom targets
9+
//! # Using targets and target.json
1010
//!
11-
//! A target tuple, as passed via `rustc --target=TUPLE`, will first be
12-
//! compared against the list of built-in targets. This is to ease distributing
13-
//! rustc (no need for configuration files) and also to hold these built-in
14-
//! targets as immutable and sacred. If `TUPLE` is not one of the built-in
15-
//! targets, rustc will check if a file named `TUPLE` exists. If it does, it
16-
//! will be loaded as the target configuration. If the file does not exist,
17-
//! rustc will search each directory in the environment variable
18-
//! `RUST_TARGET_PATH` for a file named `TUPLE.json`. The first one found will
19-
//! be loaded. If no file is found in any of those directories, a fatal error
20-
//! will be given.
11+
//! Invoking "rustc --target=${TUPLE}" will result in rustc initiating the [`Target::search`] by
12+
//! - checking if "$TUPLE" is a complete path to a json (ending with ".json") and loading if so
13+
//! - checking builtin targets for "${TUPLE}"
14+
//! - checking directories in "${RUST_TARGET_PATH}" for "${TUPLE}.json"
15+
//! - checking for "${RUSTC_SYSROOT}/lib/rustlib/${TUPLE}/target.json"
2116
//!
22-
//! Projects defining their own targets should use
23-
//! `--target=path/to/my-awesome-platform.json` instead of adding to
24-
//! `RUST_TARGET_PATH`.
17+
//! Code will then be compiled using the first discovered target spec.
2518
//!
2619
//! # Defining a new target
2720
//!

0 commit comments

Comments
 (0)