345 lines
12 KiB
HTML
345 lines
12 KiB
HTML
|
||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
<HTML><HEAD><TITLE>Man page of RUSTC</TITLE>
|
||
</HEAD><BODY>
|
||
<H1>RUSTC</H1>
|
||
Section: User Commands (1)<BR>Updated: December 2020<BR><A HREF="#index">Index</A>
|
||
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
||
|
||
<A NAME="lbAB"> </A>
|
||
<H2>NAME</H2>
|
||
|
||
rustc - The Rust compiler
|
||
<A NAME="lbAC"> </A>
|
||
<H2>SYNOPSIS</H2>
|
||
|
||
<B>rustc</B>
|
||
|
||
[<I>OPTIONS</I>] <I>INPUT</I>
|
||
<P>
|
||
<A NAME="lbAD"> </A>
|
||
<H2>DESCRIPTION</H2>
|
||
|
||
This program is a compiler for the Rust language, available at <A HREF="https://www.rust-lang.org.">https://www.rust-lang.org.</A>
|
||
<P>
|
||
<A NAME="lbAE"> </A>
|
||
<H2>OPTIONS</H2>
|
||
|
||
<P>
|
||
<DL COMPACT>
|
||
<DT id="1"><B>-h</B>, <B>--help</B><DD>
|
||
Display the help message.
|
||
<DT id="2"><B>--cfg</B> <I>SPEC</I><DD>
|
||
Configure the compilation environment.
|
||
<DT id="3"><B>-L</B> [<I>KIND</I>=]<I>PATH</I><DD>
|
||
Add a directory to the library search path.
|
||
The optional <I>KIND</I> can be one of:
|
||
<DL COMPACT><DT id="4"><DD>
|
||
<DL COMPACT>
|
||
<DT id="5"><B>dependency</B><DD>
|
||
only lookup transitive dependencies here
|
||
<DT id="6"><B>crate</B>
|
||
|
||
<DD>
|
||
only lookup local `extern crate` directives here
|
||
<DT id="7"><B>native</B>
|
||
|
||
<DD>
|
||
only lookup native libraries here
|
||
<DT id="8"><B>framework</B>
|
||
|
||
<DD>
|
||
only look for OSX frameworks here
|
||
<DT id="9"><B>all</B>
|
||
|
||
<DD>
|
||
look for anything here (the default)
|
||
</DL>
|
||
</DL>
|
||
|
||
<DT id="10"><B>-l</B> [<I>KIND</I>=]<I>NAME</I><DD>
|
||
Link the generated crate(s) to the specified library <I>NAME</I>.
|
||
The optional <I>KIND</I> can be one of <I>static</I>, <I>dylib</I>, or
|
||
<I>framework</I>.
|
||
If omitted, <I>dylib</I> is assumed.
|
||
<DT id="11"><B>--crate-type</B> [bin|lib|rlib|dylib|cdylib|staticlib]<DD>
|
||
Comma separated list of types of crates for the compiler to emit.
|
||
<DT id="12"><B>--crate-name</B> <I>NAME</I><DD>
|
||
Specify the name of the crate being built.
|
||
<DT id="13"><B>--emit</B> [asm|llvm-bc|llvm-ir|obj|link|dep-info|mir][=<I>PATH</I>]<DD>
|
||
Configure the output that <B>rustc</B> will produce. Each emission may also have
|
||
an optional explicit output <I>PATH</I> specified for that particular emission
|
||
kind. This path takes precedence over the <B>-o</B> option.
|
||
<DT id="14"><B>--print</B> [crate-name|:file-names|:sysroot|:cfg|:target-list|:target-cpus|:target-features|:relocation-models|:code-models|:tls-models|:target-spec-json|:native-static-libs]<DD>
|
||
Comma separated list of compiler information to print on stdout.
|
||
<DT id="15"><B>-g</B><DD>
|
||
Equivalent to <I>-C debuginfo=2</I>.
|
||
<DT id="16"><B>-O</B><DD>
|
||
Equivalent to <I>-C opt-level=2</I>.
|
||
<DT id="17"><B>-o</B> <I>FILENAME</I><DD>
|
||
Write output to <I>FILENAME</I>. Ignored if multiple <I>--emit</I> outputs are specified which
|
||
don't have an explicit path otherwise.
|
||
<DT id="18"><B>--out-dir</B> <I>DIR</I><DD>
|
||
Write output to compiler-chosen filename in <I>DIR</I>. Ignored if <I>-o</I> is specified.
|
||
Defaults to the current directory.
|
||
<DT id="19"><B>--explain</B> <I>OPT</I><DD>
|
||
Provide a detailed explanation of an error message.
|
||
<DT id="20"><B>--test</B><DD>
|
||
Build a test harness.
|
||
<DT id="21"><B>--target</B> <I>TARGET</I><DD>
|
||
Target triple for which the code is compiled. This option defaults to the host’s target
|
||
triple. The target triple has the general format <arch><sub>-<vendor>-<sys>-<abi>, where:
|
||
<DL COMPACT><DT id="22"><DD>
|
||
<DL COMPACT>
|
||
<DT id="23"><B><arch></B>
|
||
|
||
<DD>
|
||
x86, arm, thumb, mips, etc.
|
||
<DT id="24"><B><sub></B>
|
||
|
||
<DD>
|
||
for example on ARM: v5, v6m, v7a, v7m, etc.
|
||
<DT id="25"><B><vendor></B>
|
||
|
||
<DD>
|
||
pc, apple, nvidia, ibm, etc.
|
||
<DT id="26"><B><sys></B>
|
||
|
||
<DD>
|
||
none, linux, win32, darwin, cuda, etc.
|
||
<DT id="27"><B><abi></B>
|
||
|
||
<DD>
|
||
eabi, gnu, android, macho, elf, etc.
|
||
</DL>
|
||
</DL>
|
||
|
||
<DT id="28"><B>-W help</B><DD>
|
||
Print 'lint' options and default settings.
|
||
<DT id="29"><B>-W</B> <I>OPT</I>, <B>--warn</B> <I>OPT</I><DD>
|
||
Set lint warnings.
|
||
<DT id="30"><B>-A</B> <I>OPT</I>, <B>--allow</B> <I>OPT</I><DD>
|
||
Set lint allowed.
|
||
<DT id="31"><B>-D</B> <I>OPT</I>, <B>--deny</B> <I>OPT</I><DD>
|
||
Set lint denied.
|
||
<DT id="32"><B>-F</B> <I>OPT</I>, <B>--forbid</B> <I>OPT</I><DD>
|
||
Set lint forbidden.
|
||
<DT id="33"><B>-C</B> <I>FLAG</I>[=<I>VAL</I>], <B>--codegen</B> <I>FLAG</I>[=<I>VAL</I>]<DD>
|
||
Set a codegen-related flag to the value specified.
|
||
Use <I>-C help</I> to print available flags.
|
||
See CODEGEN OPTIONS below.
|
||
<DT id="34"><B>-V</B>, <B>--version</B><DD>
|
||
Print version info and exit.
|
||
<DT id="35"><B>-v</B>, <B>--verbose</B><DD>
|
||
Use verbose output.
|
||
<DT id="36"><B>--remap-path-prefix</B> <I>from</I>=<I>to</I><DD>
|
||
Remap source path prefixes in all output, including compiler diagnostics, debug information,
|
||
macro expansions, etc. The <I>from</I>=<I>to</I> parameter is scanned from right to left, so <I>from</I>
|
||
may contain '=', but <I>to</I> may not.
|
||
<P>
|
||
This is useful for normalizing build products, for example by removing the current directory out of
|
||
pathnames emitted into the object files. The replacement is purely textual, with no consideration of
|
||
the current system's pathname syntax. For example <I>--remap-path-prefix foo=bar</I> will
|
||
match <B>foo/lib.rs</B> but not <B>./foo/lib.rs</B>.
|
||
<DT id="37"><B>--extern</B> <I>NAME</I>=<I>PATH</I><DD>
|
||
Specify where an external rust library is located. These should match
|
||
<I>extern</I> declarations in the crate's source code.
|
||
<DT id="38"><B>--sysroot</B> <I>PATH</I><DD>
|
||
Override the system root.
|
||
<DT id="39"><B>-Z</B> <I>FLAG</I><DD>
|
||
Set internal debugging options.
|
||
Use <I>-Z help</I> to print available options.
|
||
<DT id="40"><B>--color</B> auto|always|never<DD>
|
||
Configure coloring of output:
|
||
<DL COMPACT><DT id="41"><DD>
|
||
<DL COMPACT>
|
||
<DT id="42"><B>auto</B>
|
||
|
||
<DD>
|
||
colorize, if output goes to a tty (default);
|
||
<DT id="43"><B>always</B>
|
||
|
||
<DD>
|
||
always colorize output;
|
||
<DT id="44"><B>never</B>
|
||
|
||
<DD>
|
||
never colorize output.
|
||
</DL>
|
||
</DL>
|
||
|
||
<P>
|
||
</DL>
|
||
<A NAME="lbAF"> </A>
|
||
<H2>CODEGEN OPTIONS</H2>
|
||
|
||
<P>
|
||
<DL COMPACT>
|
||
<DT id="45"><B>linker</B>=<I>/path/to/cc</I><DD>
|
||
Path to the linker utility to use when linking libraries, executables, and
|
||
objects.
|
||
<DT id="46"><B>link-args</B>='<I>-flag1 -flag2</I>'<DD>
|
||
A space-separated list of extra arguments to pass to the linker when the linker
|
||
is invoked.
|
||
<DT id="47"><B>lto</B><DD>
|
||
Perform LLVM link-time optimizations.
|
||
<DT id="48"><B>target-cpu</B>=<I>help</I><DD>
|
||
Selects a target processor.
|
||
If the value is 'help', then a list of available CPUs is printed.
|
||
<DT id="49"><B>target-feature</B>='<I>+feature1</I>,<I>-feature2</I>'<DD>
|
||
A comma-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 <I>llc -mcpu=help</I>.
|
||
<DT id="50"><B>passes</B>=<I>val</I><DD>
|
||
A space-separated list of extra LLVM passes to run.
|
||
A value of 'list' will cause <B>rustc</B> to print all known passes and
|
||
exit.
|
||
The passes specified are appended at the end of the normal pass manager.
|
||
<DT id="51"><B>llvm-args</B>='<I>-arg1</I> <I>-arg2</I>'<DD>
|
||
A space-separated list of arguments to pass through to LLVM.
|
||
<DT id="52"><B>save-temps</B><DD>
|
||
If specified, the compiler will save more files (.bc, .o, .no-opt.bc) generated
|
||
throughout compilation in the output directory.
|
||
<DT id="53"><B>rpath</B><DD>
|
||
If specified, then the rpath value for dynamic libraries will be set in
|
||
either dynamic library or executable outputs.
|
||
<DT id="54"><B>no-prepopulate-passes</B><DD>
|
||
Suppresses pre-population of the LLVM pass manager that is run over the module.
|
||
<DT id="55"><B>no-vectorize-loops</B><DD>
|
||
Suppresses running the loop vectorization LLVM pass, regardless of optimization
|
||
level.
|
||
<DT id="56"><B>no-vectorize-slp</B><DD>
|
||
Suppresses running the LLVM SLP vectorization pass, regardless of optimization
|
||
level.
|
||
<DT id="57"><B>soft-float</B><DD>
|
||
Generates software floating point library calls instead of hardware
|
||
instructions.
|
||
<DT id="58"><B>prefer-dynamic</B><DD>
|
||
Prefers dynamic linking to static linking.
|
||
<DT id="59"><B>no-integrated-as</B><DD>
|
||
Force usage of an external assembler rather than LLVM's integrated one.
|
||
<DT id="60"><B>no-redzone</B><DD>
|
||
Disable the use of the redzone.
|
||
<DT id="61"><B>relocation-model</B>=[pic,static,dynamic-no-pic]<DD>
|
||
The relocation model to use.
|
||
(Default: <I>pic</I>)
|
||
<DT id="62"><B>code-model</B>=[small,kernel,medium,large]<DD>
|
||
Choose the code model to use.
|
||
<DT id="63"><B>metadata</B>=<I>val</I><DD>
|
||
Metadata to mangle symbol names with.
|
||
<DT id="64"><B>extra-filename</B>=<I>val</I><DD>
|
||
Extra data to put in each output filename.
|
||
<DT id="65"><B>codegen-units</B>=<I>n</I><DD>
|
||
Divide crate into <I>n</I> units to optimize in parallel.
|
||
<DT id="66"><B>remark</B>=<I>val</I><DD>
|
||
Print remarks for these optimization passes (space separated, or "all").
|
||
<DT id="67"><B>no-stack-check</B><DD>
|
||
Disable checks for stack exhaustion (a memory-safety hazard!).
|
||
<DT id="68"><B>debuginfo</B>=<I>val</I><DD>
|
||
Debug info emission level:
|
||
<DL COMPACT><DT id="69"><DD>
|
||
<DL COMPACT>
|
||
<DT id="70"><B>0</B>
|
||
|
||
<DD>
|
||
no debug info;
|
||
<DT id="71"><B>1</B>
|
||
|
||
<DD>
|
||
line-tables only (for stacktraces and breakpoints);
|
||
<DT id="72"><B>2</B>
|
||
|
||
<DD>
|
||
full debug info with variable and type information.
|
||
</DL>
|
||
</DL>
|
||
|
||
<DT id="73"><B>opt-level</B>=<I>VAL</I><DD>
|
||
Optimize with possible levels 0-3, s (optimize for size), or z (for minimal size)
|
||
<P>
|
||
</DL>
|
||
<A NAME="lbAG"> </A>
|
||
<H2>ENVIRONMENT</H2>
|
||
|
||
<P>
|
||
Some of these affect only test harness programs (generated via rustc --test);
|
||
others affect all programs which link to the Rust standard library.
|
||
<P>
|
||
<DL COMPACT>
|
||
<DT id="74"><B>RUST_TEST_THREADS</B><DD>
|
||
The test framework Rust provides executes tests in parallel. This variable sets
|
||
the maximum number of threads used for this purpose. This setting is overridden
|
||
by the --test-threads option.
|
||
<P>
|
||
<DT id="75"><B>RUST_TEST_NOCAPTURE</B><DD>
|
||
If set to a value other than "0", a synonym for the --nocapture flag.
|
||
<P>
|
||
<DT id="76"><B>RUST_MIN_STACK</B><DD>
|
||
Sets the minimum stack size for new threads.
|
||
<P>
|
||
<DT id="77"><B>RUST_BACKTRACE</B><DD>
|
||
If set to a value different than "0", produces a backtrace in the output of a program which panics.
|
||
<P>
|
||
</DL>
|
||
<A NAME="lbAH"> </A>
|
||
<H2>EXAMPLES</H2>
|
||
|
||
To build an executable from a source file with a main function:
|
||
<BR> $ rustc -o hello hello.rs
|
||
<P>
|
||
To build a library from a source file:
|
||
<BR> $ rustc --crate-type=lib hello-lib.rs
|
||
<P>
|
||
To build either with a crate (.rs) file:
|
||
<BR> $ rustc hello.rs
|
||
<P>
|
||
To build an executable with debug info:
|
||
<BR> $ rustc -g -o hello hello.rs
|
||
<P>
|
||
<A NAME="lbAI"> </A>
|
||
<H2>SEE ALSO</H2>
|
||
|
||
<P>
|
||
<B><A HREF="/cgi-bin/man/man2html?1+rustdoc">rustdoc</A></B>(1)
|
||
|
||
<P>
|
||
<A NAME="lbAJ"> </A>
|
||
<H2>BUGS</H2>
|
||
|
||
See <A HREF="https://github.com/rust-lang/rust/issues">https://github.com/rust-lang/rust/issues</A> for issues.
|
||
<P>
|
||
<A NAME="lbAK"> </A>
|
||
<H2>AUTHOR</H2>
|
||
|
||
See <A HREF="https://github.com/rust-lang/rust/graphs/contributors">https://github.com/rust-lang/rust/graphs/contributors</A> or use `git log --all --format='%cN <%cE>' | sort -u` in the rust source distribution.
|
||
<P>
|
||
<A NAME="lbAL"> </A>
|
||
<H2>COPYRIGHT</H2>
|
||
|
||
This work is dual-licensed under Apache 2.0 and MIT terms.
|
||
See <I>COPYRIGHT</I> file in the rust source distribution.
|
||
<P>
|
||
|
||
<HR>
|
||
<A NAME="index"> </A><H2>Index</H2>
|
||
<DL>
|
||
<DT id="78"><A HREF="#lbAB">NAME</A><DD>
|
||
<DT id="79"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
||
<DT id="80"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
||
<DT id="81"><A HREF="#lbAE">OPTIONS</A><DD>
|
||
<DT id="82"><A HREF="#lbAF">CODEGEN OPTIONS</A><DD>
|
||
<DT id="83"><A HREF="#lbAG">ENVIRONMENT</A><DD>
|
||
<DT id="84"><A HREF="#lbAH">EXAMPLES</A><DD>
|
||
<DT id="85"><A HREF="#lbAI">SEE ALSO</A><DD>
|
||
<DT id="86"><A HREF="#lbAJ">BUGS</A><DD>
|
||
<DT id="87"><A HREF="#lbAK">AUTHOR</A><DD>
|
||
<DT id="88"><A HREF="#lbAL">COPYRIGHT</A><DD>
|
||
</DL>
|
||
<HR>
|
||
This document was created by
|
||
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
||
using the manual pages.<BR>
|
||
Time: 00:05:26 GMT, March 31, 2021
|
||
</BODY>
|
||
</HTML>
|