about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2019-11-05 09:49:47 +0100
committerGitHub <noreply@github.com>2019-11-05 09:49:47 +0100
commita4e91c2986cd6addc71b470a85b4c484c679d417 (patch)
tree73c0abf5acc8b350f599a0b1a5adb47011ed2d0f
parentd2185f6752d3e9db6a0330f1a43c27a370783ac8 (diff)
parent9b9d6512880d09722e2af3f8c6e154314fd071af (diff)
downloadrust-a4e91c2986cd6addc71b470a85b4c484c679d417.tar.gz
rust-a4e91c2986cd6addc71b470a85b4c484c679d417.zip
Rollup merge of #65136 - ehuss:update-codegen-options, r=Dylan-DPC
Update codegen option documentation.

Some documentation updates:

- Add more detail to codegen options.
- Add missing options:
    - `force-frame-pointers`
    - `default-linker-libraries`
    - `linker-plugin-lto`
- Add fragment anchors for all command-line-arguments.
- Add some cross links between options.
-rw-r--r--src/doc/rustc/src/codegen-options/index.md223
-rw-r--r--src/doc/rustc/src/command-line-arguments.md99
2 files changed, 254 insertions, 68 deletions
diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md
index f5d5f2089d7..70c7acccd36 100644
--- a/src/doc/rustc/src/codegen-options/index.md
+++ b/src/doc/rustc/src/codegen-options/index.md
@@ -9,9 +9,12 @@ This option is deprecated and does nothing.
 
 ## linker
 
-This flag lets you control which linker `rustc` invokes to link your code.
+This flag lets you control which linker `rustc` invokes to link your code. It
+takes a path to the linker executable. If this flag is not specified, the
+linker will be inferred based on the target. See also the
+[linker-flavor](#linker-flavor) flag for another way to specify the linker.
 
-## link-arg=val
+## link-arg
 
 This flag lets you append a single extra argument to the linker invocation.
 
@@ -25,9 +28,27 @@ options should be separated by spaces.
 ## linker-flavor
 
 This flag lets you control the linker flavor used by `rustc`. If a linker is given with the
-`-C linker` flag described above then the linker flavor is inferred from the value provided. If no
+[`-C linker` flag](#linker), then the linker flavor is inferred from the value provided. If no
 linker is given then the linker flavor is used to determine the linker to use. Every `rustc` target
-defaults to some linker flavor.
+defaults to some linker flavor. Valid options are:
+
+* `em`: Uses [Emscripten `emcc`](https://emscripten.org/docs/tools_reference/emcc.html).
+* `gcc`: Uses the `cc` executable, which is typically gcc or clang on many systems.
+* `ld`: Uses the `ld` executable.
+* `msvc`: Uses the `link.exe` executable from Microsoft Visual Studio MSVC.
+* `ptx-linker`: Uses
+  [`rust-ptx-linker`](https://github.com/denzp/rust-ptx-linker) for Nvidia
+  NVPTX GPGPU support.
+* `wasm-ld`: Uses the [`wasm-ld`](https://lld.llvm.org/WebAssembly.html)
+  executable, a port of LLVM `lld` for WebAssembly.
+* `ld64.lld`: Uses the LLVM `lld` executable with the [`-flavor darwin`
+  flag][lld-flavor] for Apple's `ld`.
+* `ld.lld`: Uses the LLVM `lld` executable with the [`-flavor gnu`
+  flag][lld-flavor] for GNU binutils' `ld`.
+* `lld-link`: Uses the LLVM `lld` executable with the [`-flavor link`
+  flag][lld-flavor] for Microsoft's `link.exe`.
+
+[lld-flavor]: https://lld.llvm.org/Driver.html
 
 ## link-dead-code
 
@@ -39,11 +60,44 @@ metrics.
 ## lto
 
 This flag instructs LLVM to use [link time
-optimizations](https://llvm.org/docs/LinkTimeOptimization.html).
+optimizations](https://llvm.org/docs/LinkTimeOptimization.html) to produce
+better optimized code, using whole-program analysis, at the cost of longer
+linking time.
 
-It takes one of two values, `thin` and `fat`. 'thin' LTO [is a new feature of
-LLVM](http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html),
-'fat' referring to the classic version of LTO.
+This flag may take one of the following values:
+
+* `y`, `yes`, `on`, `fat`, or no value: Performs "fat" LTO which attempts to
+  perform optimizations across all crates within the dependency graph.
+* `n`, `no`, `off`: Disables LTO.
+* `thin`: Performs ["thin"
+  LTO](http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html).
+  This is similar to "fat", but takes substantially less time to run while
+  still achieving performance gains similar to "fat".
+
+If `-C lto` is not specified, then the compiler will attempt to perform "thin
+local LTO" which performs "thin" LTO on the local crate only across its
+[codegen units](#codegen-units). When `-C lto` is not specified, LTO is
+disabled if codegen units is 1 or optimizations are disabled ([`-C
+opt-level=0`](#opt-level)). That is:
+
+* When `-C lto` is not specified:
+  * `codegen-units=1`: Disables LTO.
+  * `opt-level=0`: Disables LTO.
+* When `-C lto=true`:
+  * `lto=true`: 16 codegen units, performs fat LTO across crates.
+  * `codegen-units=1` + `lto=true`: 1 codegen unit, fat LTO across crates.
+
+See also [linker-plugin-lto](#linker-plugin-lto) for cross-language LTO.
+
+## linker-plugin-lto
+
+Defers LTO optimizations to the linker. See
+[linkger-plugin-LTO](../linker-plugin-lto.md) for more details. Takes one of
+the following values:
+
+* `y`, `yes`, `on`, or no value: Enabled.
+* `n`, `no`, or `off`: Disabled (default).
+* A path to the linker plugin.
 
 ## target-cpu
 
@@ -51,30 +105,47 @@ This instructs `rustc` to generate code specifically for a particular processor.
 
 You can run `rustc --print target-cpus` to see the valid options to pass
 here. Additionally, `native` can be passed to use the processor of the host
-machine.
+machine. Each target has a default base CPU.
 
 ## target-feature
 
 Individual targets will support different features; this flag lets you control
-enabling or disabling a feature.
+enabling or disabling a feature. Each feature should be prefixed with a `+` to
+enable it or `-` to disable it. Separate multiple features with commas.
 
 To see the valid options and an example of use, run `rustc --print
 target-features`.
 
-Using this flag is unsafe and might result in [undefined runtime behavior](../targets/known-issues.md).
+Using this flag is unsafe and might result in [undefined runtime
+behavior](../targets/known-issues.md).
+
+See also the [`target_feature`
+attribute](../../reference/attributes/codegen.md#the-target_feature-attribute)
+for controlling features per-function.
+
+This also supports the feature `+crt-static` and `-crt-static` to control
+[static C runtime linkage](../../reference/linkage.html#static-and-dynamic-c-runtimes).
+
+Each target and [`target-cpu`](#target-cpu) has a default set of enabled
+features.
 
 ## passes
 
-This flag can be used to add extra LLVM passes to the compilation.
+This flag can be used to add extra [LLVM
+passes](http://llvm.org/docs/Passes.html) to the compilation.
 
 The list must be separated by spaces.
 
+See also the [`no-prepopulate-passes`](#no-prepopulate-passes) flag.
+
 ## llvm-args
 
 This flag can be used to pass a list of arguments directly to LLVM.
 
 The list must be separated by spaces.
 
+Pass `--help` to see a list of options.
+
 ## save-temps
 
 `rustc` will generate temporary files during compilation; normally it will
@@ -83,16 +154,21 @@ preserved instead of removed.
 
 ## rpath
 
-This option allows you to set the value of
+This option allows you to enable
 [`rpath`](https://en.wikipedia.org/wiki/Rpath).
 
 ## overflow-checks
 
-This flag allows you to control the behavior of integer overflow. This flag
-can be passed many options:
+This flag allows you to control the behavior of [runtime integer
+overflow](../../reference/expressions/operator-expr.md#overflow). When
+overflow-checks are enabled, a panic will occur on overflow. This flag takes
+one of the following values:
 
-* To turn overflow checks on: `y`, `yes`, or `on`.
-* To turn overflow checks off: `n`, `no`, or `off`.
+* `y`, `yes`, `on`, or no value: Enable overflow checks.
+* `n`, `no`, or `off`: Disable overflow checks.
+
+If not specified, overflow checks are enabled if
+[debug-assertions](#debug-assertions) are enabled, disabled otherwise.
 
 ## no-prepopulate-passes
 
@@ -125,25 +201,30 @@ make it use dynamic linking instead.
 
 ## no-integrated-as
 
-LLVM comes with an internal assembler; this option will let you use an
-external assembler instead.
+`rustc` normally uses the LLVM internal assembler to create object code. This
+flag will disable the internal assembler and emit assembly code to be
+translated using an external assembler, currently the linker such as `cc`.
 
 ## no-redzone
 
 This flag allows you to disable [the
 red zone](https://en.wikipedia.org/wiki/Red_zone_\(computing\)). This flag can
-be passed many options:
+be passed one of the following options:
+
+* `y`, `yes`, `on`, or no value: Disables the red zone.
+* `n`, `no`, or `off`: Enables the red zone.
 
-* To enable the red zone: `y`, `yes`, or `on`.
-* To disable it: `n`, `no`, or `off`.
+The default if not specified depends on the target.
 
 ## relocation-model
 
-This option lets you choose which relocation model to use.
+This option lets you choose which
+[relocation](https://en.wikipedia.org/wiki/Relocation_\(computing\)) model to
+use.
 
 To find the valid options for this flag, run `rustc --print relocation-models`.
 
-## code-model=val
+## code-model
 
 This option lets you choose which code model to use.
 
@@ -151,23 +232,34 @@ To find the valid options for this flag, run `rustc --print code-models`.
 
 ## metadata
 
-This option allows you to control the metadata used for symbol mangling.
+This option allows you to control the metadata used for symbol mangling. This
+takes a space-separated list of strings. Mangled symbols will incorporate a
+hash of the metadata. This may be used, for example, to differentiate symbols
+between two different versions of the same crate being linked.
 
 ## extra-filename
 
-This option allows you to put extra data in each output filename.
+This option allows you to put extra data in each output filename. It takes a
+string to add as a suffix to the filename. See the [`--emit`
+flag][option-emit] for more information.
 
 ## codegen-units
 
-This flag lets you control how many threads are used when doing
-code generation.
+This flag controls how many code generation units the crate is split into. It
+takes an integer greater than 0.
 
-Increasing parallelism may speed up compile times, but may also
-produce slower code.
+When a crate is split into multiple codegen units, LLVM is able to process
+them in parallel. Increasing parallelism may speed up compile times, but may
+also produce slower code. Setting this to 1 may improve the performance of
+generated code, but may be slower to compile.
+
+The default, if not specified, is 16. This flag is ignored if
+[incremental](#incremental) is enabled, in which case an internal heuristic is
+used to split the crate.
 
 ## remark
 
-This flag lets you print remarks for these optimization passes.
+This flag lets you print remarks for optimization passes.
 
 The list of passes should be separated by spaces.
 
@@ -181,30 +273,55 @@ This option is deprecated and does nothing.
 
 This flag lets you control debug information:
 
-* `0`: no debug info at all
+* `0`: no debug info at all (default)
 * `1`: line tables only
 * `2`: full debug info
 
+Note: The [`-g` flag][option-g-debug] is an alias for `-C debuginfo=2`.
+
 ## opt-level
 
 This flag lets you control the optimization level.
 
-* `0`: no optimizations, also turn on `cfg(debug_assertions)`.
+* `0`: no optimizations, also turns on [`cfg(debug_assertions)`](#debug-assertions).
 * `1`: basic optimizations
 * `2`: some optimizations
 * `3`: all optimizations
 * `s`: optimize for binary size
 * `z`: optimize for binary size, but also turn off loop vectorization.
 
+Note: The [`-O` flag][option-o-optimize] is an alias for `-C opt-level=2`.
+
+The default is `0`.
+
 ## debug-assertions
 
-This flag lets you turn `cfg(debug_assertions)` on or off.
+This flag lets you turn `cfg(debug_assertions)` [conditional
+compilation](../../reference/conditional-compilation.md#debug_assertions) on
+or off. It takes one of the following values:
+
+* `y`, `yes`, `on`, or no value: Enable debug-assertions.
+* `n`, `no`, or `off`: Disable debug-assertions.
+
+If not specified, debug assertions are automatically enabled only if the
+[opt-level](#opt-level) is 0.
 
 ## inline-threshold
 
-This option lets you set the threshold for inlining a function.
+This option lets you set the default threshold for inlining a function. It
+takes an unsigned integer as a value. Inlining is based on a cost model, where
+a higher threshold will allow more inlining.
 
-The default is 225.
+The default depends on the [opt-level](#opt-level):
+
+| opt-level | Threshold |
+|-----------|-----------|
+| 0         | N/A, only inlines always-inline functions |
+| 1         | N/A, only inlines always-inline functions and LLVM lifetime intrinsics |
+| 2         | 225 |
+| 3         | 275 |
+| s         | 75 |
+| z         | 25 |
 
 ## panic
 
@@ -213,9 +330,14 @@ This option lets you control what happens when the code panics.
 * `abort`: terminate the process upon panic
 * `unwind`: unwind the stack upon panic
 
+If not specified, the default depends on the target.
+
 ## incremental
 
-This flag allows you to enable incremental compilation.
+This flag allows you to enable incremental compilation, which allows `rustc`
+to save information after compiling a crate to be reused when recompiling the
+crate, improving re-compile times. This takes a path to a directory where
+incremental files will be stored.
 
 ## profile-generate
 
@@ -232,4 +354,31 @@ optimization (PGO). The flag takes a mandatory argument which is the path
 to a valid `.profdata` file. See the chapter on
 [profile-guided optimization] for more information.
 
+## force-frame-pointers
+
+This flag forces the use of frame pointers. It takes one of the following
+values:
+
+* `y`, `yes`, `on`, or no value: Frame pointers are forced to be enabled.
+* `n`, `no`, or `off`: Frame pointers are not forced to be enabled. This does
+  not necessarily mean frame pointers will be removed.
+
+The default if not specified depends on the target.
+
+## default-linker-libraries
+
+This flag controls whether or not the linker includes its default libraries.
+It takes one of the following values:
+
+* `y`, `yes`, `on`, or no value: Default libraries are included.
+* `n`, `no`, or `off`: Default libraries are **not** included.
+
+For example, for gcc flavor linkers, this issues the `-nodefaultlibs` flag to
+the linker.
+
+The default is `yes` if not specified.
+
+[option-emit]: ../command-line-arguments.md#option-emit
+[option-o-optimize]: ../command-line-arguments.md#option-o-optimize
 [profile-guided optimization]: ../profile-guided-optimization.md
+[option-g-debug]: ../command-line-arguments.md#option-g-debug
diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md
index bdb3c519658..79b4f7542f9 100644
--- a/src/doc/rustc/src/command-line-arguments.md
+++ b/src/doc/rustc/src/command-line-arguments.md
@@ -2,19 +2,23 @@
 
 Here's a list of command-line arguments to `rustc` and what they do.
 
+<a id="option-help"></a>
 ## `-h`/`--help`: get help
 
 This flag will print out help information for `rustc`.
 
+<a id="option-cfg"></a>
 ## `--cfg`: configure the compilation environment
 
-This flag can turn on or off various `#[cfg]` settings.
+This flag can turn on or off various `#[cfg]` settings for [conditional
+compilation](../reference/conditional-compilation.md).
 
 The value can either be a single identifier or two identifiers separated by `=`.
 
 For examples, `--cfg 'verbose'` or `--cfg 'feature="serde"'`. These correspond
 to `#[cfg(verbose)]` and `#[cfg(feature = "serde")]` respectively.
 
+<a id="option-l-search-path"></a>
 ## `-L`: add a directory to the library search path
 
 When looking for external crates or libraries, a directory passed to this flag
@@ -31,6 +35,7 @@ KIND=PATH` where `KIND` may be one of:
 - `all` — Search for all library kinds in this directory. This is the default
   if `KIND` is not specified.
 
+<a id="option-l-link-lib"></a>
 ## `-l`: link the generated crate to a native library
 
 This flag allows you to specify linking to a specific native library when building
@@ -55,6 +60,7 @@ and `LINK_NAME` is the name of the actual library that will be linked.
 
 [link-attribute]: ../reference/items/external-blocks.html#the-link-attribute
 
+<a id="option-crate-type"></a>
 ## `--crate-type`: a list of types of crates for the compiler to emit
 
 This instructs `rustc` on which crate type to build. This flag accepts a
@@ -80,10 +86,12 @@ More details may be found in the [linkage chapter] of the reference.
 [linkage chapter]: ../reference/linkage.html
 [crate_type]: ../reference/linkage.html
 
+<a id="option-crate-name"></a>
 ## `--crate-name`: specify the name of the crate being built
 
 This informs `rustc` of the name of your crate.
 
+<a id="option-edition"></a>
 ## `--edition`: specify the edition to use
 
 This flag takes a value of `2015` or `2018`. The default is `2015`. More
@@ -91,8 +99,8 @@ information about editions may be found in the [edition guide].
 
 [edition guide]: ../edition-guide/introduction.html
 
+<a id="option-emit"></a>
 ## `--emit`: specifies the types of output files to generate
- <a id="option-emit"></a>
 
 This flag controls the types of output files generated by the compiler. It
 accepts a comma-separated list of values, and may be specified multiple times.
@@ -117,22 +125,24 @@ The valid emit kinds are:
 - `obj` — Generates a native object file. The default output filename is
   `CRATE_NAME.o`.
 
-The output filename can be set with the `-o` flag. A suffix may be added to
-the filename with the `-C extra-filename` flag. The files are written to the
-current directory unless the `--out-dir` flag is used. Each emission type may
-also specify the output filename with the form `KIND=PATH`, which takes
-precedence over the `-o` flag.
+The output filename can be set with the [`-o` flag](#option-o-output). A
+suffix may be added to the filename with the [`-C extra-filename`
+flag](codegen-options/index.md#extra-filename). The files are written to the
+current directory unless the [`--out-dir` flag](#option-out-dir) is used. Each
+emission type may also specify the output filename with the form `KIND=PATH`,
+which takes precedence over the `-o` flag.
 
 [LLVM bitcode]: https://llvm.org/docs/BitCodeFormat.html
 [LLVM IR]: https://llvm.org/docs/LangRef.html
 
+<a id="option-print"></a>
 ## `--print`: print compiler information
 
 This flag prints out various information about the compiler. This flag may be
 specified multiple times, and the information is printed in the order the
 flags are specified. Specifying a `--print` flag will usually disable the
-`--emit` step and will only print the requested information. The valid types
-of print values are:
+[`--emit`](#option-emit) step and will only print the requested information.
+The valid types of print values are:
 
 - `crate-name` — The name of the crate.
 - `file-names` — The names of the files created by the `link` emit kind.
@@ -142,14 +152,17 @@ of print values are:
 - `target-list` — List of known targets. The target may be selected with the
   `--target` flag.
 - `target-cpus` — List of available CPU values for the current target. The
-  target CPU may be selected with the `-C target-cpu=val` flag.
+  target CPU may be selected with the [`-C target-cpu=val`
+  flag](codegen-options/index.md#target-cpu).
 - `target-features` — List of available target features for the current
-  target. Target features may be enabled with the `-C target-feature=val`
-  flag. This flag is unsafe. See [known issues](targets/known-issues.md) for more details.
+  target. Target features may be enabled with the [`-C target-feature=val`
+  flag](codegen-options/index.md#target-feature).  This flag is unsafe. See
+  [known issues](targets/known-issues.md) for more details.
 - `relocation-models` — List of relocation models. Relocation models may be
-  selected with the `-C relocation-model=val` flag.
+  selected with the [`-C relocation-model=val`
+  flag](codegen-options/index.md#relocation-model).
 - `code-models` — List of code models. Code models may be selected with the
-  `-C code-model=val` flag.
+  [`-C code-model=val` flag](codegen-options/index.md#code-model).
 - `tls-models` — List of Thread Local Storage models supported. The model may
   be selected with the `-Z tls-model=val` flag.
 - `native-static-libs` — This may be used when creating a `staticlib` crate
@@ -160,53 +173,65 @@ of print values are:
 
 [conditional compilation]: ../reference/conditional-compilation.html
 
+<a id="option-g-debug"></a>
 ## `-g`: include debug information
 
-A synonym for `-C debuginfo=2`, for more see [here](codegen-options/index.md#debuginfo).
+A synonym for [`-C debuginfo=2`](codegen-options/index.md#debuginfo).
 
+<a id="option-o-optimize"></a>
 ## `-O`: optimize your code
 
-A synonym for `-C opt-level=2`, for more see [here](codegen-options/index.md#opt-level).
+A synonym for [`-C opt-level=2`](codegen-options/index.md#opt-level).
 
+<a id="option-o-output"></a>
 ## `-o`: filename of the output
 
 This flag controls the output filename.
 
+<a id="option-out-dir"></a>
 ## `--out-dir`: directory to write the output in
 
 The outputted crate will be written to this directory. This flag is ignored if
-the `-o` flag is used.
+the [`-o` flag](#option-o-output) is used.
 
+<a id="option-explain"></a>
 ## `--explain`: provide a detailed explanation of an error message
 
 Each error of `rustc`'s comes with an error code; this will print
 out a longer explanation of a given error.
 
+<a id="option-test"></a>
 ## `--test`: build a test harness
 
 When compiling this crate, `rustc` will ignore your `main` function
 and instead produce a test harness.
 
+<a id="option-target"></a>
 ## `--target`: select a target triple to build
 
 This controls which [target](targets/index.md) to produce.
 
+<a id="option-w-warn"></a>
 ## `-W`: set lint warnings
 
 This flag will set which lints should be set to the [warn level](lints/levels.md#warn).
 
+<a id="option-a-allow"></a>
 ## `-A`: set lint allowed
 
 This flag will set which lints should be set to the [allow level](lints/levels.md#allow).
 
+<a id="option-d-deny"></a>
 ## `-D`: set lint denied
 
 This flag will set which lints should be set to the [deny level](lints/levels.md#deny).
 
+<a id="option-f-forbid"></a>
 ## `-F`: set lint forbidden
 
 This flag will set which lints should be set to the [forbid level](lints/levels.md#forbid).
 
+<a id="option-z-unstable"></a>
 ## `-Z`: set unstable options
 
 This flag will allow you to set unstable options of rustc. In order to set multiple options,
@@ -214,35 +239,41 @@ the -Z flag can be used multiple times. For example: `rustc -Z verbose -Z time`.
 Specifying options with -Z is only available on nightly. To view all available options
 run: `rustc -Z help`.
 
+<a id="option-cap-lints"></a>
 ## `--cap-lints`: set the most restrictive lint level
 
 This flag lets you 'cap' lints, for more, [see here](lints/levels.md#capping-lints).
 
+<a id="option-codegen"></a>
 ## `-C`/`--codegen`: code generation options
 
 This flag will allow you to set [codegen options](codegen-options/index.md).
 
+<a id="option-version"></a>
 ## `-V`/`--version`: print a version
 
 This flag will print out `rustc`'s version.
 
+<a id="option-verbose"></a>
 ## `-v`/`--verbose`: use verbose output
 
 This flag, when combined with other flags, makes them produce extra output.
 
+<a id="option-extern"></a>
 ## `--extern`: specify where an external library is located
 
 This flag allows you to pass the name and location of an external crate that
 will be linked into the crate you are building. This flag may be specified
 multiple times. The format of the value should be `CRATENAME=PATH`.
 
+<a id="option-sysroot"></a>
 ## `--sysroot`: Override the system root
 
 The "sysroot" is where `rustc` looks for the crates that come with the Rust
 distribution; this flag allows that to be overridden.
 
+<a id="option-error-format"></a>
 ## `--error-format`: control how errors are produced
- <a id="option-error-format"></a>
 
 This flag lets you control the format of messages. Messages are printed to
 stderr. The valid options are:
@@ -251,6 +282,7 @@ stderr. The valid options are:
 - `json` — Structured JSON output. See [the JSON chapter] for more detail.
 - `short` — Short, one-line messages.
 
+<a id="option-color"></a>
 ## `--color`: configure coloring of output
 
 This flag lets you control color settings of the output. The valid options
@@ -260,6 +292,7 @@ are:
 - `always` — Always use colors.
 - `never` — Never colorize output.
 
+<a id="option-remap-path-prefix"></a>
 ## `--remap-path-prefix`: remap source names in output
 
 Remap source path prefixes in all output, including compiler diagnostics,
@@ -274,13 +307,14 @@ replacement is purely textual, with no consideration of the current system's
 pathname syntax. For example `--remap-path-prefix foo=bar` will match
 `foo/lib.rs` but not `./foo/lib.rs`.
 
+<a id="option-json"></a>
 ## `--json`: configure json messages printed by the compiler
- <a id="option-json"></a>
 
-When the `--error-format=json` option is passed to rustc then all of the
-compiler's diagnostic output will be emitted in the form of JSON blobs. The
-`--json` argument can be used in conjunction with `--error-format=json` to
-configure what the JSON blobs contain as well as which ones are emitted.
+When the [`--error-format=json` option](#option-error-format) is passed to
+rustc then all of the compiler's diagnostic output will be emitted in the form
+of JSON blobs. The `--json` argument can be used in conjunction with
+`--error-format=json` to configure what the JSON blobs contain as well as
+which ones are emitted.
 
 With `--error-format=json` the compiler will always emit any compiler errors as
 a JSON blob, but the following options are also available to the `--json` flag
@@ -296,20 +330,23 @@ to customize the output:
   indicates that the diagnostic should have embedded ANSI color codes intended
   to be used to colorize the message in the manner rustc typically already does
   for terminal outputs. Note that this is usefully combined with crates like
-  `fwdansi` to translate these ANSI codes on Windows to console commands or
-  `strip-ansi-escapes` if you'd like to optionally remove the ansi colors
-  afterwards.
+  [`fwdansi`](https://crates.io/crates/fwdansi) to translate these ANSI codes
+  on Windows to console commands or
+  [`strip-ansi-escapes`](https://crates.io/crates/strip-ansi-escapes) if you'd
+  like to optionally remove the ansi colors afterwards.
 
 - `artifacts` - this instructs rustc to emit a JSON blob for each artifact that
-  is emitted. An artifact corresponds to a request from the `--emit` CLI
-  argument, and as soon as the artifact is available on the filesystem a
-  notification will be emitted.
+  is emitted. An artifact corresponds to a request from the [`--emit` CLI
+  argument](#option-emit), and as soon as the artifact is available on the
+  filesystem a notification will be emitted.
 
-Note that it is invalid to combine the `--json` argument with the `--color`
-argument, and it is required to combine `--json` with `--error-format=json`.
+Note that it is invalid to combine the `--json` argument with the
+[`--color`](#option-color) argument, and it is required to combine `--json`
+with `--error-format=json`.
 
 See [the JSON chapter] for more detail.
 
+<a id="at-path"></a>
 ## `@path`: load command-line flags from a path
 
 If you specify `@path` on the command-line, then it will open `path` and read