Comments (14)
Is there a way to run cargo bloat on crates that are just libraries?
No, because executables and libraries are very different. Especially static libraries, which is the default.
Examples support is a good idea, but note that cargo-bloat
will show only stuff that is used by example, so you have to use as many features of your library as possible.
from cargo-bloat.
Examples support is a good idea, but note that cargo-bloat will show only stuff that is used by example, so you have to use as many features of your library as possible.
That would be fine. I think having that much support would still be extremely helpful. :)
from cargo-bloat.
I'm compiling my code to a static & dynamic library, so extending it to work on those cases would be really cool too.
from cargo-bloat.
@CryZe it's not possible due to the way executables and libraries are work. You can measure only executables.
from cargo-bloat.
Can you elaborate why?
from cargo-bloat.
I'm not that good in this, but the basics look like this:
- The static library is just a pile of code (in c/c++/rust it's an actual archive file with objects and some metadata). No optimizations are made afaik.
- The dynamic library is something in between. It support optimization, but not LTO afaik.
- The executable file format usually has the
.text
section in which the compiled code contains. And all this tool doing is measuring so-called symbols size. You can call them functions or methods. But Rust (and C++) has two other problems:- Generics (hello Go). The library can define generics, but not use them by itself, so they will be instanced only in the executable, so you can't measure them in the library.
- Inlining. Rust supports inlining which eliminates some functions completely. But there is no inlining in the static libraries (afaik) and only to some extend in dynamic library, so the results will be different.
from cargo-bloat.
Done.
from cargo-bloat.
Thank you! :)
from cargo-bloat.
Any chance we can reconsider this for staticlib
? Bloaty supports them, so it's definitely possible in theory.
from cargo-bloat.
There is nothing interesting in staticlib
and it doesn't affect the final binary in any way.
Remember, that staticlib
is just an archive of an intermediate compiler output. It still has to be compiled.
from cargo-bloat.
There is interesting info in a staticlib
, especially for embedded use cases that don't load in a traditional manner. A staticlib
is a collection of .o
files - it is compiled, just not linked yet. It's not an rlib
. While the output is imperfect (no LTO, for example), it's still useful data.
Bloaty supports analyzing a .a
/static lib because it can still provide useful information. You are incorrect about there being nothing interesting.
from cargo-bloat.
I will rephrase: it's not interested for cargo-bloat use case. cargo-bloat analyzes final binaries. That's it.
from cargo-bloat.
Why? I was planning on implementing this support, and would really rather not maintain a project fork for a feature that I believe should be there in the first place. Right now we have to settle with Bloaty, which doesn't yet have Rust name demangling.
from cargo-bloat.
Because cargo-bloat prints .text
section output. Can we get anything like this from static lib? I don't think so.
Can you show bloaty output?
from cargo-bloat.
Related Issues (20)
- Add `--tests` flag? HOT 6
- Support analyzing dynamic libraries HOT 6
- Build script analyzed instead of a static lib HOT 4
- Support msvc HOT 1
- cargo bloat prints json-time on stderr HOT 8
- cargo bloat --time can't execute cargo build HOT 9
- Discrepancy in reported `.text` size: `cargo bloat` vs GNU Binuils `size` HOT 3
- Cargo bloat doesn't forward compiler errors on build failure HOT 5
- don't suggest -n if all data is shown HOT 1
- Support custom profiles HOT 2
- How do I use cargo bloat with `-Zbuild-std`? HOT 7
- Incorrect target resolving
- Cargo bloaty reports only a tiny portion of the whole binary HOT 5
- How to examine other sections in the `.so` file? HOT 4
- Error: parsing failed cause 'section .symtab is missing'. HOT 10
- Detect `strip = true` in Cargo.toml HOT 3
- It "hangs" sometimes HOT 18
- Total time using cargo bloat --time? HOT 2
- missing releases on github HOT 2
- Info on the Size Calculation HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo-bloat.