Rust release profiles: customize dev and release opt-level in Cargo
Answer: Cargo profiles let you change settings such as opt-level for dev (cargo build) and release (cargo build --release).
dev and release
Cargo ships predefined, adjustable profiles so you can control how code is compiled.
Each profile is configured independently of the others.
The two main profiles are dev, used by a plain cargo build, and release, used by cargo build --release.
dev favors short compile times and, by default, no optimizations.
The release profile has good defaults for release, trading longer compile time for faster code.
Cargo has default settings for each of the profiles that apply when you haven't added any [profile.*] sections in Cargo.toml, and adding a section overrides a subset of the default settings.
opt-level
The default opt-level for the dev profile is 0, and the default for the release profile is 3.
opt-level controls how many optimizations Rust applies, in a range from 0 to 3.
Applying more optimizations extends compiling time, so in development you will want fewer optimizations to compile faster.
In release mode you compile infrequently and then run the compiled program many times.
Setting opt-level to 1 on the development profile applies more optimizations than the default, though still not as many as a release build.
Cargo's documentation lists every option and default.
See also
Claims
- id: C1 claim: Cargo uses the dev profile for cargo build and the release profile for cargo build --release. source: S1 evidence: "the dev profile Cargo uses when you run cargo build"
- id: C2 claim: The default opt-level is 0 for dev and 3 for release. source: S1 evidence: "The default opt-level for dev is therefore 0"
- id: C3 claim: opt-level ranges from 0 to 3 and higher values take longer to compile. source: S2 evidence: "with a range of 0 to 3."
Sources
- [S1] Customizing Builds with Release Profiles. The Rust Project Developers. https://doc.rust-lang.org/book/ch14-01-release-profiles.html . License: MIT OR Apache-2.0. Accessed 2026-11-26.
- [S2] Customizing Builds with Release Profiles (source). The Rust Project Developers. https://raw.githubusercontent.com/rust-lang/book/main/src/ch14-01-release-profiles.md . License: MIT OR Apache-2.0. Accessed 2026-11-26.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Rust Project Developers, Customizing Builds with Release Profiles; The Rust Project Developers, Customizing Builds with Release Profiles (source). MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Rust Project Developers, Customizing Builds with Release Profiles; The Rust Project Developers, Customizing Builds with Release Profiles (source). MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers.
Cite this
iinventedlight. 2026. "Rust release profiles: customize dev and release opt-level in Cargo." iinventedlight Library, iil:note:ts5myeek, version of 2026-11-26. https://iinventedlight.com/library/notes/rust-release-profiles/. License: CC-BY-4.0.
@misc{iil_note_ts5myeek,
author = {{iinventedlight}},
title = {{Rust release profiles: customize dev and release opt-level in Cargo}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-26},
url = {https://iinventedlight.com/library/notes/rust-release-profiles/},
note = {Permanent ID iil:note:ts5myeek. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- rust-release-profiles.schema.json (schema; CC-BY-4.0)
- rust-release-profiles.table.json (table; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/rust-release-profiles.md.