목차

, , ,

rustc

Rust crate root를 binary 또는 library로 컴파일하는 공식 compiler frontend.

Summary

일반 project는 Cargo를 통해 rustc를 호출한다. 직접 호출은 단일 file 실험, build system 통합, compiler option 진단에 적합하다.

Installation

rustc는 rustup toolchain에 포함된다. platform별 설치는 Rust Installation을 따른다.

rustup default stable
rustc --version

Usage

rustc [options] input

Options

Examples

rustc hello.rs
rustc --edition 2024 hello.rs -o hello
rustc --crate-type lib src/lib.rs
rustc --target wasm32-unknown-unknown src/lib.rs
rustc --explain E0382
rustc --print sysroot
rustc --print target-list
cargo build --verbose
module이 여러 개인 project와 dependency resolution에는 직접 rustc를 조립하기보다 Cargo를 사용한다. cargo build –verbose로 Cargo가 생성한 compiler invocation을 볼 수 있다.

Compatibility

-Z option과 일부 target은 nightly 또는 추가 component가 필요하다. stable build automation에서 nightly option을 무조건 사용하지 않는다.

Troubleshooting

Help

+ rustc --help

로컬 실행 파일이 없어 live output을 수집하지 않았다.
rustc --help
rustc -C help
rustc --print target-list

+

See Also

History