install with esp-clang & new cache key

This commit is contained in:
luoliwoshang
2025-09-08 22:43:24 +08:00
parent 9cea3226db
commit a19011897c
6 changed files with 105 additions and 19 deletions

View File

@@ -35,3 +35,6 @@ runs:
- name: Check file
run: tree .sysroot
shell: bash
- name: Get Esp clang
run: bash .github/workflows/download_esp_clang.sh
shell: bash

67
.github/workflows/download_esp_clang.sh vendored Executable file
View File

@@ -0,0 +1,67 @@
#!/bin/bash
set -e
ESP_CLANG_VERSION="19.1.2_20250905-3"
BASE_URL="https://github.com/goplus/espressif-llvm-project-prebuilt/releases/download/${ESP_CLANG_VERSION}"
get_esp_clang_platform() {
local platform="$1"
local os="${platform%-*}"
local arch="${platform##*-}"
case "${os}" in
"darwin")
case "${arch}" in
"amd64") echo "x86_64-apple-darwin" ;;
"arm64") echo "aarch64-apple-darwin" ;;
*) echo "Error: Unsupported darwin architecture: ${arch}" >&2; exit 1 ;;
esac
;;
"linux")
case "${arch}" in
"amd64") echo "x86_64-linux-gnu" ;;
"arm64") echo "aarch64-linux-gnu" ;;
*) echo "Error: Unsupported linux architecture: ${arch}" >&2; exit 1 ;;
esac
;;
*)
echo "Error: Unsupported OS: ${os}" >&2
exit 1
;;
esac
}
get_filename() {
local platform="$1"
local platform_suffix=$(get_esp_clang_platform "${platform}")
echo "clang-esp-${ESP_CLANG_VERSION}-${platform_suffix}.tar.xz"
}
download_and_extract() {
local platform="$1"
local os="${platform%-*}"
local arch="${platform##*-}"
local filename=$(get_filename "${platform}")
local download_url="${BASE_URL}/${filename}"
echo "Downloading ESP Clang for ${platform}..."
echo " URL: ${download_url}"
mkdir -p ".sysroot/${os}/${arch}/crosscompile/clang"
curl -fsSL "${download_url}" | tar -xJ -C ".sysroot/${os}/${arch}/crosscompile/clang" --strip-components=1
if [[ ! -f ".sysroot/${os}/${arch}/crosscompile/clang/bin/clang++" ]]; then
echo "Error: clang++ not found in ${platform} toolchain"
exit 1
fi
echo "${platform} ESP Clang ready in .sysroot/${os}/${arch}/crosscompile/clang"
}
echo "Downloading ESP Clang toolchain version ${ESP_CLANG_VERSION}..."
for platform in "darwin-amd64" "darwin-arm64" "linux-amd64" "linux-arm64"; do
download_and_extract "${platform}"
done
echo "ESP Clang toolchain completed successfully!"

View File

@@ -27,7 +27,6 @@ jobs:
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
@@ -107,7 +106,7 @@ jobs:
-v $(pwd):/go/src/llgo \
-w /go/src/llgo \
ghcr.io/goreleaser/goreleaser-cross:v1.22 \
release --skip=publish,nfpm,snapcraft --snapshot --clean
release --verbose --parallelism=1 --skip=publish,nfpm,snapcraft --snapshot --clean
- name: Upload Darwin AMD64 Artifacts
uses: actions/upload-artifact@v4
@@ -205,7 +204,7 @@ jobs:
mod-version: ${{ matrix.go-mod-version }}
release:
needs: [setup, build, test-artifacts]
needs: [setup, test-artifacts]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
@@ -231,4 +230,4 @@ jobs:
-v $(pwd):/go/src/llgo \
-w /go/src/llgo \
ghcr.io/goreleaser/goreleaser-cross:v1.22 \
release --clean --skip nfpm,snapcraft
release --parallelism=1 --clean --verbose --skip nfpm,snapcraft

View File

@@ -18,68 +18,84 @@ builds:
- id: llgo-darwin-amd64
main: ./cmd/llgo
binary: bin/llgo
hooks:
pre:
- rm -rf crosscompile
- cp -r .sysroot/darwin/amd64/crosscompile .
flags:
- -tags=darwin,amd64,byollvm
ldflags:
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/usr/local/opt/llvm@19/bin/llvm-config
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=../crosscompile/clang/bin/llvm-config
env:
- CC=o64-clang
- CXX=o64-clang++
- CGO_CPPFLAGS=-I{{.Env.SYSROOT_DARWIN_AMD64}}/usr/local/opt/llvm@19/include -mmacosx-version-min=10.13 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=-L{{.Env.SYSROOT_DARWIN_AMD64}}/usr/local/opt/llvm@19/lib -mmacosx-version-min=10.13 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM-19 -lz -lm
- CGO_CPPFLAGS=-I{{.Env.PWD}}/crosscompile/clang/include -mmacosx-version-min=10.13 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=-L{{.Env.PWD}}/crosscompile/clang/lib -mmacosx-version-min=10.13 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM-19 -lz -lm
targets:
- darwin_amd64
mod_timestamp: "{{.CommitTimestamp}}"
- id: llgo-darwin-arm64
main: ./cmd/llgo
binary: bin/llgo
hooks:
pre:
- rm -rf crosscompile
- cp -r .sysroot/darwin/arm64/crosscompile .
flags:
- -tags=darwin,arm64,byollvm
ldflags:
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/opt/homebrew/opt/llvm@19/bin/llvm-config
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=../crosscompile/clang/bin/llvm-config
env:
- CC=oa64-clang
- CXX=oa64-clang++
- CGO_CPPFLAGS=-I{{.Env.SYSROOT_DARWIN_ARM64}}/opt/homebrew/opt/llvm@19/include -mmacosx-version-min=10.13 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=-L{{.Env.SYSROOT_DARWIN_ARM64}}/opt/homebrew/opt/llvm@19/lib -mmacosx-version-min=10.13 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM-19 -lz -lm
- CGO_CPPFLAGS=-I{{.Env.PWD}}/crosscompile/clang/include -mmacosx-version-min=10.13 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=-L{{.Env.PWD}}/crosscompile/clang/lib -mmacosx-version-min=10.13 -Wl,-search_paths_first -Wl,-headerpad_max_install_names -lLLVM-19 -lz -lm
targets:
- darwin_arm64
mod_timestamp: "{{.CommitTimestamp}}"
- id: llgo-linux-amd64
main: ./cmd/llgo
binary: bin/llgo
hooks:
pre:
- rm -rf crosscompile
- cp -r .sysroot/linux/amd64/crosscompile .
flags:
- -tags=linux,amd64,byollvm
ldflags:
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/usr/lib/llvm-19/bin/llvm-config
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=../crosscompile/clang/bin/llvm-config
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}}/usr/include/llvm-19 -I{{.Env.SYSROOT_LINUX_AMD64}}/usr/include/llvm-c-19 -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}}/usr/lib/llvm-19/lib -lLLVM-19
- CGO_CPPFLAGS=-I{{.Env.PWD}}/crosscompile/clang/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=-L{{.Env.PWD}}/crosscompile/clang/lib -lLLVM-19
targets:
- linux_amd64
mod_timestamp: "{{.CommitTimestamp}}"
- id: llgo-linux-arm64
main: ./cmd/llgo
binary: bin/llgo
hooks:
pre:
- rm -rf crosscompile
- cp -r .sysroot/linux/arm64/crosscompile .
flags:
- -tags=linux,arm64,byollvm
ldflags:
- -X github.com/goplus/llgo/internal/env.buildVersion=v{{.Version}}
- -X github.com/goplus/llgo/internal/env.buildTime={{.Date}}
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=/usr/lib/llvm-19/bin/llvm-config
- -X github.com/goplus/llgo/xtool/env/llvm.ldLLVMConfigBin=../crosscompile/clang/bin/llvm-config
env:
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
- CGO_CPPFLAGS=--sysroot={{.Env.SYSROOT_LINUX_ARM64}} -I{{.Env.SYSROOT_LINUX_ARM64}}/usr/include/llvm-19 -I{{.Env.SYSROOT_LINUX_ARM64}}/usr/include/llvm-c-19 -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}}/usr/lib/llvm-19/lib -lLLVM-19
- CGO_CPPFLAGS=-I{{.Env.PWD}}/crosscompile/clang/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
- CGO_LDFLAGS=-L{{.Env.PWD}}/crosscompile/clang/lib -lLLVM-19
targets:
- linux_arm64
mod_timestamp: "{{.CommitTimestamp}}"
@@ -93,6 +109,7 @@ archives:
- LICENSE
- README.md
- runtime
- crosscompile
checksum:
name_template: "{{.ProjectName}}{{.Version}}.checksums.txt"

View File

@@ -48,8 +48,8 @@ var (
)
var (
espClangBaseUrl = "https://github.com/goplus/espressif-llvm-project-prebuilt/releases/download/19.1.2_20250820"
espClangVersion = "19.1.2_20250820"
espClangBaseUrl = "https://github.com/goplus/espressif-llvm-project-prebuilt/releases/download/19.1.2_20250905-3"
espClangVersion = "19.1.2_20250905-3"
)
// cacheRoot can be overridden for testing

View File

@@ -605,7 +605,7 @@ func TestESPClangDownloadWhenNotExists(t *testing.T) {
}
server := createTestServer(t, map[string]string{
"clang-esp-19.1.2_20250820-linux.tar.xz": string(archiveContent),
fmt.Sprintf("clang-esp-%s-linux.tar.xz", espClangVersion): string(archiveContent),
})
defer server.Close()