We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using the Cargo.toml below, LTO is not used for the staticlib target when building multiple library targets with cargo build --release.
Cargo.toml
staticlib
cargo build --release
To enable LTO, the lib target must be removed, or we must use cargo rustc --crate-type=staticlib for building separately.
lib
cargo rustc --crate-type=staticlib
[package] name = "a" [profile.release] lto = true [lib] crate-type = ["lib", "staticlib"]
Show a warning that LTO is disabled for the LTO-compatible targets, and suggest using cargo rustc --crate-type=X.
cargo rustc --crate-type=X
cargo 1.81.0 (2dbb1af80 2024-08-20) release: 1.81.0 commit-hash: 2dbb1af80a2914475ba76827a312e29cedfa6b2f commit-date: 2024-08-20 host: x86_64-unknown-linux-gnu libgit2: 1.8.1 (sys:0.19.0 vendored) libcurl: 8.8.0-DEV (sys:0.4.73+curl-8.8.0 vendored ssl:OpenSSL/1.1.1w) ssl: OpenSSL 1.1.1w 11 Sep 2023 os: Ubuntu 20.4.0 (focal) [64-bit]
The text was updated successfully, but these errors were encountered:
We have this comment in the code though it lacks an explanation
cargo/src/cargo/core/compiler/lto.rs
Lines 109 to 111 in 5e2878f
Sorry, something went wrong.
That code seemed to be added in #8349
No branches or pull requests
Problem
Using the
Cargo.toml
below, LTO is not used for thestaticlib
target when building multiple library targets withcargo build --release
.To enable LTO, the
lib
target must be removed, or we must usecargo rustc --crate-type=staticlib
for building separately.Steps
Cargo.toml
:cargo build --release
Possible Solution(s)
Show a warning that LTO is disabled for the LTO-compatible targets, and suggest using
cargo rustc --crate-type=X
.Version
The text was updated successfully, but these errors were encountered: