4 ms·
Do they? As far as I know, Go is the only mainstream language that supports static binaries with normal non-trivial programs. Rust for example depends on dynami
by loosescrews 6y ago
Do they? As far as I know, Go is the only mainstream language that supports static binaries with normal non-trivial programs. Rust for example depends on dynamically linked libc if you use the standard library. While you technically can statically link libc, it is unsafe with glibc.
- mrkurt 6y agoRust and Deno qualify as a "single executable" for what I need, but you're basically correct. It's not quite as dependency free as a Go binary.
- pjmlp 6y agoAda, FreePascal, C and C++ do perfectly fine. Not everyone is using Linux with glibc linking issues.
- loosescrews 6y agoUsing C and C++ without libc excludes the use of nearly all common libraries.
- lucacasonato 6y agoWe currently do dynamically link to glibc. But we could in theory support musl, which would remove our dependance on the glibc dynamic link.
- lock-free 6y agoThat's why you statically link musl C
- kibwen 6y agoI think the belief that Go does no dynamic linking whatsoever is outdated; I seem to recall that they recanted this approach on Mac and Windows since these platforms only offer a stable system interface via dynamically-linked libraries, and trying to re-implement all of it ended up being a lot of work only to end up with broken code after system updates. On Linux I think Go still tries to link mostly statically, but if you use parts of the stdlib (e.g. `net`) you'll still end up dynamically linking to libc unless you instruct it otherwise. If anyone more knowledgeable could speak up I'd welcome it.
- sim_card_map 6y agoThis is correct.
- loosescrews 6y agoGo supports dynamic linking and most Go binaries will be dynamically linked. On Linux, this is mostly due to optional features which can be easily disabled. The optional features are all related to supporting rare and unusual system configurations and do not affect normal operation. Note that cross compilation with Linux as the target does not support dynamic linking, so all Go Linux binaries compiled on a non-Linux OS will be statically linked. Regardless of how we scope it, Go is still the only mainstream language capable of producing statically linked Linux binaries without libc while still allowing full use of the standard library.
- pjmlp 6y agoC with musl does just fine.
- hetman 6y agoRust has supported statically linking to MSVC and musl for a while now but also added static glibc support on Linux very recently: https://github.com/rust-lang/rust/pull/77386 https://github.com/rust-lang/rust/pull/77386
- loosescrews 6y agoIs it possible to compile with statically linked musl with the pre-built Rust toolchain on a standard glibc based distribution?
- SomaticPirate 6y agoYes, but there are claims it is slower https://www.reddit.com/r/rust/comments/a6pna3/comment/ebzpzld https://www.reddit.com/r/rust/comments/a6pna3/comment/ebzpzl...
- saagarjha 6y agomusl is generally not optimized for performance.
- mkj 6y agoYes, it works well. The main caveat I've found is you need the rustls feature of packages rather than openssl. Though perhaps that was more related to cross compiling for Arm.