Rust 빌드의 종류
빌드 종류 요약
빌드 종류 |
명령어 |
설명 |
산출물 위치 |
최적화 |
디버그 |
cargo build |
개발 디버그용 빌드 |
target/debug/ |
❌ |
릴리즈 |
cargo build –release |
애플리케이션 배포용 빌드 |
target/release/ |
✅ |
문서 |
cargo doc |
애플리케이션 설명문서 빌드 |
target/doc/ |
N/A |
테스트 |
cargo test |
코드 정확성 테스트 |
target/debug/deps/ |
❌ |
벤치마크 |
cargo bench |
코드 성능 테스트 |
target/release/ |
✅ |
디버그 빌드 (Debug Build)
목적
명령어
1
2
| cargo build
cargo run
|
특징
✅ 컴파일 속도 빠름
✅ 심볼 정보 포함 (디버깅 가능)
✅ 실행 속도 느림 (최적화 안 됨)
✅ 산출물 위치: target/debug/
릴리즈 빌드 (Release Build)
목적
- 실행에 최적화된 실행 파일 생성
- 애플리케이션 배포용 빌드
명령어
1
2
| cargo build --release
cargo run --release
|
특징
✅ 컴파일 속도 느림
✅ 최적화 수준 높음 (opt-level = 3
)
✅ 실행 속도 빠름
✅ 산출물 위치: target/release/
문서 빌드(Documentation Build)
목적
명령어
1
2
| cargo doc
cargo doc --open
|

특징
✅ target/doc/
에 HTML 문서 생성
✅ --open
옵션으로 브라우저에서 바로 열기
테스트 빌드 (Test Build)
목적
명령어
1
2
3
4
5
6
7
8
| # test 결과 출력
Compiling hello_world v0.1.0 (/..../hello_world)
Finished `test` profile [unoptimized + debuginfo] target(s) in 0.69s
Running unittests src/main.rs (target/debug/deps/hello_world-87fa2baacdcc66af)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
|
특징
✅ 테스트 코드 포함 빌드
✅ target/debug/deps/
에 산출물 생성
벤치마크 빌드 (Benchmark Build)
목적
명령어
1
2
3
4
5
6
7
8
| # 결과 출력
Compiling hello_world v0.1.0 (/.../hello_world)
Finished `bench` profile [optimized] target(s) in 0.43s
Running unittests src/main.rs (target/release/deps/hello_world-39bc61f259f238ba)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
|
특징
✅ 벤치마크 코드 빌드 및 실행
✅ 릴리즈 빌드로 컴파일 (최적화 포함)
Reference
https://doc.rust-lang.org/book/
https://doc.rust-lang.org/cargo/
Comments