Skip to content

Commit af8ec14

Browse files
committed
Auto merge of #11603 - jofas:11398-fix, r=weihanglo
[Doc]: Added links to the `Target` section of the glossary for occurences of `target triple` Fix for #11398. #11398 raises the concern that it isn't always abundantly clear in the cargo book, what a `target triple` (i.e. `x86_64-unknown-linux-gnu`) is. This is unfortunate, as it is well described in the [glossary](https://doc.rust-lang.org/cargo/appendix/glossary.html#target) of the cargo book (including the command on how to get all targets supported by `rustc`). To mitigate this problem I added links to the glossary entry for target triples to the sections where triples are referenced, but not enough information is given on what they are and how they look like.
2 parents 6c095cc + 63e9b77 commit af8ec14

File tree

11 files changed

+48
-35
lines changed

11 files changed

+48
-35
lines changed

src/doc/man/cargo-metadata.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ possible value.
311311
312312
{{#option "`--filter-platform` _triple_" }}
313313
This filters the `resolve` output to only include dependencies for the
314-
given target triple. Without this flag, the resolve includes all targets.
314+
given [target triple](../appendix/glossary.html#target).
315+
Without this flag, the resolve includes all targets.
315316
316317
Note that the dependencies listed in the "packages" array still includes all
317318
dependencies. Each package definition is intended to be an unaltered

src/doc/man/cargo-tree.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ The default is `normal,build,dev`.
137137
{{/option}}
138138

139139
{{#option "`--target` _triple_" }}
140-
Filter dependencies matching the given target-triple. The default is the host
141-
platform. Use the value `all` to include *all* targets.
140+
Filter dependencies matching the given [target triple](../appendix/glossary.html#target).
141+
The default is the host platform. Use the value `all` to include *all* targets.
142142
{{/option}}
143143

144144
{{/options}}

src/doc/man/generated_txt/cargo-metadata.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,9 @@ OPTIONS
299299

300300
--filter-platform triple
301301
This filters the resolve output to only include dependencies for the
302-
given target triple. Without this flag, the resolve includes all
303-
targets.
302+
given target triple
303+
<https://doc.rust-lang.org/cargo/appendix/glossary.html#target>.
304+
Without this flag, the resolve includes all targets.
304305

305306
Note that the dependencies listed in the "packages" array still
306307
includes all dependencies. Each package definition is intended to be

src/doc/man/generated_txt/cargo-tree.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@ OPTIONS
133133
The default is normal,build,dev.
134134

135135
--target triple
136-
Filter dependencies matching the given target-triple. The default is
137-
the host platform. Use the value all to include all targets.
136+
Filter dependencies matching the given target triple
137+
<https://doc.rust-lang.org/cargo/appendix/glossary.html#target>. The
138+
default is the host platform. Use the value all to include all
139+
targets.
138140

139141
Tree Formatting Options
140142
--charset charset

src/doc/src/commands/cargo-metadata.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ possible value.</dd>
311311
312312
<dt class="option-term" id="option-cargo-metadata---filter-platform"><a class="option-anchor" href="#option-cargo-metadata---filter-platform"></a><code>--filter-platform</code> <em>triple</em></dt>
313313
<dd class="option-desc">This filters the <code>resolve</code> output to only include dependencies for the
314-
given target triple. Without this flag, the resolve includes all targets.</p>
314+
given <a href="../appendix/glossary.html#target">target triple</a>.
315+
Without this flag, the resolve includes all targets.</p>
315316
<p>Note that the dependencies listed in the &quot;packages&quot; array still includes all
316317
dependencies. Each package definition is intended to be an unaltered
317318
reproduction of the information within <code>Cargo.toml</code>.</dd>

src/doc/src/commands/cargo-tree.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ kind given, then it will automatically include the other dependency kinds.</li>
137137

138138

139139
<dt class="option-term" id="option-cargo-tree---target"><a class="option-anchor" href="#option-cargo-tree---target"></a><code>--target</code> <em>triple</em></dt>
140-
<dd class="option-desc">Filter dependencies matching the given target-triple. The default is the host
141-
platform. Use the value <code>all</code> to include <em>all</em> targets.</dd>
140+
<dd class="option-desc">Filter dependencies matching the given <a href="../appendix/glossary.html#target">target triple</a>.
141+
The default is the host platform. Use the value <code>all</code> to include <em>all</em> targets.</dd>
142142

143143

144144
</dl>

src/doc/src/guide/build-cache.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ For historical reasons, the `dev` and `test` profiles are stored in the
2424
same name as the profile.
2525

2626
When building for another target with `--target`, the output is placed in a
27-
directory with the name of the target:
27+
directory with the name of the [target]:
2828

2929
Directory | Example
3030
----------|--------
@@ -98,6 +98,7 @@ configuration][config]. Refer to sccache documentation for more details.
9898
[build scripts]: ../reference/build-scripts.md
9999
[config]: ../reference/config.md
100100
[def-workspace]: ../appendix/glossary.md#workspace '"workspace" (glossary entry)'
101+
[target]: ../appendix/glossary.md#target '"target" (glossary entry)'
101102
[environment variable]: ../reference/environment-variables.md
102103
[incremental output]: ../reference/profiles.md#incremental
103104
[sccache]: https://github.com/mozilla/sccache

src/doc/src/reference/config.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ all capital letters.
321321

322322
This section documents all configuration keys. The description for keys with
323323
variable parts are annotated with angled brackets like `target.<triple>` where
324-
the `<triple>` part can be any target triple like
324+
the `<triple>` part can be any [target triple] like
325325
`target.x86_64-pc-windows-msvc`.
326326

327327
#### `paths`
@@ -418,7 +418,7 @@ Sets the executable to use for `rustdoc`.
418418
* Default: host platform
419419
* Environment: `CARGO_BUILD_TARGET`
420420

421-
The default target platform triples to compile to.
421+
The default [target platform triples][target triple] to compile to.
422422

423423
This allows passing either a string or an array of strings. Each string value
424424
is a target platform triple. The selected build targets will be built for each
@@ -468,7 +468,7 @@ for the host, such as build scripts or proc macros, will not receive the args.
468468
Without `--target`, the flags will be passed to all compiler invocations
469469
(including build scripts and proc macros) because dependencies are shared. If
470470
you have args that you do not want to pass to build scripts or proc macros and
471-
are building for the host, pass `--target` with the host triple.
471+
are building for the host, pass `--target` with the [host triple][target triple].
472472

473473
It is not recommended to pass in flags that Cargo itself usually manages. For
474474
example, the flags driven by [profiles](profiles.md) are best handled by setting the
@@ -1048,8 +1048,8 @@ If none of `branch`, `tag`, or `rev` is set, defaults to the `master` branch.
10481048
#### `[target]`
10491049

10501050
The `[target]` table is used for specifying settings for specific platform
1051-
targets. It consists of a sub-table which is either a platform triple or a
1052-
[`cfg()` expression]. The given values will be used if the target platform
1051+
targets. It consists of a sub-table which is either a [platform triple][target triple]
1052+
or a [`cfg()` expression]. The given values will be used if the target platform
10531053
matches either the `<triple>` value or the `<cfg>` expression.
10541054

10551055
```toml
@@ -1068,7 +1068,7 @@ to view), values set by [build scripts], and extra `--cfg` flags passed to
10681068
`rustc` (such as those defined in `RUSTFLAGS`). Do not try to match on
10691069
`debug_assertions` or Cargo features like `feature="foo"`.
10701070

1071-
If using a target spec JSON file, the `<triple>` value is the filename stem.
1071+
If using a target spec JSON file, the [`<triple>`] value is the filename stem.
10721072
For example `--target foo/bar.json` would match `[target.bar]`.
10731073

10741074
##### `target.<triple>.ar`
@@ -1081,22 +1081,22 @@ This option is deprecated and unused.
10811081
* Environment: `CARGO_TARGET_<triple>_LINKER`
10821082

10831083
Specifies the linker which is passed to `rustc` (via [`-C linker`]) when the
1084-
`<triple>` is being compiled for. By default, the linker is not overridden.
1084+
[`<triple>`] is being compiled for. By default, the linker is not overridden.
10851085

10861086
##### `target.<triple>.runner`
10871087
* Type: string or array of strings ([program path with args])
10881088
* Default: none
10891089
* Environment: `CARGO_TARGET_<triple>_RUNNER`
10901090

1091-
If a runner is provided, executables for the target `<triple>` will be
1091+
If a runner is provided, executables for the target [`<triple>`] will be
10921092
executed by invoking the specified runner with the actual executable passed as
10931093
an argument. This applies to [`cargo run`], [`cargo test`] and [`cargo bench`]
10941094
commands. By default, compiled executables are executed directly.
10951095

10961096
##### `target.<cfg>.runner`
10971097

10981098
This is similar to the [target runner](#targettriplerunner), but using
1099-
a [`cfg()` expression]. If both a `<triple>` and `<cfg>` runner match,
1099+
a [`cfg()` expression]. If both a [`<triple>`] and `<cfg>` runner match,
11001100
the `<triple>` will take precedence. It is an error if more than one
11011101
`<cfg>` runner matches the current target.
11021102

@@ -1105,16 +1105,16 @@ the `<triple>` will take precedence. It is an error if more than one
11051105
* Default: none
11061106
* Environment: `CARGO_TARGET_<triple>_RUSTFLAGS`
11071107

1108-
Passes a set of custom flags to the compiler for this `<triple>`. The value
1109-
may be an array of strings or a space-separated string.
1108+
Passes a set of custom flags to the compiler for this [`<triple>`].
1109+
The value may be an array of strings or a space-separated string.
11101110

11111111
See [`build.rustflags`](#buildrustflags) for more details on the different
11121112
ways to specific extra flags.
11131113

11141114
##### `target.<cfg>.rustflags`
11151115

11161116
This is similar to the [target rustflags](#targettriplerustflags), but
1117-
using a [`cfg()` expression]. If several `<cfg>` and `<triple>` entries
1117+
using a [`cfg()` expression]. If several `<cfg>` and [`<triple>`] entries
11181118
match the current target, the flags are joined together.
11191119

11201120
##### `target.<triple>.<links>`
@@ -1214,3 +1214,5 @@ Sets the width for progress bar.
12141214
[revision]: https://git-scm.com/docs/gitrevisions
12151215
[registries]: registries.md
12161216
[crates.io]: https://crates.io/
1217+
[target triple]: ../appendix/glossary.md#target '"target" (glossary)'
1218+
[`<triple>`]: ../appendix/glossary.md#target '"target" (glossary)'

src/doc/src/reference/unstable.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -459,17 +459,19 @@ CLI paths are relative to the current working directory.
459459
* Tracking Issue: [#9453](https://github.com/rust-lang/cargo/issues/9453)
460460

461461
Historically, Cargo's behavior for whether the `linker` and `rustflags`
462-
configuration options from environment variables and `[target]` are
463-
respected for build scripts, plugins, and other artifacts that are
464-
_always_ built for the host platform has been somewhat inconsistent.
462+
configuration options from environment variables and
463+
[`[target]`](config.md#target) are respected for build scripts, plugins,
464+
and other artifacts that are _always_ built for the host platform has
465+
been somewhat inconsistent.
465466
When `--target` is _not_ passed, Cargo respects the same `linker` and
466467
`rustflags` for build scripts as for all other compile artifacts. When
467468
`--target` _is_ passed, however, Cargo respects `linker` from
468-
`[target.<host triple>]`, and does not pick up any `rustflags`
469-
configuration. This dual behavior is confusing, but also makes it
470-
difficult to correctly configure builds where the host triple and the
471-
target triple happen to be the same, but artifacts intended to run on
472-
the build host should still be configured differently.
469+
[`[target.<host triple>]`](config.md#targettriplelinker), and does not
470+
pick up any `rustflags` configuration.
471+
This dual behavior is confusing, but also makes it difficult to correctly
472+
configure builds where the host triple and the [target triple] happen to
473+
be the same, but artifacts intended to run on the build host should still
474+
be configured differently.
473475

474476
`-Ztarget-applies-to-host` enables the top-level
475477
`target-applies-to-host` setting in Cargo configuration files which
@@ -1432,7 +1434,7 @@ information.
14321434

14331435
The `-Z multitarget` option has been stabilized in the 1.64 release.
14341436
See [`build.target`](config.md#buildtarget) for more information about
1435-
setting the default target platform triples.
1437+
setting the default [target platform triples][target triple].
14361438

14371439
### crate-type
14381440

@@ -1459,3 +1461,5 @@ terminal where Cargo can automatically detect the width.
14591461

14601462
Sparse registry support has been stabilized in the 1.68 release.
14611463
See [Registry Protocols](registries.md#registry-protocols) for more information.
1464+
1465+
[target triple]: ../appendix/glossary.md#target '"target" (glossary)'

src/etc/man/cargo-metadata.1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ possible value.
308308
\fB\-\-filter\-platform\fR \fItriple\fR
309309
.RS 4
310310
This filters the \fBresolve\fR output to only include dependencies for the
311-
given target triple. Without this flag, the resolve includes all targets.
311+
given \fItarget triple\fR <https://doc.rust\-lang.org/cargo/appendix/glossary.html#target>\&.
312+
Without this flag, the resolve includes all targets.
312313
.sp
313314
Note that the dependencies listed in the "packages" array still includes all
314315
dependencies. Each package definition is intended to be an unaltered

src/etc/man/cargo-tree.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ The default is \fBnormal,build,dev\fR\&.
167167
.sp
168168
\fB\-\-target\fR \fItriple\fR
169169
.RS 4
170-
Filter dependencies matching the given target\-triple. The default is the host
171-
platform. Use the value \fBall\fR to include \fIall\fR targets.
170+
Filter dependencies matching the given \fItarget triple\fR <https://doc.rust\-lang.org/cargo/appendix/glossary.html#target>\&.
171+
The default is the host platform. Use the value \fBall\fR to include \fIall\fR targets.
172172
.RE
173173
.SS "Tree Formatting Options"
174174
.sp

0 commit comments

Comments
 (0)