บันทึกของฮองมู

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])แสดงว่าเป็นรูปแบบการเขียนที่เลือกใช้ได้