@@ -95,6 +95,45 @@ BuildWinArm64() {
9595 go build -o " $1 " -ldflags=" $ldflags " -tags=jsoniter .
9696}
9797
98+ BuildWin7 () {
99+ # Setup Win7 Go compiler (patched version that supports Windows 7)
100+ go_version=$( go version | grep -o ' go[0-9]\+\.[0-9]\+\.[0-9]\+' | sed ' s/go//' )
101+ echo " Detected Go version: $go_version "
102+
103+ curl -fsSL --retry 3 -o go-win7.zip -H " Authorization: Bearer $GITHUB_TOKEN " \
104+ " https://github.com/XTLS/go-win7/releases/download/patched-${go_version} /go-for-win7-linux-amd64.zip"
105+
106+ rm -rf go-win7
107+ unzip go-win7.zip -d go-win7
108+ rm go-win7.zip
109+
110+ # Set permissions for all wrapper files
111+ chmod +x ./wrapper/zcc-win7
112+ chmod +x ./wrapper/zcxx-win7
113+ chmod +x ./wrapper/zcc-win7-386
114+ chmod +x ./wrapper/zcxx-win7-386
115+
116+ # Build for both 386 and amd64 architectures
117+ for arch in " 386" " amd64" ; do
118+ echo " building for windows7-${arch} "
119+ export GOOS=windows
120+ export GOARCH=${arch}
121+ export CGO_ENABLED=1
122+
123+ # Use architecture-specific wrapper files
124+ if [ " $arch " = " 386" ]; then
125+ export CC=$( pwd) /wrapper/zcc-win7-386
126+ export CXX=$( pwd) /wrapper/zcxx-win7-386
127+ else
128+ export CC=$( pwd) /wrapper/zcc-win7
129+ export CXX=$( pwd) /wrapper/zcxx-win7
130+ fi
131+
132+ # Use the patched Go compiler for Win7 compatibility
133+ $( pwd) /go-win7/bin/go build -o " ${1} -${arch} .exe" -ldflags=" $ldflags " -tags=jsoniter .
134+ done
135+ }
136+
98137BuildDev () {
99138 rm -rf .git/
100139 mkdir -p " dist"
@@ -186,12 +225,171 @@ BuildRelease() {
186225 rm -rf .git/
187226 mkdir -p " build"
188227 BuildWinArm64 ./build/" $appName " -windows-arm64.exe
228+ BuildWin7 ./build/" $appName " -windows7
189229 xgo -out " $appName " -ldflags=" $ldflags " -tags=jsoniter .
190230 # why? Because some target platforms seem to have issues with upx compression
191231 # upx -9 ./"$appName"-linux-amd64
192232 # cp ./"$appName"-windows-amd64.exe ./"$appName"-windows-amd64-upx.exe
193233 # upx -9 ./"$appName"-windows-amd64-upx.exe
194234 mv " $appName " -* build
235+
236+ # Build LoongArch with glibc (both old world abi1.0 and new world abi2.0)
237+ # Separate from musl builds to avoid cache conflicts
238+ BuildLoongGLIBC ./build/$appName -linux-loong64-abi1.0 abi1.0
239+ BuildLoongGLIBC ./build/$appName -linux-loong64 abi2.0
240+ }
241+
242+ BuildLoongGLIBC () {
243+ local target_abi=" $2 "
244+ local output_file=" $1 "
245+ local oldWorldGoVersion=" 1.24.3"
246+
247+ if [ " $target_abi " = " abi1.0" ]; then
248+ echo building for linux-loong64-abi1.0
249+ else
250+ echo building for linux-loong64-abi2.0
251+ target_abi=" abi2.0" # Default to abi2.0 if not specified
252+ fi
253+
254+ # Note: No longer need global cache cleanup since ABI1.0 uses isolated cache directory
255+ echo " Using optimized cache strategy: ABI1.0 has isolated cache, ABI2.0 uses standard cache"
256+
257+ if [ " $target_abi " = " abi1.0" ]; then
258+ # Setup abi1.0 toolchain and patched Go compiler similar to cgo-action implementation
259+ echo " Setting up Loongson old-world ABI1.0 toolchain and patched Go compiler..."
260+
261+ # Download and setup patched Go compiler for old-world
262+ if ! curl -fsSL --retry 3 -H " Authorization: Bearer $GITHUB_TOKEN " \
263+ " https://github.com/loong64/loong64-abi1.0-toolchains/releases/download/20250722/go${oldWorldGoVersion} .linux-amd64.tar.gz" \
264+ -o go-loong64-abi1.0.tar.gz; then
265+ echo " Error: Failed to download patched Go compiler for old-world ABI1.0"
266+ if [ -n " $GITHUB_TOKEN " ]; then
267+ echo " Error output from curl:"
268+ curl -fsSL --retry 3 -H " Authorization: Bearer $GITHUB_TOKEN " \
269+ " https://github.com/loong64/loong64-abi1.0-toolchains/releases/download/20250722/go${oldWorldGoVersion} .linux-amd64.tar.gz" \
270+ -o go-loong64-abi1.0.tar.gz || true
271+ fi
272+ return 1
273+ fi
274+
275+ rm -rf go-loong64-abi1.0
276+ mkdir go-loong64-abi1.0
277+ if ! tar -xzf go-loong64-abi1.0.tar.gz -C go-loong64-abi1.0 --strip-components=1; then
278+ echo " Error: Failed to extract patched Go compiler"
279+ return 1
280+ fi
281+ rm go-loong64-abi1.0.tar.gz
282+
283+ # Download and setup GCC toolchain for old-world
284+ if ! curl -fsSL --retry 3 -H " Authorization: Bearer $GITHUB_TOKEN " \
285+ " https://github.com/loong64/loong64-abi1.0-toolchains/releases/download/20250722/loongson-gnu-toolchain-8.3.novec-x86_64-loongarch64-linux-gnu-rc1.1.tar.xz" \
286+ -o gcc8-loong64-abi1.0.tar.xz; then
287+ echo " Error: Failed to download GCC toolchain for old-world ABI1.0"
288+ if [ -n " $GITHUB_TOKEN " ]; then
289+ echo " Error output from curl:"
290+ curl -fsSL --retry 3 -H " Authorization: Bearer $GITHUB_TOKEN " \
291+ " https://github.com/loong64/loong64-abi1.0-toolchains/releases/download/20250722/loongson-gnu-toolchain-8.3.novec-x86_64-loongarch64-linux-gnu-rc1.1.tar.xz" \
292+ -o gcc8-loong64-abi1.0.tar.xz || true
293+ fi
294+ return 1
295+ fi
296+
297+ rm -rf gcc8-loong64-abi1.0
298+ mkdir gcc8-loong64-abi1.0
299+ if ! tar -Jxf gcc8-loong64-abi1.0.tar.xz -C gcc8-loong64-abi1.0 --strip-components=1; then
300+ echo " Error: Failed to extract GCC toolchain"
301+ return 1
302+ fi
303+ rm gcc8-loong64-abi1.0.tar.xz
304+
305+ # Setup separate cache directory for ABI1.0 to avoid cache pollution
306+ abi1_cache_dir=" $( pwd) /go-loong64-abi1.0-cache"
307+ mkdir -p " $abi1_cache_dir "
308+ echo " Using separate cache directory for ABI1.0: $abi1_cache_dir "
309+
310+ # Use patched Go compiler for old-world build (critical for ABI1.0 compatibility)
311+ echo " Building with patched Go compiler for old-world ABI1.0..."
312+ echo " Using isolated cache directory: $abi1_cache_dir "
313+
314+ # Use env command to set environment variables locally without affecting global environment
315+ if ! env GOOS=linux GOARCH=loong64 \
316+ CC=" $( pwd) /gcc8-loong64-abi1.0/bin/loongarch64-linux-gnu-gcc" \
317+ CXX=" $( pwd) /gcc8-loong64-abi1.0/bin/loongarch64-linux-gnu-g++" \
318+ CGO_ENABLED=1 \
319+ GOCACHE=" $abi1_cache_dir " \
320+ $( pwd) /go-loong64-abi1.0/bin/go build -a -o " $output_file " -ldflags=" $ldflags " -tags=jsoniter . ; then
321+ echo " Error: Build failed with patched Go compiler"
322+ echo " Attempting retry with cache cleanup..."
323+ env GOCACHE=" $abi1_cache_dir " $( pwd) /go-loong64-abi1.0/bin/go clean -cache
324+ if ! env GOOS=linux GOARCH=loong64 \
325+ CC=" $( pwd) /gcc8-loong64-abi1.0/bin/loongarch64-linux-gnu-gcc" \
326+ CXX=" $( pwd) /gcc8-loong64-abi1.0/bin/loongarch64-linux-gnu-g++" \
327+ CGO_ENABLED=1 \
328+ GOCACHE=" $abi1_cache_dir " \
329+ $( pwd) /go-loong64-abi1.0/bin/go build -a -o " $output_file " -ldflags=" $ldflags " -tags=jsoniter . ; then
330+ echo " Error: Build failed again after cache cleanup"
331+ echo " Build environment details:"
332+ echo " GOOS=linux"
333+ echo " GOARCH=loong64"
334+ echo " CC=$( pwd) /gcc8-loong64-abi1.0/bin/loongarch64-linux-gnu-gcc"
335+ echo " CXX=$( pwd) /gcc8-loong64-abi1.0/bin/loongarch64-linux-gnu-g++"
336+ echo " CGO_ENABLED=1"
337+ echo " GOCACHE=$abi1_cache_dir "
338+ echo " Go version: $( $( pwd) /go-loong64-abi1.0/bin/go version) "
339+ echo " GCC version: $( $( pwd) /gcc8-loong64-abi1.0/bin/loongarch64-linux-gnu-gcc --version | head -1) "
340+ return 1
341+ fi
342+ fi
343+ else
344+ # Setup abi2.0 toolchain for new world glibc build
345+ echo " Setting up new-world ABI2.0 toolchain..."
346+ if ! curl -fsSL --retry 3 -H " Authorization: Bearer $GITHUB_TOKEN " \
347+ " https://github.com/loong64/cross-tools/releases/download/20250507/x86_64-cross-tools-loongarch64-unknown-linux-gnu-legacy.tar.xz" \
348+ -o gcc12-loong64-abi2.0.tar.xz; then
349+ echo " Error: Failed to download GCC toolchain for new-world ABI2.0"
350+ if [ -n " $GITHUB_TOKEN " ]; then
351+ echo " Error output from curl:"
352+ curl -fsSL --retry 3 -H " Authorization: Bearer $GITHUB_TOKEN " \
353+ " https://github.com/loong64/cross-tools/releases/download/20250507/x86_64-cross-tools-loongarch64-unknown-linux-gnu-legacy.tar.xz" \
354+ -o gcc12-loong64-abi2.0.tar.xz || true
355+ fi
356+ return 1
357+ fi
358+
359+ rm -rf gcc12-loong64-abi2.0
360+ mkdir gcc12-loong64-abi2.0
361+ if ! tar -Jxf gcc12-loong64-abi2.0.tar.xz -C gcc12-loong64-abi2.0 --strip-components=1; then
362+ echo " Error: Failed to extract GCC toolchain"
363+ return 1
364+ fi
365+ rm gcc12-loong64-abi2.0.tar.xz
366+
367+ export GOOS=linux
368+ export GOARCH=loong64
369+ export CC=$( pwd) /gcc12-loong64-abi2.0/bin/loongarch64-unknown-linux-gnu-gcc
370+ export CXX=$( pwd) /gcc12-loong64-abi2.0/bin/loongarch64-unknown-linux-gnu-g++
371+ export CGO_ENABLED=1
372+
373+ # Use standard Go compiler for new-world build
374+ echo " Building with standard Go compiler for new-world ABI2.0..."
375+ if ! go build -a -o " $output_file " -ldflags=" $ldflags " -tags=jsoniter . ; then
376+ echo " Error: Build failed with standard Go compiler"
377+ echo " Attempting retry with cache cleanup..."
378+ go clean -cache
379+ if ! go build -a -o " $output_file " -ldflags=" $ldflags " -tags=jsoniter . ; then
380+ echo " Error: Build failed again after cache cleanup"
381+ echo " Build environment details:"
382+ echo " GOOS=$GOOS "
383+ echo " GOARCH=$GOARCH "
384+ echo " CC=$CC "
385+ echo " CXX=$CXX "
386+ echo " CGO_ENABLED=$CGO_ENABLED "
387+ echo " Go version: $( go version) "
388+ echo " GCC version: $( $CC --version | head -1) "
389+ return 1
390+ fi
391+ fi
392+ fi
195393}
196394
197395BuildReleaseLinuxMusl () {
@@ -249,6 +447,7 @@ BuildReleaseLinuxMuslArm() {
249447 done
250448}
251449
450+
252451BuildReleaseAndroid () {
253452 rm -rf .git/
254453 mkdir -p " build"
@@ -344,7 +543,7 @@ MakeRelease() {
344543 tar -czvf compress/" $i$liteSuffix " .tar.gz " $appName "
345544 rm -f " $appName "
346545 done
347- for i in $( find . -type f -name " $appName -windows-*" ) ; do
546+ for i in $( find . -type f \( -name " $appName -windows-*" -o -name " $appName -windows7-* " \) ) ; do
348547 cp " $i " " $appName " .exe
349548 zip compress/$( echo $i | sed ' s/\.[^.]*$//' ) $liteSuffix .zip " $appName " .exe
350549 rm -f " $appName " .exe
484683 echo -e " $0 release"
485684 echo -e " $0 release lite"
486685 echo -e " $0 release docker lite"
686+ echo -e " $0 release linux_musl"
487687fi
0 commit comments