Open edieYoung opened 2 years ago
@edieYoung this would be a great contribution to make to the rules_go project! I believe you're the first person to have this need. We do not currently have support, but I would be interested in learning more. How can I help you in the process of adding it as an option to rules_go?
Hey! I'm also interested in adding support to tinygo in rules_go. We are using it to build Envoy Wasm plugins (for Istio).
Our build command looks like:
tinygo build -o plugin.wasm -scheduler=none -target=wasi main.go
The tinygo
compiler is compatible with go.mod
and dependency management.
The -target=wasi
flag indicates for which target are we building the plugin. If you download the tinygo sdk you will find a targets
directory with multiple .json
definitions, one for each target.
I would say that rules_go
could be compatible with tinygo
by using go_download_sdk
and generating a custom tarball with the same structure as the go
sdk (renaming tinigo
binary as go
, etc). I'm not sure what would happen with the targets
.
@achew22 what is your recommendation to add support for tinygo
in rules_go
?
I'm not aware of anyone who is using the tinygo compiler at this point in time so firstly this would have to be implemented by someone with some experience in that ecosystem.
That said, the first thing to do would be to build a go_toolchain
which would then probably use go_wrap_sdk
with a directory structure emulating the standard go tooling package structure. Then you would register that toolchain in the project and I think thing would mostly just work.
WRT targeting wasm
, there might need to be some additional work there, but I would start by getting it to compile binaries compatible with your computer.
The file coin virtual machine and wasm cloud both require tiny go compiled programs. We are in the process of supporting both those environments. Therefore, we are very interested in tiny go as a build target for bazel.
We are going to attempt this but are not very comfortable with it. Going to be a challenge…
However, the work is worth the challenge considering the doors it opens without needing to rewrite our code base in r.
Doors opened:
All things we are very interested to explore.
For further explore on this topics... this article explain very well... in various steps... https://jayconrod.com/posts/106/writing-bazel-rules--simple-binary-rule
I finally got around to making my attempt at a rules_tinygo
public: https://github.com/ptxmac/rules_tinygo
I'm no bazel expert, and it only does the absolute minimum I need: compile go to WASI on darwin/linux/amd/arm
Hi there, we need to use tinygo for building the WASM module in envoy since standard Go complier doesn't support WASI(WebAssembly System Interface), see details at here, so we wonder if there is a plan or effort for bazel rules_go to support tinygo?