]> git.lizzy.rs Git - rust.git/blob - src/doc/rustc/src/command-line-arguments.md
Move `box` from the stable keyword to unstable keywords list
[rust.git] / src / doc / rustc / src / command-line-arguments.md
1 # Command-line arguments
2
3 Here's a list of command-line arguments to `rustc` and what they do.
4
5 ## `-h`/`--help`: get help
6
7 This flag will print out help information for `rustc`.
8
9 ## `--cfg`: configure the compilation environment
10
11 This flag can turn on or off various `#[cfg]` settings.
12
13 The value can either be a single identifier or two identifiers separated by `=`.
14
15 For examples, `--cfg 'verbose'` or `--cfg 'feature="serde"'`. These correspond
16 to `#[cfg(verbose)]` and `#[cfg(feature = "serde")]` respectively.
17
18 ## `-L`: add a directory to the library search path
19
20 When looking for external crates, a directory passed to this flag will be searched.
21
22 ## `-l`: link the generated crate to a native library
23
24 This flag allows you to specify linking to a specific native library when building
25 a crate.
26
27 ## `--crate-type`: a list of types of crates for the compiler to emit
28
29 This instructs `rustc` on which crate type to build.
30
31 ## `--crate-name`: specify the name of the crate being built
32
33 This informs `rustc` of the name of your crate.
34
35 ## `--emit`: emit output other than a crate
36
37 Instead of producing a crate, this flag can print out things like the assembly or LLVM-IR.
38
39 ## `--print`: print compiler information
40
41 This flag prints out various information about the compiler.
42
43 ## `-g`: include debug information
44
45 A synonym for `-C debuginfo=2`, for more see [here](codegen-options/index.html#debuginfo).
46
47 ## `-O`: optimize your code
48
49 A synonym for `-C opt-level=2`, for more see [here](codegen-options/index.html#opt-level).
50
51 ## `-o`: filename of the output
52
53 This flag controls the output filename.
54
55 ## `--out-dir`: directory to write the output in
56
57 The outputted crate will be written to this directory.
58
59 ## `--explain`: provide a detailed explanation of an error message
60
61 Each error of `rustc`'s comes with an error code; this will print
62 out a longer explanation of a given error.
63
64 ## `--test`: build a test harness
65
66 When compiling this crate, `rustc` will ignore your `main` function
67 and instead produce a test harness.
68
69 ## `--target`: select a target triple to build
70
71 This controls which [target](targets/index.html) to produce.
72
73 ## `-W`: set lint warnings
74
75 This flag will set which lints should be set to the [warn level](lints/levels.html#warn).
76
77 ## `-A`: set lint allowed
78
79 This flag will set which lints should be set to the [allow level](lints/levels.html#allow).
80
81 ## `-D`: set lint denied
82
83 This flag will set which lints should be set to the [deny level](lints/levels.html#deny).
84
85 ## `-F`: set lint forbidden
86
87 This flag will set which lints should be set to the [forbid level](lints/levels.html#forbid).
88
89 ## `-Z`: set unstable options
90
91 This flag will allow you to set unstable options of rustc. In order to set multiple options,
92 the -Z flag can be used multiple times. For example: `rustc -Z verbose -Z time`.
93 Specifying options with -Z is only available on nightly. To view all available options
94 run: `rustc -Z help`.
95
96 ## `--cap-lints`: set the most restrictive lint level
97
98 This flag lets you 'cap' lints, for more, [see here](lints/levels.html#capping-lints).
99
100 ## `-C`/`--codegen`: code generation options
101
102 This flag will allow you to set [codegen options](codegen-options/index.html).
103
104 ## `-V`/`--version`: print a version
105
106 This flag will print out `rustc`'s version.
107
108 ## `-v`/`--verbose`: use verbose output
109
110 This flag, when combined with other flags, makes them produce extra output.
111
112 ## `--extern`: specify where an external library is located
113
114 This flag allows you to pass the name and location of an external crate that will
115 be linked into the crate you're buildling.
116
117 ## `--sysroot`: Override the system root
118
119 The "sysroot" is where `rustc` looks for the crates that come with the Rust
120 distribution; this flag allows that to be overridden.
121
122 ## `--error-format`: control how errors are produced
123
124 This flag lets you control the format of errors.
125
126 ## `--color`: configure coloring of output
127
128 This flag lets you control color settings of the output.