13 ms·
About Musl
- peter_d_sherman 7y agoExcerpt: "Attention to correctness musl was the first Linux libc to have mutexes safe to use inside reference-counted objects, the first to have condvars where newly-arrived waiters can't steal wake events from previous waiters, and the first to have working thread cancellation without race conditions producing resource-leak or double-close. All of these are requirements of the specification that were ignored by other implementations, and getting them right was a consequence of careful reading of those specifications. musl's entire development history has been a process of reading specifications, seeking clarifications when corner cases aren't adequately covered, and proceeding with extreme caution when implementing functionality that's underspecified."
- jfkebwjsbx 7y agoSo basically a lawyer view of software engineering. It is very good to adhere to specs when possible, but not always.
- Koshkin 7y agoSo, as Einstein could have said it, "We should follow the specs as far as possible, but not any further."
- kbumsik 7y agoI've heard a lot of libc but not stdlib from other languages. I assume that most of languages that depend on C (such as Python, JVM) depend on libc as well. Is there any languages implements a runtime in C but implements its own low-level interfaces?
- ksherlock 7y agosome k-family languages do that. http://kparc.com/b/A.S http://kparc.com/b/A.S
- smabie 7y agoBut why?
- yjftsjthsd-h 7y agoThe k family likes to be the whole stack; they would view libc as an unnecessary huge[0] dependency. [0] To k, every other language/library/program is too big.
- smabie 7y agoSeeing that libc is undoubtedly already loaded in memory as a dynamic lib on all systems, that doesn't make much sense. Moreover kdb+/q links to libc, and it has very good performance and memory usage.
- floatboth 7y agoHuh, nice domain name, is that new? It was musl-libc.org with a dash before..
- swat1508 7y agoOk nice
- tyingq 7y agomusl, pronounced like the word “mussel” or “muscle” Oh. I've been saying mew-sel this whole time.
- moomin 7y agoI've been saying muzzle.
- Aissen 7y agoI've been using musl on embedded systems for a while, and its simplicity is indeed quite a feature. My biggest issue is the lack of ASan, or ever HWAsan. valgrind is nice, but quite slow. I know Rich has been working on a new allocator that will make ASan easier to implement, but it's still a few months away.
- rustybolt 7y agoThe bad thing is, it's pretty hard to compile Linux with musl. I don't remember the specifics, but it had to with the #define mess that glibc uses.
- onli 7y agoI also stayed away from musl because of compatibility concerns. I see the appeal, and void even has a musl version. But I remember posts about software not being available, maybe sometimes just not being as easy to install. Thinking of steam there for example, though I'm sure there are solutions to make it run anyway.
- KitDuncan 7y agoYou can just use flatpacked Steam if you want to use Musl Void. There might be still a few issues, but that's not because of Musl, but because of the Flatpack version.
- friend-monoid 7y agoBut the kernel itself doesn’t use glibc?
- buserror 7y agoI had some problems with musl last year and had to back out using it for an embedded system. Typically for example, 2 threads listening to their own socket bound using REUSEPORT wouldn't work; half the connection would arrive on a thread and the second one wouldn't get anything. That scared me a bit as I was on a deadline to deliver, so I had to quickly recompile my distro with glibc, and the problem disappeared. I really wish it worked as I like the lean&mean&precise approach they've been using!
- wahern 7y agoOther than #define'ing SO_REUSEPORT, libc has no role whatsoever in its behavior. You can see this yourself by grep'ing for SO_REUSEPORT in the glibc and musl source code. And both glibc and musl implement 1:1 threading, so it's the kernel making all the thread scheduling and inbound connection queueing decisions. Your problem lay elsewhere, unless you were using a really old version of musl that lacked the SO_REUSEPORT definition.
- buserror 7y agoI do not have an explanation either. I'm more of a kernel guy so I realized it "should" have worked but it didn't. I suspect perhaps a thread wakening issue of some sort, as the connections were definitely 'queued' on the listen socket. I know that that same code worked perfectly with glibc!
- Chris2048 7y agoAlpine (the docker distro) uses musl, but this means that you can't use many python wheels because they aren't musl based :-/
- jpgvm 7y agoAlpine is not "the Docker distro". It predates Docker by quite some time and was used in lots of lightweight systems. Python wheels compiled using the manylinux infrastructure actually do work on Alpine + musl. That said I wouldn't recommend running Python on musl as I have seen incredibly weird behaviour including corruption of Python's low integer cache resulting in some truely awful consequences. i.e amounts of currency suddenly being 10x what they should be.
- Chris2048 7y agoPresumably those manylinux wheels do not have c bindings, when they do they are glibc based.
- Conan_Kudo 7y agomanylinux wheels are exclusively binary wheels with compiled parts, so they're all glibc-based (as the manylinux ABI is glibc).
- Chris2048 7y agoThen, I can't see how they work on Alpine w/ musl. @jpgvm Do you mean they work if you manually install them? b/c pip won't install glibc wheels on alpine.
- greenshackle2 7y agoThere's no guarantee that they do and I certainly don't expect any random manylinux wheel off pypi to work on alpine. I maintain one that definitely doesn't. We build a musl wheel too but there's no musl platform tag so we don't have a good way to distribute it on pypi.
- moomin 7y agoBiggest problem for musl isn't actually a problem _with_ musl at all, it's this: the C stdlib isn't an ABI. What this means is, something compiled for glibc doesn't necessarily work with musl and will just crash. This problem goes much further than you'd expect. For instance, if you use .NET 3.1 with Alpine, you can't use Google's gRPC client (thankfully, you can use Microsoft's).
- tyingq 7y agoI see similar issues with devs trying to use pre-compiled (originally w/glibc) JVMs with Alpine. There are musl built JVMs, but the dev teams seem unaware musl is even there.
- ur-whale 7y agoThis actually goes further than that as different version of glibc aren't ABI compatible with one another.
- bonzini 7y agoThey are backwards-compatible (which is all you can do of course).
- ur-whale 7y agoAre they ? If seen my share of old x64 binaries refusing to run on modern linux distro, spouting some sort of undecipherable glibc error message on startup (something along the lines of "version `GLIBC blah' not found)
- floatboth 7y agoThat message happens when a new binary is run on an old glibc, not the other way around.
- ur-whale 7y agoYes, you'd think so indeed. Unfortunately, I've seen the exact opposite in production: older binary running atop newer glibc and crashing with that kind of message. glibc abi compatibility is and has been a joke.
- stefan_ 7y agoThe libc situation is pretty unfortunate. You can go with glibc for compatibility, but ideally you don't actually use the upstream version but copy the one from Debian that has crucial fixes that most of the world uses that they didn't bother to upstream because for a while there, glibc was maintained by the biggest asshole in all of software engineering. On the other hand you have musl, and we can all appreciate its design goals, but then it is similarly maintained by people that believe they and their work are utterly infallible. Hence why to this date they have not made it possible to detect musl and would rather cite you a POSIX standards meeting from 1980 than fix an incompatibility everyone else handles differently. Just ctrl+F musl on http://landley.net/toybox/ http://landley.net/toybox/ for some insight. The last time I felt like smashing the desk because of musl was when I realized you can't stacktrace a thread in a syscall because they refuse to annotate their 10 lines of assembler doing the syscall with the required CFI directives. They would rather wait for someone to write a 200 line AWK script that does it ([1]) than fix debugging on platforms like arm64. 1: https://github.com/bminor/musl/blob/master/tools/add-cfi.x86_64.awk https://github.com/bminor/musl/blob/master/tools/add-cfi.x86...
- bonzini 7y ago> crucial fixes that most of the world uses that they didn't bother to upstream If you are talking about eglibc, it's been merged back for years.
- stefan_ 7y agoThe specific anecdote I was thinking of is glibc not reloading resolv.conf automatically, making people think they have no internet connectivity for no good fucking reason for decades now. Debian carries a patch since 2006: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=272265 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=272265 Why is my Pidgin thinking I'm offline, 2007: https://developer.pidgin.im/ticket/2825 https://developer.pidgin.im/ticket/2825 Firefox 2008: https://bugzilla.mozilla.org/show_bug.cgi?id=214538 https://bugzilla.mozilla.org/show_bug.cgi?id=214538 Chef, 2015: https://github.com/chef/chef/issues/2894 https://github.com/chef/chef/issues/2894 Someone stumbled on this brokenness in Rust in 2017: https://github.com/rust-lang/rust/issues/41570 https://github.com/rust-lang/rust/issues/41570 And then drums Wed Aug 2 19:12:20 2017 glibc 2.26 released with a patch. Maybe programs can rely on this behavior starting in 2027.
- ddevault 7y agoAlpine Linux uses musl libc, and SourceHut runs Alpine on all hosts and VMs. It's lean and mean and fast, and together with Alpine makes for a wonderfully simple and auditable system. I wouldn't dream of using anything else in production.
- driverdan 7y agoDependency management can be a pain. Want to install numpy? You have to use alpine's version because compiling it from pip requires glibc.
- rkeene2 7y agoCan you do something like `pip install --no-binary :all:` (or equivalent pip.conf entry) ?
- greenshackle2 7y agoYou normally will not get wheels with compiled binaries on alpine anyway because it is not compatible with any of the platform tags (manylinux* is glibc only). I think they're saying numpy won't compile with musl off the shelf, you need patches for alpine. Pip just won't help you there.
- ddevault 7y agoUsing anything other than distro packages is a pain. pip is an anti-pattern and one giant security risk.
- npx 7y agoThe musl community is one of my favorite things on the internet. It's obvious that many members of it could be making a generous salary at any number of companies but they're just hanging out on IRC because they don't give a shit and they love software. I don't get the sense that they think they are infallible, just that they are right far more often than not. You can't achieve the sort of spartan aesthetic that you see in the musl codebase by handling things like everyone else. The ability to distill things to their essence betrays a very high level of understanding. As they say in the streets, the dope sells itself.
- api 7y agoAlpine Linux is by far my favorite distro and I wish it had more support. Not only is musl nice, but it lacks a huge amount of obsolete cruft and the package manager is nice and simple and not over-engineered. It also lacks systemd. It probably lacks a lot of the "enterprise" cruft in CentOS/RHEL or Debian, but that's a good thing for everyone else.
- fmajid 7y agoI use Alpine as the OS on my home server (it used to be SmartOS/Illumos) and I compile my entire stack myself using my own cross-platform (Solaris/Linux/OS X/FreeBSD/OpenBSD) build system similar to BSD ports. While there are some portability gotchas, by and large it's manageable.
- random3 7y agoWe were using Alpine Docker images. Every few months the docker build would fail with some random glibc / musl glibc-compat new issue. The docker file is full of comments like the following: # libc6-compat needed by outdated grpc-tools # we get # sh: node_modules/grpc-tools/bin/protoc: not found # can be removed if we remove grpc-tools and assume an existing protoc for dev # i.e. developers would independently intall protoc in order to generate # grpc-web # we install separate from the packages above to avoid a failure noticed on # 2019-11-01 # apk update && apk add protobuf grpc gcompat libc6-compat # ERROR: unsatisfiable constraints: # musl-1.1.20-r4: # breaks: libc6-compat-1.1.24-r0[musl=1.1.24-r0] # satisfies: musl-utils-1.1.20-r4[musl=1.1.20-r4] #RUN apk add libc6-compat Bottom line is that it's awesome to have something lean like Alpine, but that can hardly justify the effort to maintain it. It feels like Linux two decades ago.
- MuffinFlavored 7y ago# libc6-compat needed by outdated grpc-tools # we get # sh: node_modules/grpc-tools/bin/protoc: not found # can be removed if we remove grpc-tools and assume an existing protoc for dev # i.e. developers would independently intall protoc in order to generate # grpc-web # we install separate from the packages above to avoid a failure noticed on # 2019-11-01 # apk update && apk add protobuf grpc gcompat libc6-compat # ERROR: unsatisfiable constraints: # musl-1.1.20-r4: # breaks: libc6-compat-1.1.24-r0[musl=1.1.24-r0] # satisfies: musl-utils-1.1.20-r4[musl=1.1.20-r4] #RUN apk add libc6-compat formatted that for you
- jhalstead 7y agoAnd for mobile readers ;) # libc6-compat needed by outdated grpc-tools # we get # sh: node_modules/grpc-tools/bin/protoc: not found # can be removed if we remove grpc-tools and assume an existing protoc for dev # i.e. developers would independently intall protoc in order to generate # grpc-web # we install separate from the packages above to avoid a failure noticed on # 2019-11-01 # apk update && apk add protobuf grpc gcompat libc6-compat # ERROR: unsatisfiable constraints: # musl-1.1.20-r4: # breaks: libc6-compat-1.1.24-r0[musl=1.1.24-r0] # satisfies: musl-utils-1.1.20-r4[musl=1.1.20-r4] #RUN apk add libc6-compat
- dang 7y agoRelated from 2012: https://news.ycombinator.com/item?id=4058663 https://news.ycombinator.com/item?id=4058663 2014: https://news.ycombinator.com/item?id=7434554 https://news.ycombinator.com/item?id=7434554 2015: https://news.ycombinator.com/item?id=9791709 https://news.ycombinator.com/item?id=9791709 2019: https://news.ycombinator.com/item?id=19284648 https://news.ycombinator.com/item?id=19284648