Matthew Maurer | bd39854 | 2019-09-05 16:25:08 -0700 | [diff] [blame] | 1 | '\" t |
| 2 | .\" Title: cargo-rustc |
| 3 | .\" Author: [see the "AUTHOR(S)" section] |
| 4 | .\" Generator: Asciidoctor 1.5.8 |
| 5 | .\" Date: 2019-04-16 |
| 6 | .\" Manual: \ \& |
| 7 | .\" Source: \ \& |
| 8 | .\" Language: English |
| 9 | .\" |
| 10 | .TH "CARGO\-RUSTC" "1" "2019-04-16" "\ \&" "\ \&" |
| 11 | .ie \n(.g .ds Aq \(aq |
| 12 | .el .ds Aq ' |
| 13 | .ss \n[.ss] 0 |
| 14 | .nh |
| 15 | .ad l |
| 16 | .de URL |
| 17 | \fI\\$2\fP <\\$1>\\$3 |
| 18 | .. |
| 19 | .als MTO URL |
| 20 | .if \n[.g] \{\ |
| 21 | . mso www.tmac |
| 22 | . am URL |
| 23 | . ad l |
| 24 | . . |
| 25 | . am MTO |
| 26 | . ad l |
| 27 | . . |
| 28 | . LINKSTYLE blue R < > |
| 29 | .\} |
| 30 | .SH "NAME" |
| 31 | cargo\-rustc \- Compile the current package, and pass extra options to the compiler |
| 32 | .SH "SYNOPSIS" |
| 33 | .sp |
| 34 | \fBcargo rustc [\fIOPTIONS\fP] [\-\- \fIARGS\fP]\fP |
| 35 | .SH "DESCRIPTION" |
| 36 | .sp |
| 37 | The specified target for the current package (or package specified by \fB\-p\fP if |
| 38 | provided) will be compiled along with all of its dependencies. The specified |
| 39 | \fIARGS\fP will all be passed to the final compiler invocation, not any of the |
| 40 | dependencies. Note that the compiler will still unconditionally receive |
| 41 | arguments such as \fB\-L\fP, \fB\-\-extern\fP, and \fB\-\-crate\-type\fP, and the specified |
| 42 | \fIARGS\fP will simply be added to the compiler invocation. |
| 43 | .sp |
| 44 | See \c |
| 45 | .URL "https://doc.rust\-lang.org/rustc/index.html" "" " " |
| 46 | for documentation on rustc |
| 47 | flags. |
| 48 | .sp |
| 49 | This command requires that only one target is being compiled when additional |
| 50 | arguments are provided. If more than one target is available for the current |
| 51 | package the filters of \fB\-\-lib\fP, \fB\-\-bin\fP, etc, must be used to select which |
| 52 | target is compiled. |
| 53 | To pass flags to all compiler processes spawned by Cargo, use the \fBRUSTFLAGS\fP |
| 54 | environment variable or the \fBbuild.rustflags\fP |
| 55 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 56 | .SH "OPTIONS" |
| 57 | .SS "Package Selection" |
| 58 | .sp |
| 59 | By default, the package in the current working directory is selected. The \fB\-p\fP |
| 60 | flag can be used to choose a different package in a workspace. |
| 61 | .sp |
| 62 | \fB\-p\fP \fISPEC\fP, \fB\-\-package\fP \fISPEC\fP |
| 63 | .RS 4 |
| 64 | The package to build. See \fBcargo\-pkgid\fP(1) for |
| 65 | the SPEC format. |
| 66 | .RE |
| 67 | .SS "Target Selection" |
| 68 | .sp |
| 69 | When no target selection options are given, \fBcargo rustc\fP will build all |
| 70 | binary and library targets of the selected package. |
| 71 | .sp |
| 72 | Passing target selection flags will build only the |
| 73 | specified targets. |
| 74 | .sp |
| 75 | \fB\-\-lib\fP |
| 76 | .RS 4 |
| 77 | Build the package\(cqs library. |
| 78 | .RE |
| 79 | .sp |
| 80 | \fB\-\-bin\fP \fINAME\fP... |
| 81 | .RS 4 |
| 82 | Build the specified binary. This flag may be specified multiple times. |
| 83 | .RE |
| 84 | .sp |
| 85 | \fB\-\-bins\fP |
| 86 | .RS 4 |
| 87 | Build all binary targets. |
| 88 | .RE |
| 89 | .sp |
| 90 | \fB\-\-example\fP \fINAME\fP... |
| 91 | .RS 4 |
| 92 | Build the specified example. This flag may be specified multiple times. |
| 93 | .RE |
| 94 | .sp |
| 95 | \fB\-\-examples\fP |
| 96 | .RS 4 |
| 97 | Build all example targets. |
| 98 | .RE |
| 99 | .sp |
| 100 | \fB\-\-test\fP \fINAME\fP... |
| 101 | .RS 4 |
| 102 | Build the specified integration test. This flag may be specified multiple |
| 103 | times. |
| 104 | .RE |
| 105 | .sp |
| 106 | \fB\-\-tests\fP |
| 107 | .RS 4 |
| 108 | Build all targets in test mode that have the \fBtest = true\fP manifest |
| 109 | flag set. By default this includes the library and binaries built as |
| 110 | unittests, and integration tests. Be aware that this will also build any |
| 111 | required dependencies, so the lib target may be built twice (once as a |
| 112 | unittest, and once as a dependency for binaries, integration tests, etc.). |
| 113 | Targets may be enabled or disabled by setting the \fBtest\fP flag in the |
| 114 | manifest settings for the target. |
| 115 | .RE |
| 116 | .sp |
| 117 | \fB\-\-bench\fP \fINAME\fP... |
| 118 | .RS 4 |
| 119 | Build the specified benchmark. This flag may be specified multiple times. |
| 120 | .RE |
| 121 | .sp |
| 122 | \fB\-\-benches\fP |
| 123 | .RS 4 |
| 124 | Build all targets in benchmark mode that have the \fBbench = true\fP |
| 125 | manifest flag set. By default this includes the library and binaries built |
| 126 | as benchmarks, and bench targets. Be aware that this will also build any |
| 127 | required dependencies, so the lib target may be built twice (once as a |
| 128 | benchmark, and once as a dependency for binaries, benchmarks, etc.). |
| 129 | Targets may be enabled or disabled by setting the \fBbench\fP flag in the |
| 130 | manifest settings for the target. |
| 131 | .RE |
| 132 | .sp |
| 133 | \fB\-\-all\-targets\fP |
| 134 | .RS 4 |
| 135 | Build all targets. This is equivalent to specifying \fB\-\-lib \-\-bins |
| 136 | \-\-tests \-\-benches \-\-examples\fP. |
| 137 | .RE |
| 138 | .SS "Feature Selection" |
| 139 | .sp |
| 140 | When no feature options are given, the \fBdefault\fP feature is activated for |
| 141 | every selected package. |
| 142 | .sp |
| 143 | \fB\-\-features\fP \fIFEATURES\fP |
| 144 | .RS 4 |
| 145 | Space or comma separated list of features to activate. These features only |
| 146 | apply to the current directory\(cqs package. Features of direct dependencies |
| 147 | may be enabled with \fB<dep\-name>/<feature\-name>\fP syntax. |
| 148 | .RE |
| 149 | .sp |
| 150 | \fB\-\-all\-features\fP |
| 151 | .RS 4 |
| 152 | Activate all available features of all selected packages. |
| 153 | .RE |
| 154 | .sp |
| 155 | \fB\-\-no\-default\-features\fP |
| 156 | .RS 4 |
| 157 | Do not activate the \fBdefault\fP feature of the current directory\(cqs |
| 158 | package. |
| 159 | .RE |
| 160 | .SS "Compilation Options" |
| 161 | .sp |
| 162 | \fB\-\-target\fP \fITRIPLE\fP |
| 163 | .RS 4 |
| 164 | Build for the given architecture. The default is the host |
| 165 | architecture. The general format of the triple is |
| 166 | \fB<arch><sub>\-<vendor>\-<sys>\-<abi>\fP. Run \fBrustc \-\-print target\-list\fP for a |
| 167 | list of supported targets. |
| 168 | .sp |
| 169 | This may also be specified with the \fBbuild.target\fP |
| 170 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 171 | .RE |
| 172 | .sp |
| 173 | \fB\-\-release\fP |
| 174 | .RS 4 |
| 175 | Build optimized artifacts with the \fBrelease\fP profile. See the |
| 176 | PROFILES section for details on how this affects profile selection. |
| 177 | .RE |
| 178 | .SS "Output Options" |
| 179 | .sp |
| 180 | \fB\-\-target\-dir\fP \fIDIRECTORY\fP |
| 181 | .RS 4 |
| 182 | Directory for all generated artifacts and intermediate files. May also be |
| 183 | specified with the \fBCARGO_TARGET_DIR\fP environment variable, or the |
| 184 | \fBbuild.target\-dir\fP \c |
| 185 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 186 | Defaults |
| 187 | to \fBtarget\fP in the root of the workspace. |
| 188 | .RE |
| 189 | .SS "Display Options" |
| 190 | .sp |
| 191 | \fB\-v\fP, \fB\-\-verbose\fP |
| 192 | .RS 4 |
| 193 | Use verbose output. May be specified twice for "very verbose" output which |
| 194 | includes extra output such as dependency warnings and build script output. |
| 195 | May also be specified with the \fBterm.verbose\fP |
| 196 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 197 | .RE |
| 198 | .sp |
| 199 | \fB\-q\fP, \fB\-\-quiet\fP |
| 200 | .RS 4 |
| 201 | No output printed to stdout. |
| 202 | .RE |
| 203 | .sp |
| 204 | \fB\-\-color\fP \fIWHEN\fP |
| 205 | .RS 4 |
| 206 | Control when colored output is used. Valid values: |
| 207 | .sp |
| 208 | .RS 4 |
| 209 | .ie n \{\ |
| 210 | \h'-04'\(bu\h'+03'\c |
| 211 | .\} |
| 212 | .el \{\ |
| 213 | . sp -1 |
| 214 | . IP \(bu 2.3 |
| 215 | .\} |
| 216 | \fBauto\fP (default): Automatically detect if color support is available on the |
| 217 | terminal. |
| 218 | .RE |
| 219 | .sp |
| 220 | .RS 4 |
| 221 | .ie n \{\ |
| 222 | \h'-04'\(bu\h'+03'\c |
| 223 | .\} |
| 224 | .el \{\ |
| 225 | . sp -1 |
| 226 | . IP \(bu 2.3 |
| 227 | .\} |
| 228 | \fBalways\fP: Always display colors. |
| 229 | .RE |
| 230 | .sp |
| 231 | .RS 4 |
| 232 | .ie n \{\ |
| 233 | \h'-04'\(bu\h'+03'\c |
| 234 | .\} |
| 235 | .el \{\ |
| 236 | . sp -1 |
| 237 | . IP \(bu 2.3 |
| 238 | .\} |
| 239 | \fBnever\fP: Never display colors. |
| 240 | .RE |
| 241 | .sp |
| 242 | May also be specified with the \fBterm.color\fP |
| 243 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 244 | .RE |
| 245 | .sp |
| 246 | \fB\-\-message\-format\fP \fIFMT\fP |
| 247 | .RS 4 |
| 248 | The output format for diagnostic messages. Valid values: |
| 249 | .sp |
| 250 | .RS 4 |
| 251 | .ie n \{\ |
| 252 | \h'-04'\(bu\h'+03'\c |
| 253 | .\} |
| 254 | .el \{\ |
| 255 | . sp -1 |
| 256 | . IP \(bu 2.3 |
| 257 | .\} |
| 258 | \fBhuman\fP (default): Display in a human\-readable text format. |
| 259 | .RE |
| 260 | .sp |
| 261 | .RS 4 |
| 262 | .ie n \{\ |
| 263 | \h'-04'\(bu\h'+03'\c |
| 264 | .\} |
| 265 | .el \{\ |
| 266 | . sp -1 |
| 267 | . IP \(bu 2.3 |
| 268 | .\} |
| 269 | \fBjson\fP: Emit JSON messages to stdout. |
| 270 | .RE |
| 271 | .sp |
| 272 | .RS 4 |
| 273 | .ie n \{\ |
| 274 | \h'-04'\(bu\h'+03'\c |
| 275 | .\} |
| 276 | .el \{\ |
| 277 | . sp -1 |
| 278 | . IP \(bu 2.3 |
| 279 | .\} |
| 280 | \fBshort\fP: Emit shorter, human\-readable text messages. |
| 281 | .RE |
| 282 | .RE |
| 283 | .SS "Manifest Options" |
| 284 | .sp |
| 285 | \fB\-\-manifest\-path\fP \fIPATH\fP |
| 286 | .RS 4 |
| 287 | Path to the \fBCargo.toml\fP file. By default, Cargo searches in the current |
| 288 | directory or any parent directory for the \fBCargo.toml\fP file. |
| 289 | .RE |
| 290 | .sp |
| 291 | \fB\-\-frozen\fP, \fB\-\-locked\fP |
| 292 | .RS 4 |
| 293 | Either of these flags requires that the \fBCargo.lock\fP file is |
| 294 | up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will |
| 295 | exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from |
| 296 | attempting to access the network to determine if it is out\-of\-date. |
| 297 | .sp |
| 298 | These may be used in environments where you want to assert that the |
| 299 | \fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network |
| 300 | access. |
| 301 | .RE |
| 302 | .sp |
| 303 | \fB\-\-offline\fP |
| 304 | .RS 4 |
| 305 | Prevents Cargo from accessing the network for any reason. Without this |
| 306 | flag, Cargo will stop with an error if it needs to access the network and |
| 307 | the network is not available. With this flag, Cargo will attempt to |
| 308 | proceed without the network if possible. |
| 309 | .sp |
| 310 | Beware that this may result in different dependency resolution than online |
| 311 | mode. Cargo will restrict itself to crates that are downloaded locally, even |
| 312 | if there might be a newer version as indicated in the local copy of the index. |
| 313 | See the \fBcargo\-fetch\fP(1) command to download dependencies before going |
| 314 | offline. |
| 315 | .sp |
| 316 | May also be specified with the \fBnet.offline\fP \c |
| 317 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 318 | .RE |
| 319 | .SS "Common Options" |
| 320 | .sp |
| 321 | \fB\-h\fP, \fB\-\-help\fP |
| 322 | .RS 4 |
| 323 | Prints help information. |
| 324 | .RE |
| 325 | .sp |
| 326 | \fB\-Z\fP \fIFLAG\fP... |
| 327 | .RS 4 |
| 328 | Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for |
| 329 | details. |
| 330 | .RE |
| 331 | .SS "Miscellaneous Options" |
| 332 | .sp |
| 333 | \fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP |
| 334 | .RS 4 |
| 335 | Number of parallel jobs to run. May also be specified with the |
| 336 | \fBbuild.jobs\fP \c |
| 337 | .URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "." |
| 338 | Defaults to |
| 339 | the number of CPUs. |
| 340 | .RE |
| 341 | .SH "PROFILES" |
| 342 | .sp |
| 343 | Profiles may be used to configure compiler options such as optimization levels |
| 344 | and debug settings. See |
| 345 | \c |
| 346 | .URL "https://doc.rust\-lang.org/cargo/reference/manifest.html#the\-profile\-sections" "the reference" |
| 347 | for more details. |
| 348 | .sp |
| 349 | Profile selection depends on the target and crate being built. By default the |
| 350 | \fBdev\fP or \fBtest\fP profiles are used. If the \fB\-\-release\fP flag is given, then the |
| 351 | \fBrelease\fP or \fBbench\fP profiles are used. |
| 352 | .TS |
| 353 | allbox tab(:); |
| 354 | lt lt lt. |
| 355 | T{ |
| 356 | .sp |
| 357 | Target |
| 358 | T}:T{ |
| 359 | .sp |
| 360 | Default Profile |
| 361 | T}:T{ |
| 362 | .sp |
| 363 | \fB\-\-release\fP Profile |
| 364 | T} |
| 365 | T{ |
| 366 | .sp |
| 367 | lib, bin, example |
| 368 | T}:T{ |
| 369 | .sp |
| 370 | \fBdev\fP |
| 371 | T}:T{ |
| 372 | .sp |
| 373 | \fBrelease\fP |
| 374 | T} |
| 375 | T{ |
| 376 | .sp |
| 377 | test, bench, or any target |
| 378 | .br |
| 379 | in "test" or "bench" mode |
| 380 | T}:T{ |
| 381 | .sp |
| 382 | \fBtest\fP |
| 383 | T}:T{ |
| 384 | .sp |
| 385 | \fBbench\fP |
| 386 | T} |
| 387 | .TE |
| 388 | .sp |
| 389 | .sp |
| 390 | Dependencies use the \fBdev\fP/\fBrelease\fP profiles. |
| 391 | .SH "ENVIRONMENT" |
| 392 | .sp |
| 393 | See \c |
| 394 | .URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " " |
| 395 | for |
| 396 | details on environment variables that Cargo reads. |
| 397 | .SH "EXIT STATUS" |
| 398 | .sp |
| 399 | 0 |
| 400 | .RS 4 |
| 401 | Cargo succeeded. |
| 402 | .RE |
| 403 | .sp |
| 404 | 101 |
| 405 | .RS 4 |
| 406 | Cargo failed to complete. |
| 407 | .RE |
| 408 | .SH "EXAMPLES" |
| 409 | .sp |
| 410 | .RS 4 |
| 411 | .ie n \{\ |
| 412 | \h'-04' 1.\h'+01'\c |
| 413 | .\} |
| 414 | .el \{\ |
| 415 | . sp -1 |
| 416 | . IP " 1." 4.2 |
| 417 | .\} |
| 418 | Check if your package (not including dependencies) uses unsafe code: |
| 419 | .sp |
| 420 | .if n .RS 4 |
| 421 | .nf |
| 422 | cargo rustc \-\-lib \-\- \-D unsafe\-code |
| 423 | .fi |
| 424 | .if n .RE |
| 425 | .RE |
| 426 | .sp |
| 427 | .RS 4 |
| 428 | .ie n \{\ |
| 429 | \h'-04' 2.\h'+01'\c |
| 430 | .\} |
| 431 | .el \{\ |
| 432 | . sp -1 |
| 433 | . IP " 2." 4.2 |
| 434 | .\} |
| 435 | Try an experimental flag on the nightly compiler, such as this which prints |
| 436 | the size of every type: |
| 437 | .sp |
| 438 | .if n .RS 4 |
| 439 | .nf |
| 440 | cargo rustc \-\-lib \-\- \-Z print\-type\-sizes |
| 441 | .fi |
| 442 | .if n .RE |
| 443 | .RE |
| 444 | .SH "SEE ALSO" |
| 445 | .sp |
| 446 | \fBcargo\fP(1), \fBcargo\-build\fP(1), \fBrustc\fP(1) |