All of these options are passed to rustc
via the -C
flag, short for “codegen.” You can see a version of this list for your exact compiler by running rustc -C help
.
This option is deprecated and does nothing.
This flag lets you control which linker rustc
invokes to link your code.
This flag lets you append a single extra argument to the linker invocation.
“Append” is significant; you can pass this flag multiple times to add multiple arguments.
This flag lets you append multiple extra arguments to the linker invocation. The options should be separated by spaces.
This flag lets you control the linker flavor used by rustc
. If a linker is given with the -C linker
flag described above then the linker flavor is inferred from the value provided. If no linker is given then the linker flavor is used to determine the linker to use. Every rustc
target defaults to some linker flavor.
Normally, the linker will remove dead code. This flag disables this behavior.
An example of when this flag might be useful is when trying to construct code coverage metrics.
This flag instructs LLVM to use link time optimizations.
It takes one of two values, thin
and fat
. ‘thin’ LTO is a new feature of LLVM, ‘fat’ referring to the classic version of LTO.
This instructs rustc
to generate code specifically for a particular processor.
You can run rustc --print target-cpus
to see the valid options to pass here. Additionally, native
can be passed to use the processor of the host machine.
Individual targets will support different features; this flag lets you control enabling or disabling a feature.
To see the valid options and an example of use, run rustc --print target-features
.
This flag can be used to add extra LLVM passes to the compilation.
The list must be separated by spaces.
This flag can be used to pass a list of arguments directly to LLVM.
The list must be separated by spaces.
rustc
will generate temporary files during compilation; normally it will delete them after it's done with its work. This option will cause them to be preserved instead of removed.
This option allows you to set the value of rpath
.
This flag allows you to control the behavior of integer overflow. This flag can be passed many options:
y
, yes
, or on
.n
, no
, or off
.The pass manager comes pre-populated with a list of passes; this flag ensures that list is empty.
By default, rustc
will attempt to vectorize loops. This flag will turn that behavior off.
By default, rustc
will attempt to vectorize loops using superword-level parallelism. This flag will turn that behavior off.
This option will make rustc
generate code using “soft floats.” By default, a lot of hardware supports floating point instructions, and so the code generated will take advantage of this. “soft floats” emulate floating point instructions in software.
By default, rustc
prefers to statically link dependencies. This option will make it use dynamic linking instead.
LLVM comes with an internal assembler; this option will let you use an external assembler instead.
This flag allows you to disable the red zone. This flag can be passed many options:
y
, yes
, or on
.n
, no
, or off
.This option lets you choose which relocation model to use.
To find the valid options for this flag, run rustc --print relocation-models
.
This option lets you choose which code model to use.
To find the valid options for this flag, run rustc --print code-models
.
This option allows you to control the metadata used for symbol mangling.
This option allows you to put extra data in each output filename.
This flag lets you control how many threads are used when doing code generation.
Increasing parallelism may speed up compile times, but may also produce slower code.
This flag lets you print remarks for these optimization passes.
The list of passes should be separated by spaces.
all
will remark on every pass.
This option is deprecated and does nothing.
This flag lets you control debug information:
0
: no debug info at all1
: line tables only2
: full debug infoThis flag lets you control the optimization level.
0
: no optimizations, also turn on cfg(debug_assertions)
.1
: basic optimizations2
: some optimizations3
: all optimizationss
: optimize for binary sizez
: optimize for binary size, but also turn off loop vectorization.This flag lets you turn cfg(debug_assertions)
on or off.
This option lets you set the threshold for inlining a function.
The default is 225.
This option lets you control what happens when the code panics.
abort
: terminate the process upon panicunwind
: unwind the stack upon panicThis flag allows you to enable incremental compilation.