A Go compiler built on LLVM that targets microcontrollers, WebAssembly (WASM/WASI), and command-line tools.
xgo-dev/llgo
A Go compiler built on LLVM that lets Go code call C libraries directly and import Python libraries.
- Stars
- 845
- Forks
- 53
- Open issues
- 197
- Last commit
- 2 hours ago
What is it?
LLGo is a Go compiler based on LLVM, aimed at integrating Go with the C ABI ecosystem, including C/C++, Python, and other languages that expose C-compatible interfaces. It is compatible with Go at the source-code level and is a subproject of the XGo project.
Instead of relying on cgo, LLGo binds Go declarations directly to C symbols using go:linkname, so calls into C compile to native calls without a Go-to-C stack or scheduler transition. It ships bindings for many C libraries such as SQLite, zlib, libuv, OpenSSL and raylib, and for Python packages such as NumPy and PyTorch through its llpyg tooling. Its runtime uses native goroutines mapped to OS threads and the BDWGC conservative garbage collector by default.
The compiler supports Linux, macOS and Windows natively, plus WebAssembly and embedded targets. It requires LLVM 22, Clang 22 and LLD to build and run programs.
Key features
- 01Calls C functions directly through go:linkname without cgo overhead.
- 02Imports Python libraries such as NumPy and PyTorch via generated bindings.
- 03Compiles Go source compatible with Go 1.20+ and supports cgo.
- 04Provides C/C++ standard library bindings and bindings for many common C libraries.
- 05Targets native Linux, macOS, Windows, WebAssembly and embedded boards.
Use cases
- Calling existing C libraries such as SQLite or raylib from Go code.
- Using Python numerical or data science libraries from Go programs.
- Building Go programs for WebAssembly or embedded microcontroller boards.
- Experimenting with compiling Go through LLVM for C ecosystem interop.
Quick start
- 1
Install llgo by following the How to install section of the README
- 2
Run a demo, such as _demo/c/hello, from its directory
llgo run .
Things to know
- Other targets such as WebAssembly and embedded may not provide every OS service or runtime behavior.
- Third-party Python libraries such as pandas and PyTorch must be installed separately.
- C and C++ bindings are maintained by hand, so coverage of libraries is limited.
- Forwarding C variadic calls through promoted-method wrappers is supported only on hosted native targets.
Topics
FAQ
- What is llgo?
- A Go compiler built on LLVM that lets Go code call C libraries directly and import Python libraries. LLGo is a Go compiler based on LLVM, aimed at integrating Go with the C ABI ecosystem, including C/C++, Python, and other languages that expose C-compatible interfaces. It is compatible with Go at the source-code level and is a subproject of the XGo project.
- Is llgo free to use? What license does it have?
- llgo is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is llgo still maintained?
- Actively maintained. The last commit to llgo was on Oct 22, 2026.
- What can I use llgo for?
- Calling existing C libraries such as SQLite or raylib from Go code. Using Python numerical or data science libraries from Go programs. Building Go programs for WebAssembly or embedded microcontroller boards. Experimenting with compiling Go through LLVM for C ecosystem interop.
- How do I install llgo?
- Install llgo by following the How to install section of the README Run a demo, such as _demo/c/hello, from its directory: llgo run .
- Where can I get llgo?
- The source code and installation instructions are on GitHub: https://github.com/xgo-dev/llgo
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A compiler toolchain that turns C and C++ code into WebAssembly so it can run in browsers, Node.js and other Wasm runtimes.
A modular collection of compiler and toolchain technologies, including the LLVM core, the Clang C/C++ frontend, libc++ and the LLD linker.
An open-source ESP32 emulator in Rust that runs real firmware on your computer or in a browser, without hardware.
The Kotlin programming language and its compiler, standard library, and build tooling, developed by JetBrains for multiplatform development.
A TypeScript-like language and compiler that turns a typed subset of TypeScript into WebAssembly modules.