Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Go wants low overhead multithreading and static linkage. Glibc is inherently dynamically linked, and sets up threads in ways Go doesn't want.

Error doesn't work for everyone else. It's a hack, you wouldn't do it if it wasn't for backwards compatability.



But why does it want to not dynamically link against a platform's libc?

What is the advantage in that? including that into a binary seems about as senseless to me as including the entire kernel in it.


Not all platforms have a "libc". Linux is an example: there is no standard c library and while glibc is very common, there are several distributions that use other C libraries like uClibc and musl. For example a gaming handheld i have which is running Linux uses uClibc

Another example is Windows, the platform API does not provide a C library (even MSVC has its own). While there is an MSVCRT.DLL it is not recommended to link against it as it is there only because some other software relies on it and its semantics are for around Visual C++ 4 (IIRC).


Windows used to be an example like any other non-POSIX OS, however as of Windows 10, the C standard library is part of the OS.

https://devblogs.microsoft.com/cppblog/introducing-the-unive...


Ah yes, i've forgotten about it. I wonder how reliable that is as i noticed a bunch of applications i have ship their own copy of ucrtbase.dll.


But Linux is not a platform in general.

It is already next to impossible to write software that requires “Linux” and nothing more with all the kernel functionality that can be enabled or disabled.

Linux is a component of many different platforms, which indeed do provide different libcs, but also different t.l.s. libraries, different c.p.u. architectures, different Linux configurations and whatever else.

As far as I know with respect to Windows, it only provides stable interfaces viā C libraries, and does not have a stable binary interface to the kernel directly.


Right, Windows has a stable C API, but the comment i replied to was about a platform libc.


For containers Go static binaries are great. Used to build Docker containers for Kubernetes using a 8 MB Go binary. That was all you needed. No libraries. No "minimum OS' Alpine or Ubuntu image.


That seems to be a sensible use yes, but those aren't really any targeted and supported platform.


Not every libc is a glibc.


True but errorno is still a hack.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: