bud
bud copied to clipboard
How to cross compile linux app binary in my macos machine?
If I run CGO_ENABLED=0 GOOS=linux GOARCH=amd64 bud build
, got an error:
# github.com/livebud/bud/internal/dag
../../.gvm/pkgsets/go1.18/global/pkg/mod/github.com/livebud/[email protected]/internal/dag/sqlite.go:345:27: undefined: sqlite3.Error
../../.gvm/pkgsets/go1.18/global/pkg/mod/github.com/livebud/[email protected]/internal/dag/sqlite.go:349:47: undefined: sqlite3.ErrReadonlyDbMoved
| exit status 2
but run bud build
will build successfully.
❯ bud version bud: 0.2.7 svelte: 3.47.0 react: 18.0.0
This is currently a limitation though thanks for the heads up on sqlite3
. This is a recent addition and worth fixing.
Lurking behind this issue is that Bud's production version embeds V8 so it can perform SSR efficiently. V8 depends on CGO. I plan to provide more options to bring back cross-compilation in the future.
In the meantime to do cross-compilation, I'd suggest running bud build
within a Linux docker. The contributing guide has an example Docker container. You could also go with xgo which is what I use to compile Bud.
What about switching to https://gitlab.com/cznic/sqlite ? No CGO is needed.
What about switching to https://gitlab.com/cznic/sqlite
It's a good idea for SQLite. Unfortunately we'd still have V8 though.
I'm moving away from the CGO dependencies in the next iteration of Bud. Stay tuned!