static builds even with cgo and xorg deps #7

Open
opened 2022-06-20 00:44:41 +02:00 by wanderer · 1 comment
Owner

...would be nice as it would allow a single (statically linked) binary to be built/shipped (potentially).

approaches:

  • by hand - figure out (wip) the CFLAGS and LDFLAGS to pass to the pre-build phase (nix)
  • with help using zig - this has caveats (works well for "simple" packages such as go-sqlite mentioned in the post but not so much for this one)
...would be nice as it would allow a single (statically linked) binary to be built/shipped (potentially). approaches: * by hand - figure out (wip) the `CFLAGS` and `LDFLAGS` to pass to the pre-build phase (`nix`) * with help [using](https://dev.to/kristoff/zig-makes-go-cross-compilation-just-work-29ho) [`zig`](https://zig.news/kristoff/building-sqlite-with-cgo-for-every-os-4cic) - this has caveats (works well for "simple" packages such as `go-sqlite` mentioned in the post but not so much for this one)
wanderer added the
enhancement
help wanted
pertains/nix
pertains/go
labels 2022-06-20 00:44:41 +02:00
Author
Owner

alright, even though there have apparently been attempts to solve this (be it without using Nix) even during the past few months, it looks like this issue cannot be solved using Zig or any other way to cross-compile because GLFW (and consequently go-glfw, which is Fyne's hard dependency) does not support (or endorse) static linking, at least with the current state of affairs.

That not only means we're stuck with CGO, it also means we can only link dynamically, which is even worse.

Any further insights of any random internet passer-by would, of course, be appreciated.

alright, even though there have apparently been [attempts](http://lucor.dev/post/cross-compile-golang-fyne-project-using-zig/) to solve this (be it without using Nix) even during the past few months, it looks like this issue cannot be solved using Zig or any other way to cross-compile [because GLFW (and consequently `go-glfw`, which is Fyne's hard dependency) does not support (or endorse) static linking](https://github.com/go-gl/glfw/issues/263#issuecomment-583867615), at least with the current [state of affairs](https://github.com/go-gl/glfw/issues/263). That not only means we're stuck with CGO, it also means we can only link dynamically, which is even worse. Any further insights of any random internet passer-by would, of course, be appreciated.
wanderer added the
question
label 2022-07-07 21:51:37 +02:00
Sign in to join this conversation.
No description provided.