ホンムノート

rustc

Rust 编译器。 Rust 项目通常使用 `cargo` 而不是直接调用 `rustc`

100% ブラウザのローカル処理 0 データアップロード

一般的な例

编译二进制包(crate)

rustc {{路径/到/主文件.rs}}

编译时启用优化(`s` 表示针对二进制大小优化;`z` 含义相同但使用更多优化)

rustc {{[-C|--codegen]}} lto {{[-C|--codegen]}} opt-level={{0|1|2|3|s|z}} {{路径/到/主文件.rs}}

编译时包含调试信息

rustc {{[-g|--codegen debuginfo=2]}} {{路径/到/主文件.rs}}

解释错误信息

rustc --explain {{错误码}}

编译时针对当前 CPU 架构启用特定优化

rustc {{[-C|--codegen]}} target-cpu={{native}} {{路径/到/主文件.rs}}

显示目标列表(注意:你必须先使用 `rustup` 添加目标才能为其编译)

rustc --print target-list

针对特定目标编译

rustc --target {{目标三元组}} {{路径/到/主文件.rs}}

ヘルプを表示

rustc {{[-h|--help]}}

ヒント: 中括弧{{…}}置き換える必要があるのはパラメータ (パス、ファイル名など) です。 コマンドはローカル端末でのみ実行され、このサイトでは入力は保存されません。

英語原文比較

英語の説明と例を展開します (ソース tldr-pages)

The Rust compiler. Rust projects usually use `cargo` instead of invoking `rustc` directly. More information

Compile a binary crate

rustc {{path/to/main.rs}}

Compile with optimizations (`s` means optimize for binary size; `z` is the same with even more optimizations)

rustc {{[-C|--codegen]}} lto {{[-C|--codegen]}} opt-level={{0|1|2|3|s|z}} {{path/to/main.rs}}

Compile with debugging information

rustc {{[-g|--codegen debuginfo=2]}} {{path/to/main.rs}}

Explain an error message

rustc --explain {{error_code}}

Compile with architecture-specific optimizations for the current CPU

rustc {{[-C|--codegen]}} target-cpu={{native}} {{path/to/main.rs}}

Display the target list (Note: You have to add a target using `rustup` first to be able to compile for it)

rustc --print target-list

Compile for a specific target

rustc --target {{target_triple}} {{path/to/main.rs}}

Display help

rustc {{[-h|--help]}}

コマンド情報

コマンド名rustc
目的Rust 编译器。 Rust 项目通常使用 `cargo` 而不是直接调用 `rustc`
対応プラットフォーム通用
例の数8 記事
公式ドキュメントhttps://doc.rust-lang.org/stable/rustc/
データソースtldr-pages(CC-BY-4.0)· コミュニティ中国語翻訳

よくある質問

rustc コマンドは何をするのでしょうか?

Rust 编译器。 Rust 项目通常使用 `cargo` 而不是直接调用 `rustc`

rustc 使い方は?

シーン別ページ一覧8一般的に使用される例: 各例では、最初に目的を説明し、次に直接コピーできる完全なコマンドを示します (置換する必要があるパラメーターは中括弧内にあります)。

rustc 最も一般的に使用される操作は何ですか?

编译二进制包(crate):rustc {{路径/到/主文件.rs}}

コマンドの中の中括弧は何を意味しますか?

中括弧{{…}}パスやファイル名などの独自の値に置き換える必要があることを示します。 同じ名前のパラメータには角かっこ (例:[-C|--directory]) は任意の書き込みを示します。