-
Notifications
You must be signed in to change notification settings - Fork 459
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
idea: Go bindings **Native** support without CGO #4848
Comments
Source: ebitengine/purego#236 |
Adding some context: We have discussed similiar ideas in the past.
From the ASF perspective, distributing binaries in source form is not permitted. Therefore, we might not include in this repo directly. Perhaps we could set up an additional repository for releases. |
I add a pros: Dynamic Inject distributing binaries. It can be an advantage as current features of bindings can not be controlled by users. |
Confirmed. |
Looking forward to this! |
Ok, I've checked the context, and identified some major blockers:
Well, these are truly obstacles. I've no idea how to resolve them. TBH, I do think it is impossible to support subdirectories in the foreseeable future as the Go team prioritizes things based on their needs. Even if the problem has been resolved, we still have to challenge the binary distribution as Go is not designed to be extended with other languages. IMO, it is inevitable to have multiple root repos for go bindings of various features. As long as these sources are distributed under As for the That is to say: package main
import (
opendal "opendal.apache.org/go"
_ "opendal.some.others/services/s3" // this dynamic inject *.so
) I regret that these guideline-level issues have prevented the implementation of go-binding. |
Wow, I didn't know that was possible! I think we can start with |
Cool. I will take a try next week. |
Thank @yuchanns for make this idea heppen! Would you like to create a new tracking issues for our next plan? |
Added #4892 |
This idea has been advanced at #4892 |
Hello community!
I'd like to introduce you to a native method for supporting Go bindings without CGO.
This capability primarily relies on two libraries: purego and libffi.
To support the passing and returning of structure values, we need to create lightweight Go libffi bindings by wrapping purego, which is already provided by ffi. We can either use it or maintain it ourselves directly.
Then we can call arbitrary C functions using libffi from Go without enabling CGO, which is why I refer to it as Native support!
Here's a POC that demonstrates its functionality with backend
memory
andaliyun_drive
: gopendal.Pros:
CGO
. - It is beneficial to promote opendal to various well-known pure Go basic libraries.libopendal_c.so
- Users can inject custom featured libs under their control.Cons:
libopendal_c.so
. - We can embed it in go files for each platform_suffix file. eg: *_linux.go, *_windows.go,libffi
. - libffi is widely used in many languages and commonly preinstalled on many platforms. You can easily install it with the package manager if not available.What do you think? I look forward to your comments!
The text was updated successfully, but these errors were encountered: