Skip to content
New issue

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

Thin local LTO enabled for dependencies regardless of lto setting #9171

Closed
tgnottingham opened this issue Feb 14, 2021 · 0 comments · Fixed by #9182
Closed

Thin local LTO enabled for dependencies regardless of lto setting #9171

tgnottingham opened this issue Feb 14, 2021 · 0 comments · Fixed by #9182
Labels
C-bug Category: bug

Comments

@tgnottingham
Copy link

Thin local LTO is enabled for dependency crates despite setting lto = "off" (as long as the opt-level is non-zero and codegen-units is greater than 1, as usual). For example, it's enabled for dependencies in both the release and dev profiles with this configuration:

[profile.release]
lto = "off"

[profile.dev]
lto = "off"
opt-level = 1

It seems like lto = "off" should apply to dependencies, the same way opt-level applies to dependencies. The other lto settings (regular fat and thin LTO) should continue to not apply to dependencies, as by design, they only apply to the main crate.

Note that changing this would have some impact on #3244.

To reproduce, place the above profiles in the Cargo.toml of a project that has dependencies, and build with RUSTFLAGS="-Z time-passes" cargo +nightly build -j1. Look for the presence of LLVM_lto_optimize passes in the output when building dependencies.

It may also make sense to support disabling thin local LTO in a package profile:

[profile.release.package.foo]
lto = "off"

But this is currently disallowed, giving the error:

`lto` may not be specified in a `package` profile

cargo 1.49.0 (d00d64df9 2020-12-05)

@tgnottingham tgnottingham added the C-bug Category: bug label Feb 14, 2021
bors added a commit that referenced this issue Feb 18, 2021
Propagate `lto=off` harder

This commit fixes an issue with LTO calculation for various units when
`lto=off` is specified in the profile. This ensures now that `lto=off`
is passed to all transitive dependencies as well to disable thin-local
LTO. As an added bonus this also passed `embed-bitcode=no` whenever
`lto=off` is specified since we know we won't be using bitcode anyway.

Closes #9171
@bors bors closed this as completed in 1e05dbb Feb 18, 2021
kodiakhq bot pushed a commit to vercel/turborepo that referenced this issue Jun 21, 2023
### Description

- I disabled LTO for release builds. (Related:
rust-lang/cargo#9171)
We may need to revert these patches from CI

### Testing Instructions



---

fix WEB-812 ([link](https://linear.app/vercel/issue/WEB-812))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant