-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
linking with cc failed when using lto = fat #72268
Comments
@alexcrichton It looks like when a dependency has mixed crate types ( Also, note, that this hits #60059 on macos where linking won't even start. |
Nah yeah this is a bug in Cargo's passing of |
This should be fixed in rust-lang/cargo#8254. It's worth noting that with an rlib/cdylib crate type output LTO is turned off (due to #51009), so the LTO setting doesn't actually do anything other than cause more work during compilation otherwise. |
In the case that LTO is happening but we're also generating a cdylib/rlib simultatneously that means that the final artifact will use the rlib but the cdylib still needs to be produced. To get this to work the cdylib's dependency tree needs to be compiled with embedded bitcode. The cdylib itself will be linked with the linker because we can't LTO an rlib+cdylib compilation, but the final executable will need to load bitcode from all its deps. This is meant to address rust-lang/rust#72268
Handle LTO with an rlib/cdylib crate type In the case that LTO is happening but we're also generating a cdylib/rlib simultatneously that means that the final artifact will use the rlib but the cdylib still needs to be produced. To get this to work the cdylib's dependency tree needs to be compiled with embedded bitcode. The cdylib itself will be linked with the linker because we can't LTO an rlib+cdylib compilation, but the final executable will need to load bitcode from all its deps. This is meant to address rust-lang/rust#72268
@alexcrichton we should close this one now, right?. |
Indeed! |
This bug can be reproduced only by using two crates, nothing else worked so far
A::Cargo.toml
A::main.rs is empty (or just a plain
fn main() {}
, doesn't matter).B::Cargo.toml
B::src/lib.rs is empty as well (or any public function, doesn't matter as well)
When compiling this with
cargo build
, it errors:Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: