From 3e59ad332562e2b7849b71f1ca2025d7418a96fd Mon Sep 17 00:00:00 2001 From: xgopilot Date: Tue, 30 Dec 2025 06:19:07 +0000 Subject: [PATCH] feat: use prebuilt llgo v0.12.0 and keep LLVM for clang This commit updates the CI configuration to use prebuilt llgo v0.12.0 releases instead of building from source, while maintaining LLVM dependency for clang access. Changes: - Add download-llgo.sh script to fetch prebuilt llgo releases - Update action.yml to use download script instead of source checkout - Keep LLVM/clang dependency as requested in issue #609 - Remove unnecessary LLVM dev packages (llvm-dev, libclang-dev, lld, etc.) - Retain only clang-19 for compilation needs - Add verification step for llgo and clang installation Benefits: - Faster CI builds (no source compilation) - Simpler dependency management - More reliable with official releases - Reduced complexity while keeping clang access Related: #609, #590 Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com> --- .github/actions/setup-llcppg/action.yml | 26 ++++---- .github/actions/setup-llcppg/download-llgo.sh | 65 +++++++++++++++++++ 2 files changed, 78 insertions(+), 13 deletions(-) create mode 100755 .github/actions/setup-llcppg/download-llgo.sh diff --git a/.github/actions/setup-llcppg/action.yml b/.github/actions/setup-llcppg/action.yml index 870aad4a..3d4a31b6 100644 --- a/.github/actions/setup-llcppg/action.yml +++ b/.github/actions/setup-llcppg/action.yml @@ -1,5 +1,5 @@ name: "Setup llcppg" -description: "Install dependencies, set up Go, set up LLGo, install llcppg" +description: "Install dependencies, set up Go, download LLGo release, install llcppg" inputs: go: description: "Go version to install" @@ -8,18 +8,12 @@ inputs: description: "LLVM version to install (e.g. 18)" default: "19" llgo: - description: "LLGo git ref or tag" - default: "e4218f90d7926d31c1ffae3965a4e36228d38fd2" + description: "LLGo version to download (e.g. v0.12.0)" + default: "v0.12.0" runs: using: "composite" steps: - uses: actions/checkout@v4 - - name: Checkout LLGo - uses: actions/checkout@v4 - with: - repository: 'goplus/llgo' - path: '.llgo' - ref: ${{inputs.llgo}} - name: Set up Go uses: actions/setup-go@v4 with: @@ -41,15 +35,21 @@ runs: echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${{inputs.llvm}} main" | sudo tee /etc/apt/sources.list.d/llvm.list wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - sudo apt-get update - sudo apt-get install -y llvm-${{inputs.llvm}}-dev clang-${{inputs.llvm}} libclang-${{inputs.llvm}}-dev lld-${{inputs.llvm}} libunwind-${{inputs.llvm}}-dev libc++-${{inputs.llvm}}-dev pkg-config libgc-dev libssl-dev zlib1g-dev libffi-dev libuv1-dev + sudo apt-get install -y clang-${{inputs.llvm}} pkg-config libgc-dev libssl-dev zlib1g-dev libffi-dev libuv1-dev echo "/usr/lib/llvm-${{inputs.llvm}}/bin" >> $GITHUB_PATH - - name: Install LLGo + - name: Download LLGo release shell: bash - working-directory: .llgo run: | - go install -v ./cmd/llgo/... + bash .github/actions/setup-llcppg/download-llgo.sh ${{inputs.llgo}} .llgo + echo "$GITHUB_WORKSPACE/.llgo/bin" >> $GITHUB_PATH export LLGO_ROOT=$GITHUB_WORKSPACE/.llgo echo "LLGO_ROOT=$LLGO_ROOT" >> $GITHUB_ENV + - name: Verify LLGo installation + shell: bash + run: | + echo "LLGO_ROOT: $LLGO_ROOT" + llgo version + clang --version - name: Build shell: bash run: go build -v ./... diff --git a/.github/actions/setup-llcppg/download-llgo.sh b/.github/actions/setup-llcppg/download-llgo.sh new file mode 100755 index 00000000..3c05febc --- /dev/null +++ b/.github/actions/setup-llcppg/download-llgo.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# Script to download and extract LLGo release +# Usage: ./download-llgo.sh +# Example: ./download-llgo.sh v0.12.0 ./llgo + +set -e + +VERSION=$1 +INSTALL_DIR=$2 + +if [ -z "$VERSION" ] || [ -z "$INSTALL_DIR" ]; then + echo "Usage: $0 " + echo "Example: $0 v0.12.0 ./llgo" + exit 1 +fi + +# Detect OS and architecture +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +ARCH=$(uname -m) + +# Map architecture names +case $ARCH in + x86_64) + ARCH="amd64" + ;; + aarch64|arm64) + ARCH="arm64" + ;; + *) + echo "Unsupported architecture: $ARCH" + exit 1 + ;; +esac + +# Construct download URL +# Format: llgo{version}.{os}-{arch}.tar.gz +# Example: llgo0.12.0.darwin-arm64.tar.gz or llgo0.12.0.linux-amd64.tar.gz +# Remove 'v' prefix from version if present +VERSION_NUMBER="${VERSION#v}" +FILENAME="llgo${VERSION_NUMBER}.${OS}-${ARCH}.tar.gz" +URL="https://github.com/goplus/llgo/releases/download/${VERSION}/${FILENAME}" + +echo "Downloading LLGo ${VERSION} for ${OS}-${ARCH}..." +echo "URL: $URL" + +# Create install directory +mkdir -p "$INSTALL_DIR" + +# Download and extract +curl -L -o "/tmp/${FILENAME}" "$URL" +tar -xzf "/tmp/${FILENAME}" -C "$INSTALL_DIR" +rm "/tmp/${FILENAME}" + +echo "LLGo ${VERSION} has been installed to ${INSTALL_DIR}" +echo "Binary location: ${INSTALL_DIR}/bin/llgo" + +# Verify installation +if [ -f "${INSTALL_DIR}/bin/llgo" ]; then + echo "Installation verified successfully" + ls -lh "${INSTALL_DIR}/bin/llgo" +else + echo "Error: llgo binary not found at ${INSTALL_DIR}/bin/llgo" + exit 1 +fi