xushiwei
Joined 11 years ago
Joined 11 years ago
Compatibility is checked against applicable upstream GOROOT/test cases using pinned Go 1.25 and Go 1.26 toolchains.
LLGo is a Go compiler based on LLVM in order to better integrate Go with the C ecosystem, including Python and JavaScript. It's a subproject of the XGo project.
LLGo aims to expand the boundaries of Go/XGo, providing limitless possibilities such as:
* Game development * AI and data science * WebAssembly * Embedded development * ...
How can these be achieved?
LLGo := Go * C ecosystem
LLGo is compatible with the C ecosystem through the C Application Binary Interface (ABI), while LLGo is compatible with Go at the source-code level. The C ecosystem includes languages that expose C-compatible interfaces (e.g. C/C++, Python, JavaScript, Objective-C, and Swift).
Now you can import a Python library in LLGo. For example:
package main
import ( "github.com/goplus/llgo/c" "github.com/goplus/llgo/py" "github.com/goplus/llgo/py/math" )
func main() { x := math.Sqrt(py.Float(2)) c.Printf(c.Str("sqrt(2) = %f\n"), x.Float64()) }
Here, We call py.Float(2) to create a Python number 2, and pass it to Python’s math.sqrt to get x. Then use x.Float64() to convert x to Go's float64 type, and print the value through C printf.
Let's look at a slightly more complex example. For example, we use numpy to calculate:
package main
import ( "github.com/goplus/llgo/c" "github.com/goplus/llgo/py" "github.com/goplus/llgo/py/numpy" )
func main() { a := py.List( py.List(1.0, 2.0, 3.0), py.List(4.0, 5.0, 6.0), py.List(7.0, 8.0, 9.0), ) b := py.List( py.List(9.0, 8.0, 7.0), py.List(6.0, 5.0, 4.0), py.List(3.0, 2.0, 1.0), ) x := numpy.Add(a, b) c.Printf(c.Str("a+b = %s\n"), x.Str().CStr()) }
Here we define two 3x3 matrices a and b, add them to get x, and then print the result.
- Compatible with the Go language
- Script-like style
- Supports bytecode backend or generating Go code
- All Go packages can be imported by Go+
- All Go+ packages can be imported by Go
WASI networking should work, and stdlib should be fully supported since that's our compat target. Binary size vs. stdlib coverage is likely a tradeoff, similar to TinyGo — haven't benchmarked it rigorously yet though.
Next release (~1–1.5 weeks) will bring full wasm/wasi support with a test report, including size numbers. Will post back here once it's out.