fork/cargo

git clone https://git.julia.blue/fork/cargo

Weihang Lofix: use `host-tuple` for host target subsitution (#16003)f2932725b

0.93.0
17.4 KiB402 linesraw
1CARGO-CHECK(1)
2
3NAME
4       cargo-check — Check the current package
5
6SYNOPSIS
7       cargo check [options]
8
9DESCRIPTION
10       Check a local package and all of its dependencies for errors. This will
11       essentially compile the packages without performing the final step of
12       code generation, which is faster than running cargo build. The compiler
13       will save metadata files to disk so that future runs will reuse them if
14       the source has not been modified. Some diagnostics and errors are only
15       emitted during code generation, so they inherently won’t be reported
16       with cargo check.
17
18OPTIONS
19   Package Selection
20       By default, when no package selection options are given, the packages
21       selected depend on the selected manifest file (based on the current
22       working directory if --manifest-path is not given). If the manifest is
23       the root of a workspace then the workspaces default members are
24       selected, otherwise only the package defined by the manifest will be
25       selected.
26
27       The default members of a workspace can be set explicitly with the
28       workspace.default-members key in the root manifest. If this is not set,
29       a virtual workspace will include all workspace members (equivalent to
30       passing --workspace), and a non-virtual workspace will include only the
31       root crate itself.
32
33       -p spec…, --package spec…
34           Check only the specified packages. See cargo-pkgid(1) for the SPEC
35           format. This flag may be specified multiple times and supports
36           common Unix glob patterns like *, ? and []. However, to avoid your
37           shell accidentally expanding glob patterns before Cargo handles
38           them, you must use single quotes or double quotes around each
39           pattern.
40
41       --workspace
42           Check all members in the workspace.
43
44       --all
45           Deprecated alias for --workspace.
46
47       --exclude SPEC…
48           Exclude the specified packages. Must be used in conjunction with the
49           --workspace flag. This flag may be specified multiple times and
50           supports common Unix glob patterns like *, ? and []. However, to
51           avoid your shell accidentally expanding glob patterns before Cargo
52           handles them, you must use single quotes or double quotes around
53           each pattern.
54
55   Target Selection
56       When no target selection options are given, cargo check will check all
57       binary and library targets of the selected packages. Binaries are
58       skipped if they have required-features that are missing.
59
60       Passing target selection flags will check only the specified targets.
61
62       Note that --bin, --example, --test and --bench flags also support common
63       Unix glob patterns like *, ? and []. However, to avoid your shell
64       accidentally expanding glob patterns before Cargo handles them, you must
65       use single quotes or double quotes around each glob pattern.
66
67       --lib
68           Check the package’s library.
69
70       --bin name…
71           Check the specified binary. This flag may be specified multiple
72           times and supports common Unix glob patterns.
73
74       --bins
75           Check all binary targets.
76
77       --example name…
78           Check the specified example. This flag may be specified multiple
79           times and supports common Unix glob patterns.
80
81       --examples
82           Check all example targets.
83
84       --test name…
85           Check the specified integration test. This flag may be specified
86           multiple times and supports common Unix glob patterns.
87
88       --tests
89           Check all targets that have the test = true manifest flag set. By
90           default this includes the library and binaries built as unittests,
91           and integration tests. Be aware that this will also build any
92           required dependencies, so the lib target may be built twice (once as
93           a unittest, and once as a dependency for binaries, integration
94           tests, etc.). Targets may be enabled or disabled by setting the test
95           flag in the manifest settings for the target.
96
97       --bench name…
98           Check the specified benchmark. This flag may be specified multiple
99           times and supports common Unix glob patterns.
100
101       --benches
102           Check all targets that have the bench = true manifest flag set. By
103           default this includes the library and binaries built as benchmarks,
104           and bench targets. Be aware that this will also build any required
105           dependencies, so the lib target may be built twice (once as a
106           benchmark, and once as a dependency for binaries, benchmarks, etc.).
107           Targets may be enabled or disabled by setting the bench flag in the
108           manifest settings for the target.
109
110       --all-targets
111           Check all targets. This is equivalent to specifying --lib --bins
112           --tests --benches --examples.
113
114   Feature Selection
115       The feature flags allow you to control which features are enabled. When
116       no feature options are given, the default feature is activated for every
117       selected package.
118
119       See the features documentation
120       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
121       for more details.
122
123       -F features, --features features
124           Space or comma separated list of features to activate. Features of
125           workspace members may be enabled with package-name/feature-name
126           syntax. This flag may be specified multiple times, which enables all
127           specified features.
128
129       --all-features
130           Activate all available features of all selected packages.
131
132       --no-default-features
133           Do not activate the default feature of the selected packages.
134
135   Compilation Options
136       --target triple
137           Check for the specified target architecture. Flag may be specified
138           multiple times. The default is the host architecture. The general
139           format of the triple is <arch><sub>-<vendor>-<sys>-<abi>.
140
141           Possible values:
142
143           o  Any supported target in rustc --print target-list.
144
145           o  "host-tuple", which will internally be substituted by the
146              host’s target. This can be particularly useful if you’re
147              cross-compiling some crates, and don’t want to specify your
148              host’s machine as a target (for instance, an xtask in a shared
149              project that may be worked on by many hosts).
150
151           o  A path to a custom target specification. See Custom Target Lookup
152              Path
153              <https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>
154              for more information.
155
156           This may also be specified with the build.target config value
157           <https://doc.rust-lang.org/cargo/reference/config.html>.
158
159           Note that specifying this flag makes Cargo run in a different mode
160           where the target artifacts are placed in a separate directory. See
161           the build cache
162           <https://doc.rust-lang.org/cargo/reference/build-cache.html>
163           documentation for more details.
164
165       -r, --release
166           Check optimized artifacts with the release profile. See also the
167           --profile option for choosing a specific profile by name.
168
169       --profile name
170           Check with the given profile.
171
172           As a special case, specifying the test profile will also enable
173           checking in test mode which will enable checking tests and enable
174           the test cfg option. See rustc tests
175           <https://doc.rust-lang.org/rustc/tests/index.html> for more detail.
176
177           See the reference
178           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
179           details on profiles.
180
181       --timings=fmts
182           Output information how long each compilation takes, and track
183           concurrency information over time. Accepts an optional
184           comma-separated list of output formats; --timings without an
185           argument will default to --timings=html. Specifying an output format
186           (rather than the default) is unstable and requires
187           -Zunstable-options. Valid output formats:
188
189           o  html (unstable, requires -Zunstable-options): Write a
190              human-readable file cargo-timing.html to the target/cargo-timings
191              directory with a report of the compilation. Also write a report
192              to the same directory with a timestamp in the filename if you
193              want to look at older runs. HTML output is suitable for human
194              consumption only, and does not provide machine-readable timing
195              data.
196
197           o  json (unstable, requires -Zunstable-options): Emit
198              machine-readable JSON information about timing information.
199
200   Output Options
201       --target-dir directory
202           Directory for all generated artifacts and intermediate files. May
203           also be specified with the CARGO_TARGET_DIR environment variable, or
204           the build.target-dir config value
205           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
206           target in the root of the workspace.
207
208   Display Options
209       -v, --verbose
210           Use verbose output. May be specified twice for “very verbose”
211           output which includes extra output such as dependency warnings and
212           build script output. May also be specified with the term.verbose
213           config value
214           <https://doc.rust-lang.org/cargo/reference/config.html>.
215
216       -q, --quiet
217           Do not print cargo log messages. May also be specified with the
218           term.quiet config value
219           <https://doc.rust-lang.org/cargo/reference/config.html>.
220
221       --color when
222           Control when colored output is used. Valid values:
223
224           o  auto (default): Automatically detect if color support is
225              available on the terminal.
226
227           o  always: Always display colors.
228
229           o  never: Never display colors.
230
231           May also be specified with the term.color config value
232           <https://doc.rust-lang.org/cargo/reference/config.html>.
233
234       --message-format fmt
235           The output format for diagnostic messages. Can be specified multiple
236           times and consists of comma-separated values. Valid values:
237
238           o  human (default): Display in a human-readable text format.
239              Conflicts with short and json.
240
241           o  short: Emit shorter, human-readable text messages. Conflicts with
242              human and json.
243
244           o  json: Emit JSON messages to stdout. See the reference
245              <https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages>
246              for more details. Conflicts with human and short.
247
248           o  json-diagnostic-short: Ensure the rendered field of JSON messages
249              contains the “short” rendering from rustc. Cannot be used
250              with human or short.
251
252           o  json-diagnostic-rendered-ansi: Ensure the rendered field of JSON
253              messages contains embedded ANSI color codes for respecting
254              rustc’s default color scheme. Cannot be used with human or
255              short.
256
257           o  json-render-diagnostics: Instruct Cargo to not include rustc
258              diagnostics in JSON messages printed, but instead Cargo itself
259              should render the JSON diagnostics coming from rustc. Cargo’s
260              own JSON diagnostics and others coming from rustc are still
261              emitted. Cannot be used with human or short.
262
263   Manifest Options
264       --manifest-path path
265           Path to the Cargo.toml file. By default, Cargo searches for the
266           Cargo.toml file in the current directory or any parent directory.
267
268       --ignore-rust-version
269           Ignore rust-version specification in packages.
270
271       --locked
272           Asserts that the exact same dependencies and versions are used as
273           when the existing Cargo.lock file was originally generated. Cargo
274           will exit with an error when either of the following scenarios
275           arises:
276
277           o  The lock file is missing.
278
279           o  Cargo attempted to change the lock file due to a different
280              dependency resolution.
281
282           It may be used in environments where deterministic builds are
283           desired, such as in CI pipelines.
284
285       --offline
286           Prevents Cargo from accessing the network for any reason. Without
287           this flag, Cargo will stop with an error if it needs to access the
288           network and the network is not available. With this flag, Cargo will
289           attempt to proceed without the network if possible.
290
291           Beware that this may result in different dependency resolution than
292           online mode. Cargo will restrict itself to crates that are
293           downloaded locally, even if there might be a newer version as
294           indicated in the local copy of the index. See the cargo-fetch(1)
295           command to download dependencies before going offline.
296
297           May also be specified with the net.offline config value
298           <https://doc.rust-lang.org/cargo/reference/config.html>.
299
300       --frozen
301           Equivalent to specifying both --locked and --offline.
302
303       --lockfile-path PATH
304           Changes the path of the lockfile from the default
305           (<workspace_root>/Cargo.lock) to PATH. PATH must end with Cargo.lock
306           (e.g. --lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that
307           providing --lockfile-path will ignore existing lockfile at the
308           default path, and instead will either use the lockfile from PATH, or
309           write a new lockfile into the provided PATH if it doesn’t exist.
310           This flag can be used to run most commands in read-only directories,
311           writing lockfile into the provided PATH.
312
313           This option is only available on the nightly channel
314           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
315           requires the -Z unstable-options flag to enable (see #14421
316           <https://github.com/rust-lang/cargo/issues/14421>).
317
318   Common Options
319       +toolchain
320           If Cargo has been installed with rustup, and the first argument to
321           cargo begins with +, it will be interpreted as a rustup toolchain
322           name (such as +stable or +nightly). See the rustup documentation
323           <https://rust-lang.github.io/rustup/overrides.html> for more
324           information about how toolchain overrides work.
325
326       --config KEY=VALUE or PATH
327           Overrides a Cargo configuration value. The argument should be in
328           TOML syntax of KEY=VALUE, or provided as a path to an extra
329           configuration file. This flag may be specified multiple times. See
330           the command-line overrides section
331           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
332           for more information.
333
334       -C PATH
335           Changes the current working directory before executing any specified
336           operations. This affects things like where cargo looks by default
337           for the project manifest (Cargo.toml), as well as the directories
338           searched for discovering .cargo/config.toml, for example. This
339           option must appear before the command name, for example cargo -C
340           path/to/my-project build.
341
342           This option is only available on the nightly channel
343           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
344           requires the -Z unstable-options flag to enable (see #10098
345           <https://github.com/rust-lang/cargo/issues/10098>).
346
347       -h, --help
348           Prints help information.
349
350       -Z flag
351           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
352           details.
353
354   Miscellaneous Options
355       -j N, --jobs N
356           Number of parallel jobs to run. May also be specified with the
357           build.jobs config value
358           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to
359           the number of logical CPUs. If negative, it sets the maximum number
360           of parallel jobs to the number of logical CPUs plus provided value.
361           If a string default is provided, it sets the value back to defaults.
362           Should not be 0.
363
364       --keep-going
365           Build as many crates in the dependency graph as possible, rather
366           than aborting the build on the first one that fails to build.
367
368           For example if the current package depends on dependencies fails and
369           works, one of which fails to build, cargo check -j1 may or may not
370           build the one that succeeds (depending on which one of the two
371           builds Cargo picked to run first), whereas cargo check -j1
372           --keep-going would definitely run both builds, even if the one run
373           first fails.
374
375       --future-incompat-report
376           Displays a future-incompat report for any future-incompatible
377           warnings produced during execution of this command
378
379           See cargo-report(1)
380
381ENVIRONMENT
382       See the reference
383       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
384       for details on environment variables that Cargo reads.
385
386EXIT STATUS
387       o  0: Cargo succeeded.
388
389       o  101: Cargo failed to complete.
390
391EXAMPLES
392       1. Check the local package for errors:
393
394              cargo check
395
396       2. Check all targets, including unit tests:
397
398              cargo check --all-targets --profile=test
399
400SEE ALSO
401       cargo(1), cargo-build(1)
402