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

cargo-bloat fails to find std libraries, it expects them to live in /usr/lib/rustlib #51

Closed
stefson opened this issue Dec 24, 2019 · 14 comments

Comments

@stefson
Copy link

stefson commented Dec 24, 2019

how to reproduce, with the example of a fresh git checkout:

cd tmp && git clone https://github.com/eqrion/cbindgen.git
cd cbindgen
cargo bloat 
compiling...
Error: failed to find a dir with std libraries. Expected location: /usr/lib/rustlib/x86_64-unknown-linux-gnu/lib.

this is on a x86_64 machine, hence there's /usr/lib64/${RUSTVERSION}/ where rustlib resides. Not sure wether that is excentric behavior from my distro? :-)

@RazrFalcon
Copy link
Owner

What rustc --print=sysroot outputs?

@stefson
Copy link
Author

stefson commented Dec 24, 2019

here's the output:

rustc --print=sysroot
/usr

@RazrFalcon
Copy link
Owner

Do you have rustlib at all?

@stefson
Copy link
Author

stefson commented Dec 24, 2019

Sure, I've got full rust toolchain available. It's actually the case that cargo build is executed before cargo bloat, and the error only appears when cargo build has finished it's compile. It's most likely a problem that rustlib resides in /usr/lib64, and the folder isn't scanned by cargo-bloat.

@RazrFalcon
Copy link
Owner

The problem is that I don't know where rustlib is. Currently, cargo-bloat uses the same algorithm as rustc.

Maybe your distro has a patched rust?

@stefson
Copy link
Author

stefson commented Dec 24, 2019

here's the file list: rust-files.gz

@RazrFalcon
Copy link
Owner

Looks like a bug of your distro. Library should be in

/usr/lib64/rustlib/x86_64-unknown-linux-gnu/lib

and not in

/usr/lib64/rust-1.39.0/rustlib/x86_64-unknown-linux-gnu/lib

@stefson
Copy link
Author

stefson commented Dec 25, 2019

I initially thought it was the fact that it resides in /usr/lib64, since all debian based distros don't distinguish lib and lib64, but it makes sense to me. Will test now.

@stefson
Copy link
Author

stefson commented Dec 30, 2019

this got triggered by a bug in gentoo, as you mentioned. This is now fixed, gentoo bug for reference: https://bugs.gentoo.org/703744

thanks for pointing me towards it! :)

@stefson stefson closed this as completed Dec 30, 2019
@RazrFalcon
Copy link
Owner

Glad to hear, since I'm using Gentoo too. =) Only I'm installing Rust via rustup.

@o01eg
Copy link

o01eg commented Mar 1, 2020

Currently, cargo-bloat uses the same algorithm as rustc.

rustc found out alternative libdir because it compiled with alternative CFG_LIBDIR_RELATIVE environment:

https://github.com/rust-lang/rust/blob/a916ac22b9f7f1f0f7aba0a41a789b3ecd765018/src/librustc_session/filesearch.rs#L159

@RazrFalcon
Copy link
Owner

Can I access it via CLI?

@o01eg
Copy link

o01eg commented Mar 1, 2020

No yet, I'm think it better to expose it with --print=libdir or so.

@o01eg
Copy link

o01eg commented Mar 1, 2020

@RazrFalcon I've opened PR: rust-lang/rust#69608

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Mar 8, 2020
…=ehuss

Expose target libdir information via print command

With custom libdir it is required to have an access to library placement.

See RazrFalcon/cargo-bloat#51
Centril added a commit to Centril/rust that referenced this issue Mar 8, 2020
…=ehuss

Expose target libdir information via print command

With custom libdir it is required to have an access to library placement.

See RazrFalcon/cargo-bloat#51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants