Skip to content

feat: compile llcppg with llgo and inline toolchain#653

Merged
MeteorsLiu merged 13 commits into
xgo-dev:mainfrom
luoliwoshang:llcppg-compile-with-llgo
Feb 14, 2026
Merged

feat: compile llcppg with llgo and inline toolchain#653
MeteorsLiu merged 13 commits into
xgo-dev:mainfrom
luoliwoshang:llcppg-compile-with-llgo

Conversation

@luoliwoshang
Copy link
Copy Markdown
Contributor

Summary

  • move _xtool/llcppsymg/internal/symg to _xtool/symg and update imports
  • move _xtool/llcppsigfetch/internal/parse to _xtool/parse and update imports
  • make cmd/llcppg call symg/parse/convert in-process instead of spawning tool binaries
  • pass parsed AST package (*llcppg.Pkg) directly to convert in cmd/llcppg, avoiding sigfetch JSON/unmarshal hop
  • switch install.sh to install cmd/llcppg via llgo install

Why

  • align llcppg core pipeline with llgo-compilable components
  • remove subprocess pipe handoff in the main path and keep data flow typed in memory

Validation

  • GOCACHE=/tmp/llcppg-gocache go test -vet=off ./cmd/llcppg -run TestNonExistent -count=1

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @luoliwoshang, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the llcppg tool's performance and maintainability by transforming its core symbol generation and signature fetching pipeline from an out-of-process, subprocess-based architecture to an in-process, in-memory data flow. This change streamlines operations, reduces overhead associated with inter-process communication and JSON serialization, and better aligns the tool's components with llgo's compilation model. The refactoring also involves reorganizing internal packages and updating build scripts to reflect these architectural improvements.

Highlights

  • Core Pipeline Refactoring: The llcppg tool's internal workflow has been significantly refactored to integrate symg and parse components directly, eliminating the need to spawn external tool binaries.
  • In-Memory Data Flow: Data transfer between parse and convert stages now occurs directly in memory using parsed AST packages, removing intermediate JSON serialization and deserialization steps.
  • Package Relocation: The internal/symg and internal/parse packages have been moved to top-level _xtool/symg and _xtool/parse directories, respectively, simplifying import paths and promoting reusability.
  • Build Process Update: The install.sh script and README.md instructions have been updated to use llgo install for cmd/llcppg and cmd/gogensig, aligning with the llgo-compilable components.
  • LLGo Version Update: The default LLGo version in GitHub Actions has been updated to v0.12.14, and the download source temporarily points to a fork.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .github/actions/setup-llcppg/action.yml
    • Updated the default LLGo version to "v0.12.14".
  • .github/actions/setup-llcppg/download-llgo.sh
    • Modified the LLGo download URL to use a specific fork.
  • README.md
    • Updated installation instructions for gogensig and llcppg to use llgo install.
  • _xtool/llcppsigfetch/internal/parse/dump.go
    • Renamed to _xtool/parse/dump.go.
  • _xtool/llcppsigfetch/internal/parse/parse.go
    • Renamed to _xtool/parse/parse.go.
  • _xtool/llcppsigfetch/internal/parse/parse_test.go
    • Renamed to _xtool/parse/parse_test.go and updated internal import.
  • _xtool/llcppsigfetch/internal/parse/testdata/macroexpan/expect.json
    • Renamed to _xtool/parse/testdata/macroexpan/expect.json.
  • _xtool/llcppsigfetch/internal/parse/testdata/macroexpan/hfile/def.h
    • Renamed to _xtool/parse/testdata/macroexpan/hfile/def.h.
  • _xtool/llcppsigfetch/internal/parse/testdata/macroexpan/hfile/ref.h
    • Renamed to _xtool/parse/testdata/macroexpan/hfile/ref.h.
  • _xtool/llcppsigfetch/internal/parse/testdata/sysinc/hfile/inc.h
    • Renamed to _xtool/parse/testdata/sysinc/hfile/inc.h.
  • _xtool/llcppsigfetch/internal/parse/testdata/sysinc/hfile/sys.h
    • Renamed to _xtool/parse/testdata/sysinc/hfile/sys.h.
  • _xtool/llcppsigfetch/llcppsigfetch.go
    • Updated the import path for the parse package.
  • _xtool/llcppsymg/internal/symg/lib.go
    • Renamed to _xtool/symg/lib.go and added ModeDynamic and ModeStatic constants.
  • _xtool/llcppsymg/internal/symg/lib_test.go
    • Renamed to _xtool/symg/lib_test.go and updated internal import.
  • _xtool/llcppsymg/internal/symg/parse.go
    • Renamed to _xtool/symg/parse.go.
  • _xtool/llcppsymg/internal/symg/symg.go
    • Renamed to _xtool/symg/symg.go.
  • _xtool/llcppsymg/internal/symg/symg_test.go
    • Renamed to _xtool/symg/symg_test.go and updated internal import.
  • _xtool/llcppsymg/internal/symg/testdata/c/c.c
    • Renamed to _xtool/symg/testdata/c/c.c.
  • _xtool/llcppsymg/internal/symg/testdata/c/c.h
    • Renamed to _xtool/symg/testdata/c/c.h.
  • _xtool/llcppsymg/internal/symg/testdata/c/expect.json
    • Renamed to _xtool/symg/testdata/c/expect.json.
  • _xtool/llcppsymg/internal/symg/testdata/c/llcppg.cfg
    • Renamed to _xtool/symg/testdata/c/llcppg.cfg.
  • _xtool/llcppsymg/internal/symg/testdata/cjson/cJSON.c
    • Renamed to _xtool/symg/testdata/cjson/cJSON.c.
  • _xtool/llcppsymg/internal/symg/testdata/cjson/cJSON.h
    • Renamed to _xtool/symg/testdata/cjson/cJSON.h.
  • _xtool/llcppsymg/internal/symg/testdata/cjson/cJSON_Utils.h
    • Renamed to _xtool/symg/testdata/cjson/cJSON_Utils.h.
  • _xtool/llcppsymg/internal/symg/testdata/cjson/expect.json
    • Renamed to _xtool/symg/testdata/cjson/expect.json.
  • _xtool/llcppsymg/internal/symg/testdata/cjson/llcppg.cfg
    • Renamed to _xtool/symg/testdata/cjson/llcppg.cfg.
  • _xtool/llcppsymg/internal/symg/testdata/cpp/cpp.cpp
    • Renamed to _xtool/symg/testdata/cpp/cpp.cpp.
  • _xtool/llcppsymg/internal/symg/testdata/cpp/cpp.h
    • Renamed to _xtool/symg/testdata/cpp/cpp.h.
  • _xtool/llcppsymg/internal/symg/testdata/cpp/expect.json
    • Renamed to _xtool/symg/testdata/cpp/expect.json.
  • _xtool/llcppsymg/internal/symg/testdata/cpp/llcppg.cfg
    • Renamed to _xtool/symg/testdata/cpp/llcppg.cfg.
  • _xtool/llcppsymg/internal/symg/testdata/gpgerror/expect.json
    • Renamed to _xtool/symg/testdata/gpgerror/expect.json.
  • _xtool/llcppsymg/internal/symg/testdata/gpgerror/gpg-error.h
    • Renamed to _xtool/symg/testdata/gpgerror/gpg-error.h.
  • _xtool/llcppsymg/internal/symg/testdata/gpgerror/gpgerror.c
    • Renamed to _xtool/symg/testdata/gpgerror/gpgerror.c.
  • _xtool/llcppsymg/internal/symg/testdata/gpgerror/gpgrt.h
    • Renamed to _xtool/symg/testdata/gpgerror/gpgrt.h.
  • _xtool/llcppsymg/internal/symg/testdata/gpgerror/llcppg.cfg
    • Renamed to _xtool/symg/testdata/gpgerror/llcppg.cfg.
  • _xtool/llcppsymg/internal/symg/testdata/include/expect.json
    • Renamed to _xtool/symg/testdata/include/expect.json.
  • _xtool/llcppsymg/internal/symg/testdata/include/llcppg.cfg
    • Renamed to _xtool/symg/testdata/include/llcppg.cfg.
  • _xtool/llcppsymg/internal/symg/testdata/include/src/conf.h
    • Renamed to _xtool/symg/testdata/include/src/conf.h.
  • _xtool/llcppsymg/internal/symg/testdata/include/src/core/core.h
    • Renamed to _xtool/symg/testdata/include/src/core/core.h.
  • _xtool/llcppsymg/internal/symg/testdata/include/temp.c
    • Renamed to _xtool/symg/testdata/include/temp.c.
  • _xtool/llcppsymg/internal/symg/testdata/include/temp.h
    • Renamed to _xtool/symg/testdata/include/temp.h.
  • _xtool/llcppsymg/internal/symg/testdata/inireader/INIReader.cpp
    • Renamed to _xtool/symg/testdata/inireader/INIReader.cpp.
  • _xtool/llcppsymg/internal/symg/testdata/inireader/INIReader.h
    • Renamed to _xtool/symg/testdata/inireader/INIReader.h.
  • _xtool/llcppsymg/internal/symg/testdata/inireader/expect.json
    • Renamed to _xtool/symg/testdata/inireader/expect.json.
  • _xtool/llcppsymg/internal/symg/testdata/inireader/llcppg.cfg
    • Renamed to _xtool/symg/testdata/inireader/llcppg.cfg.
  • _xtool/llcppsymg/internal/symg/testdata/isl/expect.json
    • Renamed to _xtool/symg/testdata/isl/expect.json.
  • _xtool/llcppsymg/internal/symg/testdata/isl/isl.c
    • Renamed to _xtool/symg/testdata/isl/isl.c.
  • _xtool/llcppsymg/internal/symg/testdata/isl/isl/ctx.h
    • Renamed to _xtool/symg/testdata/isl/isl/ctx.h.
  • _xtool/llcppsymg/internal/symg/testdata/isl/isl/polynomial.h
    • Renamed to _xtool/symg/testdata/isl/isl/polynomial.h.
  • _xtool/llcppsymg/internal/symg/testdata/isl/isl/polynomial_type.h
    • Renamed to _xtool/symg/testdata/isl/isl/polynomial_type.h.
  • _xtool/llcppsymg/internal/symg/testdata/isl/llcppg.cfg
    • Renamed to _xtool/symg/testdata/isl/llcppg.cfg.
  • _xtool/llcppsymg/internal/symg/testdata/lua/expect.json
    • Renamed to _xtool/symg/testdata/lua/expect.json.
  • _xtool/llcppsymg/internal/symg/testdata/lua/llcppg.cfg
    • Renamed to _xtool/symg/testdata/lua/llcppg.cfg.
  • _xtool/llcppsymg/internal/symg/testdata/lua/lua.c
    • Renamed to _xtool/symg/testdata/lua/lua.c.
  • _xtool/llcppsymg/internal/symg/testdata/lua/lua.h
    • Renamed to _xtool/symg/testdata/lua/lua.h.
  • _xtool/llcppsymg/llcppsymg.go
    • Updated the import path for the symg package.
    • Removed the internal/symbol import.
    • Adjusted libMode assignments to use symgtask.ModeDynamic and symgtask.ModeStatic.
  • cmd/llcppg/llcppg.go
    • Removed bytes and io imports.
    • Added path/filepath, gogen, parse, symgtask, ast, cl, ncimpl, gowrite, and errors imports.
    • Refactored llcppsymg, llcppsigfetch, and gogensig functions to perform operations in-process.
    • Removed CommandOptions struct and command helper function.
    • Implemented prepareEnv, writePkg, and runCommand helper functions.
    • Updated the do function to call the refactored in-process functions.
  • install.sh
    • Updated gogensig and llcppg installation commands to use llgo install.
    • Added echo statements to indicate installation progress for various tools.
Ignored Files
  • Ignored by pattern: .github/workflows/** (3)
    • .github/workflows/end2end.yml
    • .github/workflows/gentest.yml
    • .github/workflows/go.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors llcppg to inline its sub-tools into a single process, aiming to improve performance and maintainability by removing the overhead of spawning separate processes and inter-process communication. However, a security audit identified two medium-severity vulnerabilities in cmd/llcppg/llcppg.go: insecure file permissions when writing the symbol table and a potential path traversal vulnerability when determining the output directory from the configuration file. These issues need to be addressed to enhance the tool's robustness against malicious configurations and local attacks. Additionally, there are a few suggestions to improve error handling and overall file permissions, which will make the tool more robust and user-friendly.

Comment thread cmd/llcppg/llcppg.go
Comment thread cmd/llcppg/llcppg.go
Comment thread cmd/llcppg/llcppg.go
Comment thread .github/actions/setup-llcppg/download-llgo.sh
Comment thread cmd/llcppg/llcppg.go
@fennoai
Copy link
Copy Markdown
Contributor

fennoai Bot commented Feb 14, 2026

The architectural change from subprocess-based execution to in-process library calls is a solid improvement -- it eliminates serialization overhead and simplifies the data flow. The package restructuring (symg, parse promoted from internal) is the correct prerequisite for this.

Key issues to address: symbol table file written with 0777 permissions, potential nil dereference if parse.Do succeeds without invoking the Exec callback, and the fork download URL should track an issue for reversion.

Comment thread cmd/llcppg/llcppg.go
Comment thread cmd/llcppg/llcppg.go
Comment thread cmd/llcppg/llcppg.go
Comment thread .github/actions/setup-llcppg/download-llgo.sh
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 14, 2026

Codecov Report

❌ Patch coverage is 0% with 96 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.32%. Comparing base (df16664) to head (d53e6fa).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/llcppg/llcppg.go 0.00% 96 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #653      +/-   ##
==========================================
- Coverage   85.16%   83.32%   -1.84%     
==========================================
  Files          28       28              
  Lines        2447     2501      +54     
==========================================
  Hits         2084     2084              
- Misses        315      369      +54     
  Partials       48       48              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

FILENAME="llgo${VERSION_NUMBER}.${OS}-${ARCH}.tar.gz"
URL="https://github.com/goplus/llgo/releases/download/${VERSION}/${FILENAME}"
# Use fork releases while upstream release is not available yet.
URL="https://github.com/luoliwoshang/llgo/releases/download/${VERSION}/${FILENAME}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: This should be replaced with latest version when llgo release.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xgopilot actually because the goplus/llgo with v0.12.1 have lots problem for compile goplus/gogen,and goplus/main branch is fix this problem,but the goplus/llgo is not release the latest code,so we current use the fork luoliwoshang/llgo to use the bug fix version llgo,when llgo release we will replace the repo,make a better comment !

and use this version
https://github.com/luoliwoshang/llgo/releases/tag/v0.12.2-preview

will more like the next version for llgo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xgopilot actually because the goplus/llgo with v0.12.1 have lots problem for compile goplus/gogen,and goplus/main branch is fix this problem,but the goplus/llgo is not release the latest code,so we current use the fork luoliwoshang/llgo to use the bug fix version llgo,when llgo release we will replace the repo,make a better comment !

and use this version
https://github.com/luoliwoshang/llgo/releases/tag/v0.12.2-preview

will more like the next version for llgo

Copy link
Copy Markdown
Contributor

@fennoai fennoai Bot Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the context! That makes sense — upstream goplus/llgo v0.12.1 has compilation issues with goplus/gogen, and the fix is on main but not yet released.

A few suggestions for the comment to capture this context:

# Temporary: use fork releases because goplus/llgo v0.12.1 has gogen
# compilation bugs fixed on main but not yet released.
# Revert to github.com/goplus/llgo once v0.12.2+ is available.
URL="https://github.com/luoliwoshang/llgo/releases/download/${VERSION}/${FILENAME}"

Also, if v0.12.2-preview is the intended tag, consider updating the default version in action.yml from v0.12.14 to v0.12.2-preview to better signal this is a pre-release.

Copy link
Copy Markdown
Contributor

@fennoai fennoai Bot Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the fork comment in download-llgo.sh and switched LLGo version to v0.12.2-preview across all CI files. Changes are ready but need push access.

Changes Made

  • download-llgo.sh: Improved comment to explain why the fork is used (goplus/llgo v0.12.1 has gogen compilation bugs, fix on main but unreleased) with a TODO to revert once v0.12.2+ is officially released
  • action.yml: Default version v0.12.14v0.12.2-preview
  • end2end.yml, gentest.yml, go.yml: Matrix version v0.12.14v0.12.2-preview

Permission Required

Hi @luoliwoshang! I've prepared your changes but need permission to push to your fork.

View Details & Solution

Target: luoliwoshang/llcppg (fork)

Push blocked:

remote: Permission to luoliwoshang/llcppg.git denied to xgopilot[bot].
fatal: unable to access 'https://github.com/luoliwoshang/llcppg.git/': The requested URL returned error: 403

Recommended Solution: Install GitHub App

  1. Install xgopilot
  2. Select repository: luoliwoshang/llcppg
  3. Click "Install"
  4. Return here and comment to retry

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xgopilot now i give you permission , try to give the PR!

Copy link
Copy Markdown
Contributor

@fennoai fennoai Bot Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Pushed the changes and created a PR in your fork:

PR: luoliwoshang#8

Changes

  • download-llgo.sh: Improved comment explaining the fork usage (goplus/llgo v0.12.1 gogen compilation bugs, fix on main but unreleased) with a TODO to revert once v0.12.2+ is officially released
  • action.yml + workflow files: Version v0.12.14v0.12.2-preview

Please merge that PR into your llcppg-compile-with-llgo branch to include these changes in this PR.

Comment on lines +32 to +36
if err := tmpFile.Close(); err != nil {
_ = os.Remove(tmpName)
return err
}
defer os.Remove(tmpName)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: It seems like AI defense code, just defer os.Remove(tmpName) should work. However, it's fine to keep it.

Comment thread cmd/llcppg/llcppg.go
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: this will break out current architecture, however, refactor is in deed for llcppg. So i think it's not so important for now to consider a lot about it?

Copy link
Copy Markdown
Contributor

@MeteorsLiu MeteorsLiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, but architecture is a huge problem for now, becasue we combined all these modules now instead of llcppgsymg + llcppsigfetch + gogensig. However, it's acceptable for now.

@MeteorsLiu MeteorsLiu merged commit 136f197 into xgo-dev:main Feb 14, 2026
10 of 12 checks passed
@fennoai fennoai Bot mentioned this pull request Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants