Skip to content

Commit a5456bd

Browse files
add -C to the rustdoc book
1 parent 1a0d7a8 commit a5456bd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/doc/rustdoc/src/command-line-arguments.md

+25
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,31 @@ Similar to `--library-path`, `--extern` is about specifying the location
141141
of a dependency. `--library-path` provides directories to search in, `--extern`
142142
instead lets you specify exactly which dependency is located where.
143143

144+
## `-C`/`--codegen`: pass codegen options to rustc
145+
146+
Using this flag looks like this:
147+
148+
```bash
149+
$ rustdoc src/lib.rs -C target_feature=+avx
150+
$ rustdoc src/lib.rs --codegen target_feature=+avx
151+
152+
$ rustdoc --test src/lib.rs -C target_feature=+avx
153+
$ rustdoc --test src/lib.rs --codegen target_feature=+avx
154+
155+
$ rustdoc --test README.md -C target_feature=+avx
156+
$ rustdoc --test README.md --codegen target_feature=+avx
157+
```
158+
159+
When rustdoc generates documentation, looks for documentation tests, or executes documentation
160+
tests, it needs to compile some rust code, at least part-way. This flag allows you to tell rustdoc
161+
to provide some extra codegen options to rustc when it runs these compilations. Most of the time,
162+
these options won't affect a regular documentation run, but if something depends on target features
163+
to be enabled, or documentation tests need to use some additional options, this flag allows you to
164+
affect that.
165+
166+
The arguments to this flag are the same as those for the `-C` flag on rustc. Run `rustc -C help` to
167+
get the full list.
168+
144169
## `--passes`: add more rustdoc passes
145170

146171
Using this flag looks like this:

0 commit comments

Comments
 (0)