Merge pull request #1325 from luoliwoshang/ci/rmllvm

ci/gorelease:remove reduant llvm download
This commit is contained in:
xushiwei
2025-09-27 06:15:03 +08:00
committed by GitHub
5 changed files with 7 additions and 96 deletions

View File

@@ -1,9 +1,6 @@
name: "Setup GoReleaser"
description: "Setup GoReleaser environment"
inputs:
darwin-cache-key:
description: "Darwin sysroot cache key"
required: true
linux-cache-key:
description: "Linux sysroot cache key"
required: true
@@ -14,21 +11,12 @@ runs:
uses: actions/setup-go@v5
with:
go-version: 1.24.x
- name: Restore Darwin sysroot cache
id: cache-darwin-sysroot
uses: actions/cache/restore@v4
with:
path: .sysroot/darwin.tar.gz
key: ${{ inputs.darwin-cache-key }}
- name: Restore Linux sysroot cache
id: cache-linux-sysroot
uses: actions/cache/restore@v4
with:
path: .sysroot/linux.tar.gz
key: ${{ inputs.linux-cache-key }}
- name: Populate Darwin sysroot
run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot
shell: bash
- name: Populate Linux sysroot
run: tar -xzvf .sysroot/linux.tar.gz -C .sysroot
shell: bash

View File

@@ -1,40 +0,0 @@
#!/bin/bash
set -e
TMPDIR="$(mktemp -d)"
export TMPDIR
trap 'rm -rf "${TMPDIR}"' EXIT
DARWIN_AMD64_LLVM_PREFIX=.sysroot/darwin/amd64/usr/local/opt/llvm@19
DARWIN_ARM64_LLVM_PREFIX=.sysroot/darwin/arm64/opt/homebrew/opt/llvm@19
mkdir -p "${DARWIN_AMD64_LLVM_PREFIX}" "${DARWIN_ARM64_LLVM_PREFIX}"
BREW_LLVM_FORMULA_JSON="$(mktemp)"
curl -fsSL https://formulae.brew.sh/api/formula/llvm@19.json > "${BREW_LLVM_FORMULA_JSON}"
BREW_LLVM_AMD64_BOTTLE_URL=$(jq -r '.bottle.stable.files.sonoma.url' "${BREW_LLVM_FORMULA_JSON}")
BREW_LLVM_ARM64_BOTTLE_URL=$(jq -r '.bottle.stable.files.arm64_sonoma.url' "${BREW_LLVM_FORMULA_JSON}")
curl -fsSL -H "Authorization: Bearer QQ==" "${BREW_LLVM_AMD64_BOTTLE_URL}" | tar -xzf - --strip-components=2 -C "${DARWIN_AMD64_LLVM_PREFIX}"
curl -fsSL -H "Authorization: Bearer QQ==" "${BREW_LLVM_ARM64_BOTTLE_URL}" | tar -xzf - --strip-components=2 -C "${DARWIN_ARM64_LLVM_PREFIX}"
patch_homebrew_lib_dir() {
local LIB_DIR="$1"
local HOMEBREW_PREFIX="$2"
for DYLIB_FILE in "${LIB_DIR}"/*.dylib; do
if [[ -f "${DYLIB_FILE}" ]]; then
ID=$(otool -D "${DYLIB_FILE}" | grep '@@HOMEBREW_PREFIX@@' | awk '{print $1}')
if [[ -n "${ID}" ]]; then
NEW_ID=${ID/'@@HOMEBREW_PREFIX@@'/${HOMEBREW_PREFIX}}
install_name_tool -id "${NEW_ID}" "${DYLIB_FILE}"
fi
DEPS=$(otool -L "${DYLIB_FILE}" | grep '@@HOMEBREW_PREFIX@@' | awk '{print $1}')
for DEP in ${DEPS}; do
NEW_DEP=${DEP/'@@HOMEBREW_PREFIX@@'/${HOMEBREW_PREFIX}}
install_name_tool -change "${DEP}" "${NEW_DEP}" "${DYLIB_FILE}"
done
fi
done
}
patch_homebrew_lib_dir "${DARWIN_AMD64_LLVM_PREFIX}/lib" /usr/lib
patch_homebrew_lib_dir "${DARWIN_ARM64_LLVM_PREFIX}/lib" /opt/homebrew

View File

@@ -17,12 +17,7 @@ cat > "${POPULATE_LINUX_SYSROOT_SCRIPT}" << EOF
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y lsb-release gnupg wget rsync
echo "deb http://apt.llvm.org/\$(lsb_release -cs)/ llvm-toolchain-\$(lsb_release -cs)-19 main" | tee /etc/apt/sources.list.d/llvm.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
apt-get update
apt-get install -y llvm-19-dev
apt-get install -y build-essential zlib1g-dev rsync
error() {
echo -e "\$1" >&2

View File

@@ -15,7 +15,6 @@ jobs:
setup:
runs-on: ubuntu-latest
outputs:
darwin-cache-key: ${{ steps.cache-keys.outputs.darwin-key }}
linux-cache-key: ${{ steps.cache-keys.outputs.linux-key }}
steps:
- name: Check out code
@@ -23,36 +22,8 @@ jobs:
- name: Calculate cache keys
id: cache-keys
run: |
DARWIN_KEY="darwin-sysroot-${{ hashFiles('.github/workflows/populate_darwin_sysroot.sh', '.github/workflows/release-build.yml') }}-v1.0.0"
LINUX_KEY="linux-sysroot-${{ hashFiles('.github/workflows/populate_linux_sysroot.sh', '.github/workflows/release-build.yml') }}-v1.0.0"
echo "darwin-key=$DARWIN_KEY" >> $GITHUB_OUTPUT
echo "linux-key=$LINUX_KEY" >> $GITHUB_OUTPUT
populate-darwin-sysroot:
runs-on: macos-latest
timeout-minutes: 30
needs: setup
steps:
- name: Check out code
uses: actions/checkout@v5
- name: Check Darwin sysroot cache
id: cache-darwin-sysroot
uses: actions/cache/restore@v4
with:
path: .sysroot/darwin.tar.gz
key: ${{ needs.setup.outputs.darwin-cache-key }}
lookup-only: true
- name: Populate Darwin sysroot
if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true'
run: bash .github/workflows/populate_darwin_sysroot.sh
- name: Create Darwin sysroot tarball
if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true'
run: tar -czvf .sysroot/darwin.tar.gz -C .sysroot darwin
- name: Save Darwin sysroot cache
if: steps.cache-darwin-sysroot.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: .sysroot/darwin.tar.gz
key: ${{ needs.setup.outputs.darwin-cache-key }}
populate-linux-sysroot:
runs-on: ubuntu-latest
needs: setup
@@ -86,14 +57,13 @@ jobs:
key: ${{ needs.setup.outputs.linux-cache-key }}
build:
runs-on: ubuntu-latest
needs: [setup, populate-darwin-sysroot, populate-linux-sysroot]
needs: [setup, populate-linux-sysroot]
steps:
- name: Check out code
uses: actions/checkout@v5
- name: Set up Release
uses: ./.github/actions/setup-goreleaser
with:
darwin-cache-key: ${{ needs.setup.outputs.darwin-cache-key }}
linux-cache-key: ${{ needs.setup.outputs.linux-cache-key }}
- name: Run GoReleaser (Build & Test)
env:
@@ -206,8 +176,7 @@ jobs:
mod-version: ${{ matrix.go-mod-version }}
release:
needs:
[setup, test-artifacts, populate-darwin-sysroot, populate-linux-sysroot]
needs: [setup, test-artifacts, populate-linux-sysroot]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
@@ -218,7 +187,6 @@ jobs:
- name: Set up Release
uses: ./.github/actions/setup-goreleaser
with:
darwin-cache-key: ${{ needs.setup.outputs.darwin-cache-key }}
linux-cache-key: ${{ needs.setup.outputs.linux-cache-key }}
- name: Run GoReleaser (Release)
env:

View File

@@ -55,12 +55,12 @@ builds:
ldflags:
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
- '-extldflags=-Wl,-rpath,$ORIGIN/../crosscompile/clang/lib'
- "-extldflags=-Wl,-rpath,$ORIGIN/../crosscompile/clang/lib"
env:
- CC=x86_64-linux-gnu-gcc
- CXX=x86_64-linux-gnu-g++
- CGO_CPPFLAGS=--sysroot={{.Env.SYSROOT_LINUX_AMD64}} -I{{.Env.SYSROOT_LINUX_AMD64}}/crosscompile/clang/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=--sysroot={{.Env.SYSROOT_LINUX_AMD64}} -L{{.Env.SYSROOT_LINUX_AMD64}}/crosscompile/clang/lib -lLLVM-19
- CGO_LDFLAGS=--sysroot={{.Env.SYSROOT_LINUX_AMD64}} -L{{.Env.SYSROOT_LINUX_AMD64}}/crosscompile/clang/lib -L{{.Env.SYSROOT_LINUX_AMD64}}/lib/x86_64-linux-gnu -lLLVM-19 -lz
- CGO_LDFLAGS_ALLOW=--sysroot.*
targets:
- linux_amd64
@@ -73,12 +73,12 @@ builds:
ldflags:
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
- '-extldflags=-Wl,-rpath,$ORIGIN/../crosscompile/clang/lib'
- "-extldflags=-Wl,-rpath,$ORIGIN/../crosscompile/clang/lib"
env:
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
- CGO_CPPFLAGS=--sysroot={{.Env.SYSROOT_LINUX_ARM64}} -I{{.Env.SYSROOT_LINUX_ARM64}}/crosscompile/clang/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=--sysroot={{.Env.SYSROOT_LINUX_ARM64}} -L{{.Env.SYSROOT_LINUX_ARM64}}/crosscompile/clang/lib -lLLVM-19
- CGO_LDFLAGS=--sysroot={{.Env.SYSROOT_LINUX_ARM64}} -L{{.Env.SYSROOT_LINUX_ARM64}}/crosscompile/clang/lib -L{{.Env.SYSROOT_LINUX_ARM64}}/lib/aarch64-linux-gnu -lLLVM-19 -lz
- CGO_LDFLAGS_ALLOW=--sysroot.*
targets:
- linux_arm64