3 ms·
why the Go standard library doesn't go use libc They do you use a `libc` they use `musl-libc` [1] as apposed to `gnu-libc` (gblic) [2]. There are some differen
by valarauca1 8y ago
why the Go standard library doesn't go use libc
They do you use a `libc` they use `musl-libc` [1] as apposed to `gnu-libc` (gblic) [2]. There are some differences [3], the largest (without getting into various API incompatibilities) is licensing. `musl-libc` is BSD licensed, while `gnu-libc` (glibc) is GPL licensed.
The parent post does explain, about as well as any member of the go-team has to date for their usage of `musl-libc` over `gnu-libc` (glibc). Overall `musl-libc` does focus on correctness a lot more then `glibc`, and static linking is a large benefit.
Static linking isn't an issue when you expect applications to be short lived transient items. Where system images only exist for days, or hours before being redeployed by either patches, or CI-Managered triggered updates. I think this is the largest disconnect. Go expects the development pipeline to be quick so nobody expects multi-year lifespan binaries, which is directly contradictory to how many expect executable binaries to behave.
No that I'm authority on this, just stating a common disconnect I've experienced working with ex-Googlers.
[1] https://www.musl-libc.org/ https://www.musl-libc.org/
[2] https://www.gnu.org/software/libc/ https://www.gnu.org/software/libc/
[3] https://wiki.musl-libc.org/functional-differences-from-glibc.html https://wiki.musl-libc.org/functional-differences-from-glibc...
[4] https://github.com/golang/go/issues/9627 https://github.com/golang/go/issues/9627
- masklinn 8y ago> They do you use a `libc` they use `musl-libc` [1] as apposed to `gnu-libc` (gblic) [2] No. Historically they don't use a libc at all if you don't use the DNS subsystem. The latest version (1.11) finally started using libSystem on OSX (where performing raw syscalls has never ever been supported, and Go broke several time because they refused to acknowledge that).
- valarauca1 8y agoMy Go v1.11 compiler still emits symbols from `musl-libc` for static builds on linux. I had to dig through on object dump just on friday.
- TheDong 8y agoAre you running on a linux distro which uses musl, such as alpine? Are you running the build inside a docker container which uses musl, such as alpine? Those are the cases where this might happen. On a normal linux distro, this will not happen.
- TheDong 8y agoThis post is just plain wrong. They do not default to musl on any platform. They only default to the system's libc (which is typically gnu libc, though could be musl) if certain networking constructs are used. They otherwise default to not using any external libc library, but rather implementing one with syscalls internally. The above is for linux. On other platforms it varies further, but to my knowledge the parent post is not right on any platform.