4 ms·
This is cute, but is there a way to actually create static binaries with the standard tooling and not jumping through hoops? Hello World in Rust with tip of tr
by swetland 12y ago
This is cute, but is there a way to actually create static binaries with the standard tooling and not jumping through hoops?
Hello World in Rust with tip of tree (as of yesterday) is a ~500K binary that depends on glibc and friends.
Switching from println!() to std::io...write_str() actually made it larger!
- steveklabnik 12y agoYou can't static link glibc, so our static binaries still have a dynamic dependency on it.
- cowsandmilk 12y agoand for many, there are legal issues with statically linking glibc due to its license.
- swetland 12y agoIs there a process for making a fully static binary (say if I were to substitute an alternate libc, or provide my own low level wrappers for syscalls, or whatnot)?
- steveklabnik 12y agoYes, that's totally possible. You can write a kernel in Rust if you want.
- tdrd 12y ago...is it documented anywhere? where?
- steveklabnik 12y agohttp://doc.rust-lang.org/book/unsafe.html#avoiding-the-standard-library http://doc.rust-lang.org/book/unsafe.html#avoiding-the-stand... is the closest we have, currently. https://github.com/rust-lang/rust/wiki/Operating-system-development https://github.com/rust-lang/rust/wiki/Operating-system-deve... has a bunch of stuff, and https://github.com/charliesome/rustboot https://github.com/charliesome/rustboot and its forks are examples that I know of.
- swetland 12y agoThe example minimal do-nothing program there is much smaller (8k), but still results in a dynamic binary requiring glibc. The only unresolved symbol is: __libc_start_main@@GLIBC_2.2.5
- daurnimator 12y agoI believe musl supports static linking
- ChickeNES 12y agoAny reason one couldn't use musl instead for static linking? (http://www.musl-libc.org/ http://www.musl-libc.org/)