Giter VIP home page Giter VIP logo

Comments (20)

sdroege avatar sdroege commented on July 22, 2024 1

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.

RazrFalcon avatar RazrFalcon commented on July 22, 2024

It can't be done. See #5 (comment) for details.

from cargo-bloat.

RazrFalcon avatar RazrFalcon commented on July 22, 2024

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.

CryZe avatar CryZe commented on July 22, 2024

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.

sdroege avatar sdroege commented on July 22, 2024

I don't know how Rust static libs work in detail, so no opinion on that.

from cargo-bloat.

RazrFalcon avatar RazrFalcon commented on July 22, 2024

Done.

from cargo-bloat.

CryZe avatar CryZe commented on July 22, 2024

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.

sdroege avatar sdroege commented on July 22, 2024

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.

RazrFalcon avatar RazrFalcon commented on July 22, 2024

@sdroege it's a different error. What is your pwd? Because it crashed there.

from cargo-bloat.

sdroege avatar sdroege commented on July 22, 2024

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.

CryZe avatar CryZe commented on July 22, 2024

If mine would get that far, it would probably also crash there if that's the case.

from cargo-bloat.

sdroege avatar sdroege commented on July 22, 2024

FWIW, commenting out the println! makes it work correctly.

from cargo-bloat.

RazrFalcon avatar RazrFalcon commented on July 22, 2024

@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 avatar sdroege commented on July 22, 2024

@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.

RazrFalcon avatar RazrFalcon commented on July 22, 2024

@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.

RazrFalcon avatar RazrFalcon commented on July 22, 2024

@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.

sdroege avatar sdroege commented on July 22, 2024

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.

RazrFalcon avatar RazrFalcon commented on July 22, 2024

@sdroege yes, but I removed it completely for now.

from cargo-bloat.

RazrFalcon avatar RazrFalcon commented on July 22, 2024

@CryZe fixed.

from cargo-bloat.

sdroege avatar sdroege commented on July 22, 2024

Great, thanks!

from cargo-bloat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.