4 ms·
The biggest question I have regarding rust-1.0, is what's the likelyhood of small/standalone binaries being possible? Last time I looked, while there was talk
by swetland 12y ago
The biggest question I have regarding rust-1.0, is what's the likelyhood of small/standalone binaries being possible? Last time I looked, while there was talk about lightweight core libraries on the website, but the basic hello world binary was 2MB+ and depended on a bunch of shared libraries. I spent a little time trying to figure out how to build static/smaller binaries without much luck.
- kibwen 12y agoRust's runtime is actually undergoing a dramatic overhaul and is being almost entirely removed as we speak: https://github.com/rust-lang/rust/pull/19654 https://github.com/rust-lang/rust/pull/19654 This is incredibly exciting in that it means that you won't need to do any ceremony to link in Rust libraries from other languages (previously you had to opt out of the stdlib and reimplement lang items as needed). But it also means that static libs should be much smaller, due to no runtime being necessary (which should also make LTO more able to strip unused symbols, shrinking binary size further).
- swetland 12y agoThat definitely sounds encouraging! Looking forward to this.
- steveklabnik 12y agoIt shouldn't be _both_ 2MB _and_ depend on a bunch of shared libraries, it should only be glibc and libgcc. And you can make it smaller by asking Rust to do dynamic linking rather than static linking. The smallest known Rust binary is 151 bytes: http://www.reddit.com/r/rust/comments/2iwtjh/151byte_static_binary_for_x8664_linux_in_rust/ http://www.reddit.com/r/rust/comments/2iwtjh/151byte_static_... My sibling also has great info.
- buster 12y agoTo be fair, it's not possible to tell cargo to do that (yet) (refering to https://github.com/rust-lang/cargo/issues/60 https://github.com/rust-lang/cargo/issues/60 )
- alkonaut 12y agoThat must be under something other than windows. Rust on Windows definitely still has issues with static linking, dependence on gcc libs for 32bit exception handling etc. Being able to build smaller statically linked binaries on windows is hopefully a priority.
- steveklabnik 12y agoAs I said before, a dependence on libgcc and glibc are expected. It's not an issue with static linking, you don't generally statically link those two dependencies.
- swetland 12y agoIs that expected to ever change and/or does Rust expect to work with other libcs (bionic? musl-libc?) Being able to build completely self-contained static binaries can be very nice at times, and for embedded use, glibc is pretty large... I thought Rust used llvm for compilation? That makes the libgcc dependency seem a bit odd. Maybe I misunderstood?
- steveklabnik 12y agoRight now, it can't work with other libcs, but if you strip things down enough, it's not required to use glibc either, for example, if you're building an OS. You just end up throwing away a lot of the standard library. Check out stuff like http://zinc.rs/ http://zinc.rs/ for embedded Rust. libgcc is used for stack unwinding, not for compilation. So it does seem a bit weird at first :)
- kibwen 12y agoWe have people who are interested in getting Rust working with musl, but it's not a high priority at the moment.