]> git.proxmox.com Git - cargo.git/blame - src/doc/src/reference/config.md
Auto merge of #7818 - giraffate:add_some_tests, r=alexcrichton
[cargo.git] / src / doc / src / reference / config.md
CommitLineData
4d590f95
BE
1## Configuration
2
dd8f7d8d 3This document explains how Cargo’s configuration system works, as well as
f7c91ba6 4available keys or configuration. For configuration of a package through its
b119b891 5manifest, see the [manifest format](manifest.md).
4d590f95
BE
6
7### Hierarchical structure
8
4a8bd29f 9Cargo allows local configuration for a particular package as well as global
dd8f7d8d
EH
10configuration. It looks for configuration files in the current directory and
11all parent directories. If, for example, Cargo were invoked in
12`/projects/foo/bar/baz`, then the following configuration files would be
13probed for and unified in this order:
4d590f95 14
271860a9
JG
15* `/projects/foo/bar/baz/.cargo/config`
16* `/projects/foo/bar/.cargo/config`
17* `/projects/foo/.cargo/config`
18* `/projects/.cargo/config`
4d590f95 19* `/.cargo/config`
dd8f7d8d
EH
20* `$CARGO_HOME/config` which defaults to:
21 * Windows: `%USERPROFILE%\.cargo\config`
22 * Unix: `$HOME/.cargo/config`
4d590f95 23
4a8bd29f 24With this structure, you can specify configuration per-package, and even
271860a9 25possibly check it into version control. You can also specify personal defaults
4d590f95
BE
26with a configuration file in your home directory.
27
dd8f7d8d
EH
28If a key is specified in multiple config files, the values will get merged
29together. Numbers, strings, and booleans will use the value in the deeper
30config directory taking precedence over ancestor directories, where the
31home directory is the lowest priority. Arrays will be joined together.
4d590f95 32
dd8f7d8d 33### Configuration format
4d590f95 34
dd8f7d8d
EH
35Configuration files are written in the [TOML format][toml] (like the
36manifest), with simple key-value pairs inside of sections (tables). The
37following is a quick overview of all settings, with detailed descriptions
38found below.
4d590f95
BE
39
40```toml
dd8f7d8d 41paths = ["/path/to/override"] # path dependency overrides
4d590f95 42
dd8f7d8d
EH
43[alias] # command aliases
44b = "build"
45c = "check"
46t = "test"
47r = "run"
48rr = "run --release"
49space_example = ["run", "--release", "--", "\"command list\""]
ba375813 50
4d590f95
BE
51[build]
52jobs = 1 # number of parallel jobs, defaults to # of CPUs
53rustc = "rustc" # the rust compiler tool
dd8f7d8d 54rustc-wrapper = "…" # run this wrapper instead of `rustc`
4d590f95 55rustdoc = "rustdoc" # the doc generator tool
01421ef2 56target = "triple" # build for the target triple (ignored by `cargo install`)
4d590f95 57target-dir = "target" # path of where to place all generated artifacts
dd8f7d8d
EH
58rustflags = ["…", "…"] # custom flags to pass to all compiler invocations
59rustdocflags = ["…", "…"] # custom flags to pass to rustdoc
2bfcb2f9 60incremental = true # whether or not to enable incremental compilation
dd8f7d8d
EH
61dep-info-basedir = "…" # path for the base directory for targets in depfiles
62pipelining = true # rustc pipelining
4d590f95 63
dd8f7d8d
EH
64[cargo-new]
65name = "Your Name" # name to use in `authors` field
66email = "you@example.com" # email address to use in `authors` field
67vcs = "none" # VCS to use ('git', 'hg', 'pijul', 'fossil', 'none')
68
69[http]
70debug = false # HTTP debugging
71proxy = "host:port" # HTTP proxy in libcurl format
72ssl-version = "tlsv1.3" # TLS version to use
73ssl-version.max = "tlsv1.3" # maximum TLS version
74ssl-version.min = "tlsv1.1" # minimum TLS version
75timeout = 30 # timeout for each HTTP request, in seconds
76low-speed-limit = 10 # network timeout threshold (bytes/sec)
77cainfo = "cert.pem" # path to Certificate Authority (CA) bundle
78check-revoke = true # check for SSL certificate revocation
79multiplexing = true # HTTP/2 multiplexing
80user-agent = "…" # the user-agent header
81
82[install]
83root = "/some/path" # `cargo install` destination directory
4d590f95 84
4d590f95 85[net]
dd8f7d8d
EH
86retry = 2 # network retries
87git-fetch-with-cli = true # use the `git` executable for git operations
88offline = false # do not access the network
4d590f95 89
dd8f7d8d
EH
90[registries.<name>] # registries other than crates.io
91index = "…" # URL of the registry index
92token = "…" # authentication token for the registry
93
94[registry]
95default = "…" # name of the default registry
96token = "…" # authentication token for crates.io
97
98[source.<name>] # source definition and replacement
99replace-with = "…" # replace this source with the given named source
100directory = "…" # path to a directory source
101registry = "…" # URL to a registry source
102local-registry = "…" # path to a local registry source
103git = "…" # URL of a git repository source
104branch = "…" # branch name for the git repository
105tag = "…" # tag name for the git repository
106rev = "…" # revision for the git repository
107
108[target.<triple>]
109linker = "…" # linker to use
110runner = "…" # wrapper to run executables
111rustflags = ["…", "…"] # custom flags for `rustc`
112
113[target.<cfg>]
114runner = "…" # wrapper to run executables
115rustflags = ["…", "…"] # custom flags for `rustc`
116
117[target.<triple>.<links>] # `links` build script override
118rustc-link-lib = ["foo"]
119rustc-link-search = ["/path/to/foo"]
120rustc-flags = ["-L", "/some/path"]
121rustc-cfg = ['key="value"']
122rustc-env = {key = "value"}
123rustc-cdylib-link-arg = ["…"]
124metadata_key1 = "value"
125metadata_key2 = "value"
126
127[term]
128verbose = false # whether cargo provides verbose output
129color = 'auto' # whether cargo colorizes output
4d590f95
BE
130```
131
132### Environment variables
133
134Cargo can also be configured through environment variables in addition to the
dd8f7d8d
EH
135TOML configuration files. For each configuration key of the form `foo.bar` the
136environment variable `CARGO_FOO_BAR` can also be used to define the value.
137Keys are converted to uppercase, dots and dashes are converted to underscores.
138For example the `target.x86_64-unknown-linux-gnu.runner` key can also be
139defined by the `CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER` environment
140variable.
141
142Environment variables will take precedence over TOML configuration files.
143Currently only integer, boolean, string and some array values are supported to
144be defined by environment variables. Descriptions below indicate which keys
145support environment variables.
4d590f95
BE
146
147In addition to the system above, Cargo recognizes a few other specific
148[environment variables][env].
149
dd8f7d8d
EH
150### Config-relative paths
151
152Paths in config files may be absolute, relative, or a bare name without any
153path separators. Paths for executables without a path separator will use the
154`PATH` environment variable to search for the executable. Paths for
155non-executables will be relative to where the config value is defined. For
156config files, that is relative to the parent directory of the `.cargo`
157directory where the value was defined. For environment variables it is
158relative to the current working directory.
159
160```toml
161# Relative path examples.
162
163[target.x86_64-unknown-linux-gnu]
164runner = "foo" # Searches `PATH` for `foo`.
165
166[source.vendored-sources]
167# Directory is relative to the parent where `.cargo/config` is located.
168# For example, `/my/project/.cargo/config` would result in `/my/project/vendor`.
169directory = "vendor"
170```
171
737382d7
EH
172### Credentials
173
174Configuration values with sensitive information are stored in the
175`$CARGO_HOME/credentials` file. This file is automatically created and updated
176by [`cargo login`]. It follows the same format as Cargo config files.
177
178```toml
179[registry]
dd8f7d8d 180token = "…" # Access token for crates.io
737382d7 181
dd8f7d8d
EH
182[registries.<name>]
183token = "…" # Access token for the named registry
737382d7
EH
184```
185
186Tokens are used by some Cargo commands such as [`cargo publish`] for
187authenticating with remote registries. Care should be taken to protect the
188tokens and to keep them secret.
189
190As with most other config values, tokens may be specified with environment
dd8f7d8d 191variables. The token for [crates.io] may be specified with the
737382d7
EH
192`CARGO_REGISTRY_TOKEN` environment variable. Tokens for other registries may
193be specified with environment variables of the form
dd8f7d8d
EH
194`CARGO_REGISTRIES_<name>_TOKEN` where `<name>` is the name of the registry in
195all capital letters.
196
197### Configuration keys
198
199This section documents all configuration keys. The description for keys with
200variable parts are annotated with angled brackets like `target.<triple>` where
201the `<triple>` part can be any target triple like
202`target.x86_64-pc-windows-msvc`.
203
204#### `paths`
205* Type: array of strings (paths)
206* Default: none
207* Environment: not supported
208
209An array of paths to local packages which are to be used as overrides for
d1d08378
EH
210dependencies. For more information see the [Overriding Dependencies
211guide](overriding-dependencies.md#paths-overrides).
dd8f7d8d
EH
212
213#### `[alias]`
214* Type: string or array of strings
215* Default: see below
216* Environment: `CARGO_ALIAS_<name>`
217
218The `[alias]` table defines CLI command aliases. For example, running `cargo
219b` is an alias for running `cargo build`. Each key in the table is the
220subcommand, and the value is the actual command to run. The value may be an
221array of strings, where the first element is the command and the following are
222arguments. It may also be a string, which will be split on spaces into
223subcommand and arguments. The following aliases are built-in to Cargo:
224
225```toml
226[alias]
227b = "build"
228c = "check"
229t = "test"
230r = "run"
231```
232
233Aliases are not allowed to redefine existing built-in commands.
234
235#### `[build]`
236
237The `[build]` table controls build-time operations and compiler settings.
238
239##### `build.jobs`
240* Type: integer
241* Default: number of logical CPUs
242* Environment: `CARGO_BUILD_JOBS`
243
244Sets the maximum number of compiler processes to run in parallel.
245
246Can be overridden with the `--jobs` CLI option.
247
248##### `build.rustc`
249* Type: string (program path)
250* Default: "rustc"
251* Environment: `CARGO_BUILD_RUSTC` or `RUSTC`
252
253Sets the executable to use for `rustc`.
254
255##### `build.rustc-wrapper`
256* Type: string (program path)
257* Default: none
258* Environment: `CARGO_BUILD_RUSTC_WRAPPER` or `RUSTC_WRAPPER`
259
260Sets a wrapper to execute instead of `rustc`. The first argument passed to the
261wrapper is the path to the actual `rustc`.
262
263##### `build.rustdoc`
264* Type: string (program path)
265* Default: "rustdoc"
266* Environment: `CARGO_BUILD_RUSTDOC` or `RUSTDOC`
267
268Sets the executable to use for `rustdoc`.
269
270##### `build.target`
271* Type: string
272* Default: host platform
273* Environment: `CARGO_BUILD_TARGET`
274
275The default target platform triple to compile to.
276
277This may also be a relative path to a `.json` target spec file.
278
279Can be overridden with the `--target` CLI option.
280
281##### `build.target-dir`
282* Type: string (path)
283* Default: "target"
284* Environment: `CARGO_BUILD_TARGET_DIR` or `CARGO_TARGET_DIR`
285
286The path to where all compiler output is placed. The default if not specified
287is a directory named `target` located at the root of the workspace.
288
289Can be overridden with the `--target-dir` CLI option.
290
291##### `build.rustflags`
292* Type: string or array of strings
293* Default: none
294* Environment: `CARGO_BUILD_RUSTFLAGS` or `RUSTFLAGS`
295
296Extra command-line flags to pass to `rustc`. The value may be a array of
297strings or a space-separated string.
298
299There are three mutually exclusive sources of extra flags. They are checked in
300order, with the first one being used:
301
3021. `RUSTFLAGS` environment variable.
3032. All matching `target.<triple>.rustflags` and `target.<cfg>.rustflags`
304 config entries joined together.
3053. `build.rustflags` config value.
306
307Additional flags may also be passed with the [`cargo rustc`] command.
308
309If the `--target` flag (or [`build.target`](#buildtarget)) is used, then the
310flags will only be passed to the compiler for the target. Things being built
311for the host, such as build scripts or proc macros, will not receive the args.
312Without `--target`, the flags will be passed to all compiler invocations
313(including build scripts and proc macros) because dependencies are shared. If
314you have args that you do not want to pass to build scripts or proc macros and
315are building for the host, pass `--target` with the host triple.
316
317##### `build.rustdocflags`
318* Type: string or array of strings
319* Default: none
320* Environment: `CARGO_BUILD_RUSTDOCFLAGS` or `RUSTDOCFLAGS`
321
322Extra command-line flags to pass to `rustdoc`. The value may be a array of
323strings or a space-separated string.
324
325There are two mutually exclusive sources of extra flags. They are checked in
326order, with the first one being used:
327
3281. `RUSTDOCFLAGS` environment variable.
3292. `build.rustdocflags` config value.
330
331Additional flags may also be passed with the [`cargo rustdoc`] command.
332
333##### `build.incremental`
334* Type: bool
335* Default: from profile
336* Environment: `CARGO_BUILD_INCREMENTAL` or `CARGO_INCREMENTAL`
337
338Whether or not to perform [incremental compilation]. The default if not set is
339to use the value from the [profile]. Otherwise this overrides the setting of
340all profiles.
341
342The `CARGO_INCREMENTAL` environment variable can be set to `1` to force enable
343incremental compilation for all profiles, or `0` to disable it. This env var
344overrides the config setting.
345
346##### `build.dep-info-basedir`
347* Type: string (path)
348* Default: none
349* Environment: `CARGO_BUILD_DEP_INFO_BASEDIR`
350
765c80da
EH
351Strips the given path prefix from [dep
352info](../guide/build-cache.md#dep-info-files) file paths. This config setting
353is intended to convert absolute paths to relative paths for tools that require
354relative paths.
dd8f7d8d
EH
355
356The setting itself is a config-relative path. So, for example, a value of
357`"."` would strip all paths starting with the parent directory of the `.cargo`
358directory.
359
360##### `build.pipelining`
361* Type: boolean
362* Default: true
363* Environment: `CARGO_BUILD_PIPELINING`
364
365Controls whether or not build pipelining is used. This allows Cargo to
366schedule overlapping invocations of `rustc` in parallel when possible.
367
368#### `[cargo-new]`
369
370The `[cargo-new]` table defines defaults for the [`cargo new`] command.
371
372##### `cargo-new.name`
373* Type: string
374* Default: from environment
375* Environment: `CARGO_NAME` or `CARGO_CARGO_NEW_NAME`
376
377Defines the name to use in the `authors` field when creating a new
378`Cargo.toml` file. If not specified in the config, Cargo searches the
379environment or your `git` configuration as described in the [`cargo new`]
380documentation.
381
382##### `cargo-new.email`
383* Type: string
384* Default: from environment
385* Environment: `CARGO_EMAIL` or `CARGO_CARGO_NEW_EMAIL`
386
387Defines the email address used in the `authors` field when creating a new
388`Cargo.toml` file. If not specified in the config, Cargo searches the
389environment or your `git` configuration as described in the [`cargo new`]
390documentation. The `email` value may be set to an empty string to prevent
391Cargo from placing an address in the authors field.
392
393##### `cargo-new.vcs`
394* Type: string
395* Default: "git" or "none"
396* Environment: `CARGO_CARGO_NEW_VCS`
397
398Specifies the source control system to use for initializing a new repository.
399Valid values are `git`, `hg` (for Mercurial), `pijul`, `fossil` or `none` to
400disable this behavior. Defaults to `git`, or `none` if already inside a VCS
401repository. Can be overridden with the `--vcs` CLI option.
402
403#### `[http]`
404
405The `[http]` table defines settings for HTTP behavior. This includes fetching
406crate dependencies and accessing remote git repositories.
407
408##### `http.debug`
409* Type: boolean
410* Default: false
411* Environment: `CARGO_HTTP_DEBUG`
412
413If `true`, enables debugging of HTTP requests. The debug information can be
414seen by setting the `CARGO_LOG=cargo::ops::registry=debug` environment
415variable (or use `trace` for even more information).
416
417Be wary when posting logs from this output in a public location. The output
418may include headers with authentication tokens which you don't want to leak!
419Be sure to review logs before posting them.
737382d7 420
dd8f7d8d
EH
421##### `http.proxy`
422* Type: string
423* Default: none
424* Environment: `CARGO_HTTP_PROXY` or `HTTPS_PROXY` or `https_proxy` or `http_proxy`
425
426Sets an HTTP and HTTPS proxy to use. The format is in [libcurl format] as in
427`[protocol://]host[:port]`. If not set, Cargo will also check the `http.proxy`
428setting in your global git configuration. If none of those are set, the
429`HTTPS_PROXY` or `https_proxy` environment variables set the proxy for HTTPS
430requests, and `http_proxy` sets it for HTTP requests.
431
432##### `http.timeout`
433* Type: integer
434* Default: 30
435* Environment: `CARGO_HTTP_TIMEOUT` or `HTTP_TIMEOUT`
436
437Sets the timeout for each HTTP request, in seconds.
438
439##### `http.cainfo`
440* Type: string (path)
441* Default: none
442* Environment: `CARGO_HTTP_CAINFO`
443
444Path to a Certificate Authority (CA) bundle file, used to verify TLS
445certificates. If not specified, Cargo attempts to use the system certificates.
446
447##### `http.check-revoke`
448* Type: boolean
449* Default: true (Windows) false (all others)
450* Environment: `CARGO_HTTP_CHECK_REVOKE`
451
452This determines whether or not TLS certificate revocation checks should be
453performed. This only works on Windows.
454
455##### `http.ssl-version`
456* Type: string or min/max table
457* Default: none
458* Environment: `CARGO_HTTP_SSL_VERSION`
459
460This sets the minimum TLS version to use. It takes a string, with one of the
461possible values of "default", "tlsv1", "tlsv1.0", "tlsv1.1", "tlsv1.2", or
462"tlsv1.3".
463
464This may alternatively take a table with two keys, `min` and `max`, which each
465take a string value of the same kind that specifies the minimum and maximum
466range of TLS versions to use.
467
468The default is a minimum version of "tlsv1.0" and a max of the newest version
469supported on your platform, typically "tlsv1.3".
470
471##### `http.low-speed-limit`
472* Type: integer
473* Default: 10
474* Environment: `CARGO_HTTP_LOW_SPEED_LIMIT`
475
476This setting controls timeout behavior for slow connections. If the average
477transfer speed in bytes per second is below the given value for
478[`http.timeout`](#httptimeout) seconds (default 30 seconds), then the
479connection is considered too slow and Cargo will abort and retry.
480
481##### `http.multiplexing`
482* Type: boolean
483* Default: true
484* Environment: `CARGO_HTTP_MULTIPLEXING`
485
486When `true`, Cargo will attempt to use the HTTP2 protocol with multiplexing.
487This allows multiple requests to use the same connection, usually improving
488performance when fetching multiple files. If `false`, Cargo will use HTTP 1.1
489without pipelining.
490
491##### `http.user-agent`
492* Type: string
493* Default: Cargo's version
494* Environment: `CARGO_HTTP_USER_AGENT`
495
496Specifies a custom user-agent header to use. The default if not specified is a
497string that includes Cargo's version.
498
499#### `[install]`
500
501The `[install]` table defines defaults for the [`cargo install`] command.
502
503##### `install.root`
504* Type: string (path)
505* Default: Cargo's home directory
506* Environment: `CARGO_INSTALL_ROOT`
507
508Sets the path to the root directory for installing executables for [`cargo
509install`]. Executables go into a `bin` directory underneath the root.
510
511The default if not specified is Cargo's home directory (default `.cargo` in
512your home directory).
513
514Can be overridden with the `--root` command-line option.
515
516#### `[net]`
517
518The `[net]` table controls networking configuration.
519
520##### `net.retry`
521* Type: integer
522* Default: 2
523* Environment: `CARGO_NET_RETRY`
524
525Number of times to retry possibly spurious network errors.
526
527##### `net.git-fetch-with-cli`
528* Type: boolean
529* Default: false
530* Environment: `CARGO_NET_GIT_FETCH_WITH_CLI`
531
532If this is `true`, then Cargo will use the `git` executable to fetch registry
533indexes and git dependencies. If `false`, then it uses a built-in `git`
534library.
535
536Setting this to `true` can be helpful if you have special authentication
5d9eff36
EH
537requirements that Cargo does not support. See [Git
538Authentication](../appendix/git-authentication.md) for more information about
539setting up git authentication.
dd8f7d8d
EH
540
541##### `net.offline`
542* Type: boolean
543* Default: false
544* Environment: `CARGO_NET_OFFLINE`
545
546If this is `true`, then Cargo will avoid accessing the network, and attempt to
547proceed with locally cached data. If `false`, Cargo will access the network as
548needed, and generate an error if it encounters a network error.
549
550Can be overridden with the `--offline` command-line option.
551
552#### `[registries]`
553
554The `[registries]` table is used for specifying additional [registries]. It
555consists of a sub-table for each named registry.
556
557##### `registries.<name>.index`
558* Type: string (url)
559* Default: none
560* Environment: `CARGO_REGISTRIES_<name>_INDEX`
561
562Specifies the URL of the git index for the registry.
563
564##### `registries.<name>.token`
565* Type: string
566* Default: none
567* Environment: `CARGO_REGISTRIES_<name>_TOKEN`
568
569Specifies the authentication token for the given registry. This value should
570only appear in the [credentials](#credentials) file. This is used for registry
571commands like [`cargo publish`] that require authentication.
572
573Can be overridden with the `--token` command-line option.
574
575#### `[registry]`
576
577The `[registry]` table controls the default registry used when one is not
578specified.
579
580##### `registry.index`
581
582This value is deprecated and should not be used.
583
584##### `registry.default`
585* Type: string
586* Default: `"crates-io"`
587* Environment: `CARGO_REGISTRY_DEFAULT`
588
589The name of the registry (from the [`registries` table](#registries)) to use
590by default for registry commands like [`cargo publish`].
591
592Can be overridden with the `--registry` command-line option.
593
594##### `registry.token`
595* Type: string
596* Default: none
597* Environment: `CARGO_REGISTRY_TOKEN`
598
599Specifies the authentication token for [crates.io]. This value should only
600appear in the [credentials](#credentials) file. This is used for registry
601commands like [`cargo publish`] that require authentication.
602
603Can be overridden with the `--token` command-line option.
604
605#### `[source]`
606
607The `[source]` table defines the registry sources available. See [Source
608Replacement] for more information. It consists of a sub-table for each named
609source. A source should only define one kind (directory, registry,
610local-registry, or git).
611
612##### `source.<name>.replace-with`
613* Type: string
614* Default: none
615* Environment: not supported
616
617If set, replace this source with the given named source.
618
619##### `source.<name>.directory`
620* Type: string (path)
621* Default: none
622* Environment: not supported
623
624Sets the path to a directory to use as a directory source.
625
626##### `source.<name>.registry`
627* Type: string (url)
628* Default: none
629* Environment: not supported
630
631Sets the URL to use for a registry source.
632
633##### `source.<name>.local-registry`
634* Type: string (path)
635* Default: none
636* Environment: not supported
637
638Sets the path to a directory to use as a local registry source.
639
640##### `source.<name>.git`
641* Type: string (url)
642* Default: none
643* Environment: not supported
644
645Sets the URL to use for a git repository source.
646
647##### `source.<name>.branch`
648* Type: string
649* Default: none
650* Environment: not supported
651
652Sets the branch name to use for a git repository.
653
654If none of `branch`, `tag`, or `rev` is set, defaults to the `master` branch.
655
656##### `source.<name>.tag`
657* Type: string
658* Default: none
659* Environment: not supported
660
661Sets the tag name to use for a git repository.
662
663If none of `branch`, `tag`, or `rev` is set, defaults to the `master` branch.
664
665##### `source.<name>.rev`
666* Type: string
667* Default: none
668* Environment: not supported
669
670Sets the [revision] to use for a git repository.
671
672If none of `branch`, `tag`, or `rev` is set, defaults to the `master` branch.
673
674
675#### `[target]`
676
677The `[target]` table is used for specifying settings for specific platform
678targets. It consists of a sub-table which is either a platform triple or a
679[`cfg()` expression]. The given values will be used if the target platform
680matches either the `<triple>` value or the `<cfg>` expression.
681
682```toml
683[target.thumbv7m-none-eabi]
684linker = "arm-none-eabi-gcc"
685runner = "my-emulator"
686rustflags = ["…", "…"]
687
688[target.'cfg(all(target_arch = "arm", target_os = "none"))']
689runner = "my-arm-wrapper"
690rustflags = ["…", "…"]
691```
692
693`cfg` values come from those built-in to the compiler (run `rustc --print=cfg`
694to view), values set by [build scripts], and extra `--cfg` flags passed to
695`rustc` (such as those defined in `RUSTFLAGS`). Do not try to match on
696`debug_assertions` or Cargo features like `feature="foo"`.
697
698If using a target spec JSON file, the `<triple>` value is the filename stem.
699For example `--target foo/bar.json` would match `[target.bar]`.
700
701##### `target.<triple>.ar`
702
703This option is deprecated and unused.
704
705##### `target.<triple>.linker`
706* Type: string (program path)
707* Default: none
708* Environment: `CARGO_TARGET_<triple>_LINKER`
709
710Specifies the linker which is passed to `rustc` (via [`-C linker`]) when the
711`<triple>` is being compiled for. By default, the linker is not overridden.
712
713##### `target.<triple>.runner`
714* Type: string or array of strings (program path and args)
715* Default: none
716* Environment: `CARGO_TARGET_<triple>_RUNNER`
717
718If a runner is provided, executables for the target `<triple>` will be
719executed by invoking the specified runner with the actual executable passed as
720an argument. This applies to [`cargo run`], [`cargo test`] and [`cargo bench`]
721commands. By default, compiled executables are executed directly.
722
723The value may be an array of strings like `['/path/to/program', 'somearg']` or
724a space-separated string like `'/path/to/program somearg'`. The arguments will
725be passed to the runner with the executable to run as the last argument. If
726the runner program does not have path separators, it will search `PATH` for
727the runner executable.
728
729##### `target.<cfg>.runner`
730
731This is similar to the [target runner](#targettriplerunner), but using
732a [`cfg()` expression]. If both a `<triple>` and `<cfg>` runner match,
733the `<triple>` will take precedence. It is an error if more than one
734`<cfg>` runner matches the current target.
735
736##### `target.<triple>.rustflags`
737* Type: string or array of strings
738* Default: none
739* Environment: `CARGO_TARGET_<triple>_RUSTFLAGS`
740
741Passes a set of custom flags to the compiler for this `<triple>`. The value
742may be a array of strings or a space-separated string.
743
744See [`build.rustflags`](#buildrustflags) for more details on the different
745ways to specific extra flags.
746
747##### `target.<cfg>.rustflags`
748
749This is similar to the [target rustflags](#targettriplerustflags), but
750using a [`cfg()` expression]. If several `<cfg>` and `<triple>` entries
751match the current target, the flags are joined together.
752
753##### `target.<triple>.<links>`
754
755The links sub-table provides a way to [override a build script]. When
756specified, the build script for the given `links` library will not be
757run, and the given values will be used instead.
758
759```toml
760[target.x86_64-unknown-linux-gnu.foo]
761rustc-link-lib = ["foo"]
762rustc-link-search = ["/path/to/foo"]
763rustc-flags = "-L /some/path"
764rustc-cfg = ['key="value"']
765rustc-env = {key = "value"}
766rustc-cdylib-link-arg = ["…"]
767metadata_key1 = "value"
768metadata_key2 = "value"
769```
770
771#### `[term]`
772
773The `[term]` table controls terminal output and interaction.
774
775##### `term.verbose`
776* Type: boolean
777* Default: false
778* Environment: `CARGO_TERM_VERBOSE`
779
780Controls whether or not extra detailed messages are displayed by Cargo.
781
782Specifying the `--quiet` flag will override and disable verbose output.
783Specifying the `--verbose` flag will override and force verbose output.
784
785##### `term.color`
786* Type: string
787* Default: "auto"
788* Environment: `CARGO_TERM_COLOR`
789
790Controls whether or not colored output is used in the terminal. Possible values:
791
792* `auto` (default): Automatically detect if color support is available on the
793 terminal.
794* `always`: Always display colors.
795* `never`: Never display colors.
796
797Can be overridden with the `--color` command-line option.
798
799
800[`cargo bench`]: ../commands/cargo-bench.md
b119b891 801[`cargo login`]: ../commands/cargo-login.md
dd8f7d8d 802[`cargo new`]: ../commands/cargo-new.md
b119b891 803[`cargo publish`]: ../commands/cargo-publish.md
dd8f7d8d
EH
804[`cargo run`]: ../commands/cargo-run.md
805[`cargo rustc`]: ../commands/cargo-rustc.md
806[`cargo test`]: ../commands/cargo-test.md
807[`cargo rustdoc`]: ../commands/cargo-rustdoc.md
808[`cargo install`]: ../commands/cargo-install.md
b119b891 809[env]: environment-variables.md
dd8f7d8d
EH
810[`cfg()` expression]: ../../reference/conditional-compilation.html
811[build scripts]: build-scripts.md
812[`-C linker`]: ../../rustc/codegen-options/index.md#linker
813[override a build script]: build-scripts.md#overriding-build-scripts
814[toml]: https://github.com/toml-lang/toml
815[incremental compilation]: profiles.md#incremental
816[profile]: profiles.md
817[libcurl format]: https://ec.haxx.se/usingcurl-proxies.html
818[source replacement]: source-replacement.md
819[revision]: https://git-scm.com/docs/gitrevisions
820[registries]: registries.md
821[crates.io]: https://crates.io/