d2layout-dagre: Compile fully statically with musl libc
See https://honnef.co/posts/2015/06/statically_compiled_go_programs__always__even_with_cgo__using_musl/
Another possible approach is to compile with qemu. I believe this is how code-server now handles cross compilation.
On nvm, qemu would help us avoid needing to maintain a builder of each architecture and OS but we'd still need one of each OS at the least. I don't think there's any easy way to cross compile for a different platform apart from using zig which I'll need to research further.
Relevant: https://github.com/rogchap/v8go/issues/170
https://xeiaso.net/blog/carcinization-golang
we could also compile v8 to wasm and execute in a pure go wasm runtime instead. then no cgo at all!
This currently fully breaks build on musl, including of the d2 command itself (not just d2plugin-dagre).
Is there no easy way to cut this out and require e.g. a library to be present on the system, or something else like that?
d2 imports d2plugin-dagre by default. But the d2 command itself is pure Go. You can use --tags nodagre to build without dagre. See https://github.com/terrastruct/d2/blob/f64ed4981e911ef54d0b9ff6c204fc4c591b06fd/d2plugin/plugin_dagre.go#L1
or CGO_ENABLED=0 go build ...
The only pure Go layout engine we currently have is TALA which requires a license. See https://github.com/terrastruct/tala
https://github.com/rogchap/v8go/pull/350
@alixander damn nice how did you know that someone opened a PR fixing it?
i brieflyz considering calling React from Go for server side renders (probably won't go with that), and the potential extra reliance on v8go made me investigate its activity.
Can also try https://github.com/dop251/goja?
Also means it will be far easier to do #136 when there's no cgo involved.
Ok maybe not far given the dagre/elk javascript can just run in the browser lol.
omg what if we just embedded the node binary? code-server used to do this thing where they embedded the node binary/js into a single binary. they probably still do. we could do it too.
we can close this now that goja's worked.