Comments (20)
cdylibs don't contain generic code, can do LTO, etc. and there is no Rust metadata left either. Only a couple of C symbols are exported. It's basically like an executable.
from cargo-bloat.
It can't be done. See #5 (comment) for details.
from cargo-bloat.
Well, I was wrong about cdylib
. goblin
supports .so
and I don't tested dylib
yet. So at least Linux support for cdylib
can be implemented.
from cargo-bloat.
It seems like static libs are just multiple object files archived together and nm works just fine with that too. Linking might do additional pruning afterwards though, so that may have some influence, but I think at least some support for static libraries might possibly make sense too. What do you think @sdroege?
I'd be fine with just cdylibs for my use case though, as I just compile to both anyway.
from cargo-bloat.
I don't know how Rust static libs work in detail, so no opinion on that.
from cargo-bloat.
Done.
from cargo-bloat.
I just tried it and it doesn't seem to work:
Compiling livesplit-core-capi v0.8.1 (file:///mnt/home/CryZe/workspace/livesplit-core/capi)
Finished release [optimized] target(s) in 162.28 secs
Only 'bin' and 'cdylib' targets are supported.
$ ls ../target/release/
build/ liblivesplit_core_capi.d
.cargo-lock liblivesplit_core_capi.rlib
deps/ liblivesplit_core_capi.so
examples/ liblivesplit_core.rlib
.fingerprint/ liblivesplit_hotkey.rlib
incremental/ native/
liblivesplit_core_capi.a
Cargo.toml:
[package]
name = "livesplit-core-capi"
version = "0.8.1"
authors = ["Christopher Serr <[email protected]>"]
[dependencies]
livesplit-core = { path = ".." }
libc = "0.2.18"
[lib]
crate-type = ["rlib", "cdylib", "staticlib"]
from cargo-bloat.
Also does not work here, but differently:
Finished release [optimized + debuginfo] target(s) in 0.0 secs
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: StripPrefixError(())', /checkout/src/libcore/result.rs:906:4
stack backtrace:
0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::_print
at /checkout/src/libstd/sys_common/backtrace.rs:68
2: std::panicking::default_hook::{{closure}}
at /checkout/src/libstd/sys_common/backtrace.rs:57
at /checkout/src/libstd/panicking.rs:381
3: std::panicking::default_hook
at /checkout/src/libstd/panicking.rs:397
4: std::panicking::rust_panic_with_hook
at /checkout/src/libstd/panicking.rs:577
5: std::panicking::begin_panic
at /checkout/src/libstd/panicking.rs:538
6: std::panicking::begin_panic_fmt
at /checkout/src/libstd/panicking.rs:522
7: rust_begin_unwind
at /checkout/src/libstd/panicking.rs:498
8: core::panicking::panic_fmt
at /checkout/src/libcore/panicking.rs:71
9: core::result::unwrap_failed
at /checkout/src/libcore/macros.rs:23
10: <core::result::Result<T, E>>::unwrap
at /checkout/src/libcore/result.rs:772
11: cargo_bloat::process_bin
at src/main.rs:166
12: cargo_bloat::real_main
at src/main.rs:143
13: cargo::call_main_without_stdin
at /home/slomo/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-0.24.0/src/cargo/lib.rs:128
14: cargo_bloat::main
at src/main.rs:99
15: __rust_maybe_catch_panic
at /checkout/src/libpanic_unwind/lib.rs:101
16: std::rt::lang_start
at /checkout/src/libstd/panicking.rs:459
at /checkout/src/libstd/panic.rs:365
at /checkout/src/libstd/rt.rs:58
17: main
18: __libc_start_main
19: _start
from cargo-bloat.
@sdroege it's a different error. What is your pwd
? Because it crashed there.
from cargo-bloat.
path is "/home/slomo/Projects/rust/gst-plugin-rs/target/release/deps/libgstrsaudiofx.so", pwd is "/home/slomo/Projects/rust/gst-plugin-rs/gst-plugin-audiofx". Maybe it's confused because it's a sub-crate inside a cargo workspace?
from cargo-bloat.
If mine would get that far, it would probably also crash there if that's the case.
from cargo-bloat.
FWIW, commenting out the println! makes it work correctly.
from cargo-bloat.
@sdroege Yes. It works only when target
folder is in the same folder.
@CryZe crate-type
with multiple values was not supported. Fixed.
from cargo-bloat.
@sdroege Yes. It works only when target folder is in the same folder.
Should I open a new issue about that then, for more complete workspace support? Also it seems to work fine already except for the println!
from cargo-bloat.
@CryZe looks like I can't get a library path if crate-type
has more than one value. Will open a cargo bug.
from cargo-bloat.
@sdroege yes, the bug is in println line. I will remove it for now and try to test with more complex workspaces.
from cargo-bloat.
For the println!, this should be able to just use Path::file_name instead of the component stripping it does right now, or not?
from cargo-bloat.
@sdroege yes, but I removed it completely for now.
from cargo-bloat.
@CryZe fixed.
from cargo-bloat.
Great, thanks!
from cargo-bloat.
Related Issues (20)
- Doesn't work with custom registries HOT 2
- Default test binary HOT 3
- --release flag fails HOT 4
- Add an option to sort output by crate/fn name instead of size HOT 1
- 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
- FR: Cargo bloat should allow multiple `--features=foo` flags and merge them HOT 1
- [Q&A] Is there a tool or plugin that uses `cargo bloat` information to point at duplication due to monomorphization? HOT 2
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.