News for hackers. Stuff that matters.
Re:Mugo, a toy compiler for a subset of Go that can compile ... by chrfrasco on Monday April 12, 2021 @07:17AM (#26778118)
This is so cool. I especially loved the Makefile, it's nice to see "bootstrapping" laid out so plainly. I remember finding the concept quite hard to wrap my head around when I was introduced to it. Seeing this would have made it a lot easier to understand!
Re:Mugo, a toy compiler for a subset of Go that can compile ... by dane-pgp on Monday April 12, 2021 @01:31PM (#26782374)
If you like well-documented bootstrap processes, I can recommend this:

https://github.com/fosslinux/live-bootstrap/blob/master/part...

The steps go from a binary seed of a few hundred bytes to (almost) gcc. It is still being actively developed as part of the Bootstrappable Builds project:

https://www.bootstrappable.org/

Re:Mugo, a toy compiler for a subset of Go that can compile ... by pabs3 on Tuesday April 13, 2021 @01:30AM (#26788433)
Re:Mugo, a toy compiler for a subset of Go that can compile ... by chrfrasco on Monday April 12, 2021 @07:23AM (#26778147)
> I wonder if we could reduce binary size with a dead-simple scheduler and GC

For many CLIs I think even a brain-dead bump allocator would work

Re:Mugo, a toy compiler for a subset of Go that can compile ... by Hello71 on Monday April 12, 2021 @08:47AM (#26778769)
musl automatically uses a bump allocator if free is not referenced in the program.
Re:Mugo, a toy compiler for a subset of Go that can compile ... by benhoyt on Monday April 12, 2021 @06:12PM (#26785824)
Interesting. I couldn't find any documentation for how this happens (does it need compiler/linker support to know whether free is used?), but I did find the source code for this __simple_malloc: https://git.musl-libc.org/cgit/musl/tree/src/malloc/lite_mal...
Re:Mugo, a toy compiler for a subset of Go that can compile ... by KMag on Monday April 12, 2021 @01:22PM (#26782239)
That's really cool!

Though, I'm curious... don't a lot of malloc implementations use a bump allocator if a simple fragmentation heuristic is below some limit? Presumably musl down inside malloc() has a static bool (or a static function pointer) it uses to keep track if dlsym() has ever returned the address of free(). How much faster is the musl implementation than an implementation using a simple fragmentation heuristic? Presumably, they're both well-predicted conditional branches (and/or indirect branch targets well predicted by the BTB).

Re:Mugo, a toy compiler for a subset of Go that can compile ... by saagarjha on Thursday April 15, 2021 @05:31AM (#26818192)
Musl's implementation only works for statically linked programs.
Re:Mugo, a toy compiler for a subset of Go that can compile ... by tetha on Monday April 12, 2021 @06:24PM (#26785937)
A programming language professor working on interpreters once said - for short-living processes the most effective and efficient garbage processing might be... not to and terminating the process. The OS will collect all garbage at once very quickly. So why bother time spending being smart?