Merge pull request #1325 from luoliwoshang/ci/rmllvm
ci/gorelease:remove reduant llvm download
This commit is contained in:
12
.github/actions/setup-goreleaser/action.yml
vendored
12
.github/actions/setup-goreleaser/action.yml
vendored
@@ -1,9 +1,6 @@
|
|||||||
name: "Setup GoReleaser"
|
name: "Setup GoReleaser"
|
||||||
description: "Setup GoReleaser environment"
|
description: "Setup GoReleaser environment"
|
||||||
inputs:
|
inputs:
|
||||||
darwin-cache-key:
|
|
||||||
description: "Darwin sysroot cache key"
|
|
||||||
required: true
|
|
||||||
linux-cache-key:
|
linux-cache-key:
|
||||||
description: "Linux sysroot cache key"
|
description: "Linux sysroot cache key"
|
||||||
required: true
|
required: true
|
||||||
@@ -14,21 +11,12 @@ runs:
|
|||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: 1.24.x
|
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
|
- name: Restore Linux sysroot cache
|
||||||
id: cache-linux-sysroot
|
id: cache-linux-sysroot
|
||||||
uses: actions/cache/restore@v4
|
uses: actions/cache/restore@v4
|
||||||
with:
|
with:
|
||||||
path: .sysroot/linux.tar.gz
|
path: .sysroot/linux.tar.gz
|
||||||
key: ${{ inputs.linux-cache-key }}
|
key: ${{ inputs.linux-cache-key }}
|
||||||
- name: Populate Darwin sysroot
|
|
||||||
run: tar -xzvf .sysroot/darwin.tar.gz -C .sysroot
|
|
||||||
shell: bash
|
|
||||||
- name: Populate Linux sysroot
|
- name: Populate Linux sysroot
|
||||||
run: tar -xzvf .sysroot/linux.tar.gz -C .sysroot
|
run: tar -xzvf .sysroot/linux.tar.gz -C .sysroot
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
40
.github/workflows/populate_darwin_sysroot.sh
vendored
40
.github/workflows/populate_darwin_sysroot.sh
vendored
@@ -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
|
|
||||||
7
.github/workflows/populate_linux_sysroot.sh
vendored
7
.github/workflows/populate_linux_sysroot.sh
vendored
@@ -17,12 +17,7 @@ cat > "${POPULATE_LINUX_SYSROOT_SCRIPT}" << EOF
|
|||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y lsb-release gnupg wget rsync
|
apt-get install -y build-essential zlib1g-dev 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
|
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
echo -e "\$1" >&2
|
echo -e "\$1" >&2
|
||||||
|
|||||||
36
.github/workflows/release-build.yml
vendored
36
.github/workflows/release-build.yml
vendored
@@ -15,7 +15,6 @@ jobs:
|
|||||||
setup:
|
setup:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
darwin-cache-key: ${{ steps.cache-keys.outputs.darwin-key }}
|
|
||||||
linux-cache-key: ${{ steps.cache-keys.outputs.linux-key }}
|
linux-cache-key: ${{ steps.cache-keys.outputs.linux-key }}
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
@@ -23,36 +22,8 @@ jobs:
|
|||||||
- name: Calculate cache keys
|
- name: Calculate cache keys
|
||||||
id: cache-keys
|
id: cache-keys
|
||||||
run: |
|
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"
|
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
|
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:
|
populate-linux-sysroot:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: setup
|
needs: setup
|
||||||
@@ -86,14 +57,13 @@ jobs:
|
|||||||
key: ${{ needs.setup.outputs.linux-cache-key }}
|
key: ${{ needs.setup.outputs.linux-cache-key }}
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [setup, populate-darwin-sysroot, populate-linux-sysroot]
|
needs: [setup, populate-linux-sysroot]
|
||||||
steps:
|
steps:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
- name: Set up Release
|
- name: Set up Release
|
||||||
uses: ./.github/actions/setup-goreleaser
|
uses: ./.github/actions/setup-goreleaser
|
||||||
with:
|
with:
|
||||||
darwin-cache-key: ${{ needs.setup.outputs.darwin-cache-key }}
|
|
||||||
linux-cache-key: ${{ needs.setup.outputs.linux-cache-key }}
|
linux-cache-key: ${{ needs.setup.outputs.linux-cache-key }}
|
||||||
- name: Run GoReleaser (Build & Test)
|
- name: Run GoReleaser (Build & Test)
|
||||||
env:
|
env:
|
||||||
@@ -206,8 +176,7 @@ jobs:
|
|||||||
mod-version: ${{ matrix.go-mod-version }}
|
mod-version: ${{ matrix.go-mod-version }}
|
||||||
|
|
||||||
release:
|
release:
|
||||||
needs:
|
needs: [setup, test-artifacts, populate-linux-sysroot]
|
||||||
[setup, test-artifacts, populate-darwin-sysroot, populate-linux-sysroot]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
steps:
|
steps:
|
||||||
@@ -218,7 +187,6 @@ jobs:
|
|||||||
- name: Set up Release
|
- name: Set up Release
|
||||||
uses: ./.github/actions/setup-goreleaser
|
uses: ./.github/actions/setup-goreleaser
|
||||||
with:
|
with:
|
||||||
darwin-cache-key: ${{ needs.setup.outputs.darwin-cache-key }}
|
|
||||||
linux-cache-key: ${{ needs.setup.outputs.linux-cache-key }}
|
linux-cache-key: ${{ needs.setup.outputs.linux-cache-key }}
|
||||||
- name: Run GoReleaser (Release)
|
- name: Run GoReleaser (Release)
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -55,12 +55,12 @@ builds:
|
|||||||
ldflags:
|
ldflags:
|
||||||
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
|
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
|
||||||
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
|
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
|
||||||
- '-extldflags=-Wl,-rpath,$ORIGIN/../crosscompile/clang/lib'
|
- "-extldflags=-Wl,-rpath,$ORIGIN/../crosscompile/clang/lib"
|
||||||
env:
|
env:
|
||||||
- CC=x86_64-linux-gnu-gcc
|
- CC=x86_64-linux-gnu-gcc
|
||||||
- CXX=x86_64-linux-gnu-g++
|
- 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_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.*
|
- CGO_LDFLAGS_ALLOW=--sysroot.*
|
||||||
targets:
|
targets:
|
||||||
- linux_amd64
|
- linux_amd64
|
||||||
@@ -73,12 +73,12 @@ builds:
|
|||||||
ldflags:
|
ldflags:
|
||||||
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
|
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
|
||||||
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
|
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
|
||||||
- '-extldflags=-Wl,-rpath,$ORIGIN/../crosscompile/clang/lib'
|
- "-extldflags=-Wl,-rpath,$ORIGIN/../crosscompile/clang/lib"
|
||||||
env:
|
env:
|
||||||
- CC=aarch64-linux-gnu-gcc
|
- CC=aarch64-linux-gnu-gcc
|
||||||
- CXX=aarch64-linux-gnu-g++
|
- 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_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.*
|
- CGO_LDFLAGS_ALLOW=--sysroot.*
|
||||||
targets:
|
targets:
|
||||||
- linux_arm64
|
- linux_arm64
|
||||||
|
|||||||
Reference in New Issue
Block a user