Skip to content

Commit

Permalink
rustc book: document how the RUST_TARGET_PATH variable is used
Browse files Browse the repository at this point in the history
based on the module comment in
rust/compiler/rustc_target/src/spec/mod.rs

Fixes rust-lang#128280
  • Loading branch information
lolbinarycat committed Jul 27, 2024
1 parent d9e1dea commit 6fd7462
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/doc/rustc/src/targets/custom.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@ rustc +nightly -Z unstable-options --target=wasm32-unknown-unknown --print targe
```

To use a custom target, see the (unstable) [`build-std` feature](../../cargo/reference/unstable.html#build-std) of `cargo`.

## Custom Target Lookup Path

When `rustc` is given an option `--target=TARGET` (where `TARGET` is any string), it uses the following logic:
1. if `TARGET` is the name of a built-in target, use that
2. if `TARGET` is a path to a file, read that file as a json target
3. otherwise, search the colon-seperated list of directories found
in the `RUST_TARGET_PATH` environment variable for a file named
`TARGET.json`.

If none of these methods find a target, an error is thrown.

0 comments on commit 6fd7462

Please sign in to comment.