llgo  by goplus

Go compiler based on LLVM for better C/Python ecosystem integration

created 1 year ago
529 stars

Top 60.6% on sourcepulse

GitHubView on GitHub
Project Summary

LLGo is a Go compiler that leverages LLVM to enable seamless integration with the C ecosystem, including Python. It targets developers looking to expand Go's capabilities into areas like game development, AI, data science, WebAssembly, and embedded systems by providing a unified environment for Go, C, and Python.

How It Works

LLGo achieves C and Python interoperability through their respective Application Binary Interfaces (ABIs). It allows direct import and usage of C/C++ standard libraries and Python libraries by translating Go code into LLVM Intermediate Representation (IR). This approach facilitates calling C functions with callbacks and interacting with Python objects and functions directly within Go code.

Quick Start & Requirements

  • Install: Run curl https://raw.githubusercontent.com/goplus/llgo/refs/heads/main/install.sh | bash ./install.sh after meeting prerequisites.
  • Prerequisites: Go 1.21+, LLVM 18, Clang 18, LLD 18, pkg-config 0.29+, bdwgc/libgc 8.0+, OpenSSL 3.0+, zlib 1.2+. Python 3.12+ is optional for Python integration. Specific installation commands are provided for macOS, Debian/Ubuntu, and Alpine Linux.
  • Demo Execution: Navigate to demo directories (e.g., _demo/hello) and run llgo run ..
  • Documentation: https://github.com/goplus/llgo

Highlighted Details

  • Supports all Go syntax, including cgo.
  • Integrates with C libraries like raylib, sqlite, llama2-c, and openssl.
  • Enables Python library usage, including numpy, pandas, and torch.
  • Offers garbage collection via bdwgc by default, with an option to disable it (-tags nogc).

Maintenance & Community

The project is part of the Go+ project. Development tools like pydump, pysigfetch, and llpyg are available for library integration.

Licensing & Compatibility

The repository does not explicitly state a license in the README. Compatibility for commercial use or closed-source linking is not specified.

Limitations & Caveats

The README notes that LLGo defer statements do not support usage within loops, which is described as a feature rather than a bug. Some Go standard library packages (math/big, sync, syscall, runtime, os, fmt, reflect, time, hash/crc32, crypto/sha512, crypto/hmac, crypto/rand, crypto/subtle) are only partially supported. Manual import of C libraries is currently required, though automation is planned.

Health Check
Last commit

1 day ago

Responsiveness

1 day

Pull Requests (30d)
15
Issues (30d)
6
Star History
52 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.