RUSTC(1)

NAME
rustc - The Rust compiler

SYNOPSIS
rustc [OPTIONS] INPUT

DESCRIPTION
This program is a compiler for the Rust language, available at <https://www.rust-lang.org>.

OPTIONS

--crate-type=[bin|lib|dylib|rlib|staticlib]
    Configure the flavor of rust crate that is generated (default `bin`)

--cfg SPEC
    Configure the compilation environment

--emit=[asm,ir,bc,obj,link]
    Configure the output that rustc will produce

-h, --help
    Display this message

-L PATH
    Add a directory to the library search path

--no-trans
    Run all passes except translation; no output

--no-analysis
    Parse and expand the source, but run no analysis and produce no output

-g  Emit DWARF debug information into object files generated.

--debuginfo LEVEL
    Emit DWARF debug info to the objects created: 0 = no debug info, 1 = line-tables only (for stacktraces and breakpoints), 2 = full debug info with variable and type information (same as -g).

-O  Equivalent to --opt-level=2

-o FILENAME
    Write output to <filename>. Ignored if more than one --emit is specified.

--opt-level LEVEL
    Optimize with possible levels 0-3

--out-dir DIR
    Write output to compiler-chosen filename in <dir>. Ignored if -o is specified. (default the current directory)

--parse-only
    Parse only; do not compile, assemble, or link

--pretty [TYPE]
    Pretty-print the input instead of compiling; valid types are: normal (un-annotated source), expanded (crates expanded), typed (crates expanded, with type annotations), or identified (fully parenthesized, AST nodes and blocks with IDs)

--dep-info [FILENAME]
    Output dependency info to <filename> after compiling, in o format suitable for use by Makefiles.

--sysroot PATH
    Override the system root

--test
    Build a test harness

--target TRIPLE
    Target triple cpu-manufacturer-kernel[-os] to compile for (see http://sources.redhat.com/autobook/autobook/autobook_17.html for details)

-W help
    Print 'lint' options and default settings

-W OPT, --warn OPT
    Set lint warnings

-A OPT, --allow OPT
    Set lint allowed

-D OPT, --deny OPT
    Set lint denied

-F OPT, --forbid OPT
    Set lint forbidden

-Z FLAG
    Set internal debugging options. Use "-Z help" to print available options.

-C FLAG[=VAL], --codegen FLAG[=VAL]
    Set a codegen-related flag to the value specifie.d Use "-C help" to print available flags. See CODEGEN OPTIONS below

-v, --version
    Print version info and exit

CODEGEN OPTIONS

ar=/path/to/ar
    Path to the archive utility to use when assembling archives.

linker=/path/to/cc
    Path to the linker utility to use when linking libraries, executables, and objects.

link-args='-flag1 -flag2'
    A space-separated list of extra arguments to pass to the linker when the linker is invoked.

target-cpu=help
    Selects a target processor. If the value is 'help', then a list of available cpus is printed.

target-feature='+feature1 -feature2'
    A space-separated list of features to enable or disable for the target. A preceding '+' enables a feature while a preceding '-' disables it. Available features can be discovered through target-cpu=help.

passes=list
    A space-separated list of extra LLVM passes to run. A value of 'list' will cause rustc to print all known passes and exit. The passes specified are appended at the end of the normal pass manager.

llvm-args='-arg1 -arg2'
    A space-separted list of argument to pass through to LLVM.

save-temps
    If specified, the compiler will save more files (.bc, .o, .no-opt.bc) generated throughout compilation in the output directory.

android-cross-path=path/to/ndk/bin
    Directory to find the Android NDK cross-compilation tools

no-rpath
    If specified, then the rpath value for dynamic libraries will not be set in either dynamic library or executable outputs.

no-prepopulate-passes
    Suppresses pre-population of the LLVM pass manager that is run over the module.

no-vectorize-loops
    Suppresses running the loop vectorization LLVM pass, regardless of optimization level.

no-vectorize-slp
    Suppresses running the LLVM SLP vectorization pass, regardless of optimization level.

soft-float
    Generates software floating point library calls instead of hardware instructions.

prefer-dynamic
    Prefers dynamic linking to static linking.

no-integrated-as
    Force usage of an external assembler rather than LLVM's integrated one.

relocation-model=[pic,static,dynamic-no-pic]
    The relocation model to use. (default: pic)

EXAMPLES
To build an executable from a source file with a main function:
    $ rustc -o hello hello.rs To build a library from a source file:
    $ rustc --crate-type=lib hello-lib.rs To build either with a crate (.rs) file:
    $ rustc hello.rs To build an executable with debug info:
    $ rustc -g -o hello hello.rs

SEE ALSO
rustdoc

BUGS
See <https://github.com/mozilla/rust/issues> for issues.

AUTHOR
See AUTHORS.txt in the Rust source distribution.

COPYRIGHT
This work is dual-licensed under Apache 2.0 and MIT terms. See COPYRIGHT file in the rust source distribution.