Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cgo #870

Merged
merged 2 commits into from
Oct 11, 2022
Merged

Remove cgo #870

merged 2 commits into from
Oct 11, 2022

Conversation

simonwo
Copy link
Contributor

@simonwo simonwo commented Oct 11, 2022

So long CGO, we hardly knew ye.

We switched to using CGO in 3bf5e0. Since then we have seen a number of issues with it:

  • Builds have to be done on each platform rather than producing all of the builds from one box, because cross-compilation is badly supported between different OSes for C programs.
  • It produces dynamic builds by default and we would rather have static builds as they are easier to distribute.
  • It requires anyone using Bacalhau as a library to also build with CGO.

To do this, we've replaced our WASM engine with one that doesn't require CGO. It has some missing features compared to our existing implementation, but none that we are actually using. It is also better integrated with Go and should actually provide a more solid foundation from which to build.

We have previously been using `wasmtime-go` to run our WASM executor
which requires us to build using CGO for all platforms. This has
proven to be problematic and has resulted in many yak shaves. There
is also the downside that any project that uses bacalhau as a library
now also has to use CGO.

There is in fact a Go-only wasm engine called `wazero`. This commit
moves us to using wazero instead. ����This is largely a painless process
as the old and new libraries share a very similar API.
So long CGO, we hardly knew ye.

We switched to using CGO in 3bf5e0. Since then we have seen a number
of issues with it:

- Builds have to be done on each platform rather than producing all of
  the builds from one box, because cross-compilation is badly supported
  between different OSes for C programs.
- It produces dynamic builds by default and we would rather have static
  builds as they are easier to distribute.
- It requires anyone using Bacalhau as a library to also build with CGO.

Now that we have replaced our WASM engine to no longer require CGO, we
can undo the CGO support and go back to building just with pure Go.
@simonwo simonwo merged commit 07c7144 into main Oct 11, 2022
@simonwo simonwo deleted the remove-cgo branch October 11, 2022 16:45
@wdbaruni wdbaruni restored the remove-cgo branch October 11, 2022 18:33
@wdbaruni wdbaruni deleted the remove-cgo branch October 12, 2022 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants