livebud / bud

The Full-Stack Web Framework for Go
MIT License
5.53k stars 182 forks source link

How to cross compile linux app binary in my macos machine? #367

Open wymli opened 1 year ago

wymli commented 1 year ago

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/bud@v0.2.7/internal/dag/sqlite.go:345:27: undefined: sqlite3.Error
../../.gvm/pkgsets/go1.18/global/pkg/mod/github.com/livebud/bud@v0.2.7/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

matthewmueller commented 1 year ago

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.

derkan commented 8 months ago

What about switching to https://gitlab.com/cznic/sqlite ? No CGO is needed.

matthewmueller commented 7 months ago

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!