diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6d65425d..f5bb148d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,14 +29,20 @@ jobs: strategy: matrix: jobs: - - { goos: darwin, goarch: arm64, output: arm64 } - { goos: darwin, goarch: amd64, goamd64: v1, output: amd64-compatible } - { goos: darwin, goarch: amd64, goamd64: v3, output: amd64 } + - { goos: darwin, goarch: amd64, goamd64: v1, output: amd64-v1 } + - { goos: darwin, goarch: amd64, goamd64: v2, output: amd64-v2 } + - { goos: darwin, goarch: amd64, goamd64: v3, output: amd64-v3 } + - { goos: darwin, goarch: arm64, output: arm64 } - { goos: linux, goarch: '386', go386: sse2, output: '386', debian: i386, rpm: i386} - { goos: linux, goarch: '386', go386: softfloat, output: '386-softfloat' } - - { goos: linux, goarch: amd64, goamd64: v1, output: amd64-compatible, test: test } - - { goos: linux, goarch: amd64, goamd64: v3, output: amd64, debian: amd64, rpm: x86_64, pacman: x86_64} + - { goos: linux, goarch: amd64, goamd64: v1, output: amd64-compatible} + - { goos: linux, goarch: amd64, goamd64: v3, output: amd64} + - { goos: linux, goarch: amd64, goamd64: v1, output: amd64-v1, test: test } + - { goos: linux, goarch: amd64, goamd64: v2, output: amd64-v2 } + - { goos: linux, goarch: amd64, goamd64: v3, output: amd64-v3, debian: amd64, rpm: x86_64, pacman: x86_64} - { goos: linux, goarch: arm64, output: arm64, debian: arm64, rpm: aarch64, pacman: aarch64} - { goos: linux, goarch: arm, goarm: '5', output: armv5 } - { goos: linux, goarch: arm, goarm: '6', output: armv6, debian: armel, rpm: armv6hl} @@ -56,11 +62,17 @@ jobs: - { goos: windows, goarch: '386', output: '386' } - { goos: windows, goarch: amd64, goamd64: v1, output: amd64-compatible } - { goos: windows, goarch: amd64, goamd64: v3, output: amd64 } + - { goos: windows, goarch: amd64, goamd64: v1, output: amd64-v1 } + - { goos: windows, goarch: amd64, goamd64: v2, output: amd64-v2 } + - { goos: windows, goarch: amd64, goamd64: v3, output: amd64-v3 } - { goos: windows, goarch: arm64, output: arm64 } - { goos: freebsd, goarch: '386', output: '386' } - { goos: freebsd, goarch: amd64, goamd64: v1, output: amd64-compatible } - { goos: freebsd, goarch: amd64, goamd64: v3, output: amd64 } + - { goos: freebsd, goarch: amd64, goamd64: v1, output: amd64-v1 } + - { goos: freebsd, goarch: amd64, goamd64: v2, output: amd64-v2 } + - { goos: freebsd, goarch: amd64, goamd64: v3, output: amd64-v3 } - { goos: freebsd, goarch: arm64, output: arm64 } - { goos: android, goarch: '386', ndk: i686-linux-android34, output: '386' } @@ -71,46 +83,54 @@ jobs: # Go 1.23 with special patch can work on Windows 7 # https://github.com/MetaCubeX/go/commits/release-branch.go1.23/ - { goos: windows, goarch: '386', output: '386-go123', goversion: '1.23' } - - { goos: windows, goarch: amd64, goamd64: v1, output: amd64-compatible-go123, goversion: '1.23' } - - { goos: windows, goarch: amd64, goamd64: v3, output: amd64-go123, goversion: '1.23' } + - { goos: windows, goarch: amd64, goamd64: v1, output: amd64-v1-go123, goversion: '1.23' } + - { goos: windows, goarch: amd64, goamd64: v2, output: amd64-v2-go123, goversion: '1.23' } + - { goos: windows, goarch: amd64, goamd64: v3, output: amd64-v3-go123, goversion: '1.23' } # Go 1.22 with special patch can work on Windows 7 # https://github.com/MetaCubeX/go/commits/release-branch.go1.22/ - { goos: windows, goarch: '386', output: '386-go122', goversion: '1.22' } - - { goos: windows, goarch: amd64, goamd64: v1, output: amd64-compatible-go122, goversion: '1.22' } - - { goos: windows, goarch: amd64, goamd64: v3, output: amd64-go122, goversion: '1.22' } + - { goos: windows, goarch: amd64, goamd64: v1, output: amd64-v1-go122, goversion: '1.22' } + - { goos: windows, goarch: amd64, goamd64: v2, output: amd64-v2-go122, goversion: '1.22' } + - { goos: windows, goarch: amd64, goamd64: v3, output: amd64-v3-go122, goversion: '1.22' } # Go 1.21 can revert commit `9e4385` to work on Windows 7 # https://github.com/golang/go/issues/64622#issuecomment-1847475161 # (OR we can just use golang1.21.4 which unneeded any patch) - { goos: windows, goarch: '386', output: '386-go121', goversion: '1.21' } - - { goos: windows, goarch: amd64, goamd64: v1, output: amd64-compatible-go121, goversion: '1.21' } - - { goos: windows, goarch: amd64, goamd64: v3, output: amd64-go121, goversion: '1.21' } + - { goos: windows, goarch: amd64, goamd64: v1, output: amd64-v1-go121, goversion: '1.21' } + - { goos: windows, goarch: amd64, goamd64: v2, output: amd64-v2-go121, goversion: '1.21' } + - { goos: windows, goarch: amd64, goamd64: v3, output: amd64-v3-go121, goversion: '1.21' } # Go 1.20 is the last release that will run on any release of Windows 7, 8, Server 2008 and Server 2012. Go 1.21 will require at least Windows 10 or Server 2016. - { goos: windows, goarch: '386', output: '386-go120', goversion: '1.20' } - - { goos: windows, goarch: amd64, goamd64: v1, output: amd64-compatible-go120, goversion: '1.20' } - - { goos: windows, goarch: amd64, goamd64: v3, output: amd64-go120, goversion: '1.20' } + - { goos: windows, goarch: amd64, goamd64: v1, output: amd64-v1-go120, goversion: '1.20' } + - { goos: windows, goarch: amd64, goamd64: v2, output: amd64-v2-go120, goversion: '1.20' } + - { goos: windows, goarch: amd64, goamd64: v3, output: amd64-v3-go120, goversion: '1.20' } # Go 1.22 is the last release that will run on macOS 10.15 Catalina. Go 1.23 will require macOS 11 Big Sur or later. - { goos: darwin, goarch: arm64, output: arm64-go122, goversion: '1.22' } - - { goos: darwin, goarch: amd64, goamd64: v1, output: amd64-compatible-go122, goversion: '1.22' } - - { goos: darwin, goarch: amd64, goamd64: v3, output: amd64-go122, goversion: '1.22' } + - { goos: darwin, goarch: amd64, goamd64: v1, output: amd64-v1-go122, goversion: '1.22' } + - { goos: darwin, goarch: amd64, goamd64: v2, output: amd64-v2-go122, goversion: '1.22' } + - { goos: darwin, goarch: amd64, goamd64: v3, output: amd64-v3-go122, goversion: '1.22' } # Go 1.20 is the last release that will run on macOS 10.13 High Sierra or 10.14 Mojave. Go 1.21 will require macOS 10.15 Catalina or later. - { goos: darwin, goarch: arm64, output: arm64-go120, goversion: '1.20' } - - { goos: darwin, goarch: amd64, goamd64: v1, output: amd64-compatible-go120, goversion: '1.20' } - - { goos: darwin, goarch: amd64, goamd64: v3, output: amd64-go120, goversion: '1.20' } + - { goos: darwin, goarch: amd64, goamd64: v1, output: amd64-v1-go120, goversion: '1.20' } + - { goos: darwin, goarch: amd64, goamd64: v2, output: amd64-v2-go120, goversion: '1.20' } + - { goos: darwin, goarch: amd64, goamd64: v3, output: amd64-v3-go120, goversion: '1.20' } # Go 1.23 is the last release that requires Linux kernel version 2.6.32 or later. Go 1.24 will require Linux kernel version 3.2 or later. - { goos: linux, goarch: '386', output: '386-go123', goversion: '1.23' } - - { goos: linux, goarch: amd64, goamd64: v1, output: amd64-compatible-go123, goversion: '1.23', test: test } - - { goos: linux, goarch: amd64, goamd64: v3, output: amd64-go123, goversion: '1.23' } + - { goos: linux, goarch: amd64, goamd64: v1, output: amd64-v1-go123, goversion: '1.23', test: test } + - { goos: linux, goarch: amd64, goamd64: v2, output: amd64-v2-go123, goversion: '1.23' } + - { goos: linux, goarch: amd64, goamd64: v3, output: amd64-v3-go123, goversion: '1.23' } # only for test - { goos: linux, goarch: '386', output: '386-go120', goversion: '1.20' } - - { goos: linux, goarch: amd64, goamd64: v1, output: amd64-compatible-go120, goversion: '1.20', test: test } - - { goos: linux, goarch: amd64, goamd64: v3, output: amd64-go120, goversion: '1.20' } + - { goos: linux, goarch: amd64, goamd64: v1, output: amd64-v1-go120, goversion: '1.20', test: test } + - { goos: linux, goarch: amd64, goamd64: v2, output: amd64-v2-go120, goversion: '1.20' } + - { goos: linux, goarch: amd64, goamd64: v3, output: amd64-v3-go120, goversion: '1.20' } steps: - uses: actions/checkout@v4 diff --git a/Makefile b/Makefile index 36c640d5..e1646d35 100644 --- a/Makefile +++ b/Makefile @@ -17,11 +17,19 @@ GOBUILD=CGO_ENABLED=0 go build -tags with_gvisor -trimpath -ldflags '-X "github. -w -s -buildid=' PLATFORM_LIST = \ + darwin-386 \ darwin-amd64-compatible \ darwin-amd64 \ + darwin-amd64-v1 \ + darwin-amd64-v2 \ + darwin-amd64-v3 \ darwin-arm64 \ + linux-386 \ linux-amd64-compatible \ linux-amd64 \ + linux-amd64-v1 \ + linux-amd64-v2 \ + linux-amd64-v3 \ linux-armv5 \ linux-armv6 \ linux-armv7 \ @@ -43,37 +51,61 @@ WINDOWS_ARCH_LIST = \ windows-386 \ windows-amd64-compatible \ windows-amd64 \ + windows-amd64-v1 \ + windows-amd64-v2 \ + windows-amd64-v3 \ windows-arm64 \ windows-arm32v7 -all:linux-amd64 linux-arm64\ - darwin-amd64 darwin-arm64\ - windows-amd64 windows-arm64\ +all:linux-amd64-v3 linux-arm64\ + darwin-amd64-v3 darwin-arm64\ + windows-amd64-v3 windows-arm64\ -darwin-all: darwin-amd64 darwin-arm64 +darwin-all: darwin-amd64-v3 darwin-arm64 docker: GOAMD64=v1 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ -darwin-amd64: - GOARCH=amd64 GOOS=darwin GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ +darwin-386: + GOARCH=386 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ darwin-amd64-compatible: GOARCH=amd64 GOOS=darwin GOAMD64=v1 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ +darwin-amd64: + GOARCH=amd64 GOOS=darwin GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ + +darwin-amd64-v1: + GOARCH=amd64 GOOS=darwin GOAMD64=v1 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ + +darwin-amd64-v2: + GOARCH=amd64 GOOS=darwin GOAMD64=v2 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ + +darwin-amd64-v3: + GOARCH=amd64 GOOS=darwin GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ + darwin-arm64: GOARCH=arm64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ linux-386: GOARCH=386 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ +linux-amd64-compatible: + GOARCH=amd64 GOOS=linux GOAMD64=v1 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ + linux-amd64: GOARCH=amd64 GOOS=linux GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ -linux-amd64-compatible: +linux-amd64-v1: GOARCH=amd64 GOOS=linux GOAMD64=v1 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ +linux-amd64-v2: + GOARCH=amd64 GOOS=linux GOAMD64=v2 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ + +linux-amd64-v3: + GOARCH=amd64 GOOS=linux GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ + linux-arm64: GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ @@ -125,12 +157,21 @@ freebsd-arm64: windows-386: GOARCH=386 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe +windows-amd64-compatible: + GOARCH=amd64 GOOS=windows GOAMD64=v1 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe + windows-amd64: GOARCH=amd64 GOOS=windows GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe -windows-amd64-compatible: +windows-amd64-v1: GOARCH=amd64 GOOS=windows GOAMD64=v1 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe +windows-amd64-v2: + GOARCH=amd64 GOOS=windows GOAMD64=v2 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe + +windows-amd64-v3: + GOARCH=amd64 GOOS=windows GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe + windows-arm64: GOARCH=arm64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe diff --git a/component/updater/update_core.go b/component/updater/update_core.go index 97ae0d50..fd665b18 100644 --- a/component/updater/update_core.go +++ b/component/updater/update_core.go @@ -23,9 +23,9 @@ import ( // modify from https://github.com/AdguardTeam/AdGuardHome/blob/595484e0b3fb4c457f9bb727a6b94faa78a66c5f/internal/updater/updater.go // Updater is the mihomo updater. var ( - goarm string - gomips string - amd64Compatible string + goarm string + gomips string + goamd64 string workDir string @@ -46,8 +46,15 @@ var ( ) func init() { - if runtime.GOARCH == "amd64" && getGOAMD64level() < 3 { - amd64Compatible = "-compatible" + if runtime.GOARCH == "amd64" { + switch getGOAMD64level() { + case 1: + goamd64 = "-v1" + case 2: + goamd64 = "-v2" + case 3: + goamd64 = "-v3" + } } if !strings.HasPrefix(C.Version, "alpha") { baseURL = "https://github.com/MetaCubeX/mihomo/releases/latest/download/mihomo" @@ -137,11 +144,11 @@ func prepare(exePath string) (err error) { backupDir = filepath.Join(workDir, "meta-backup") if runtime.GOOS == "windows" { - updateExeName = "mihomo" + "-" + runtime.GOOS + "-" + runtime.GOARCH + amd64Compatible + ".exe" + updateExeName = "mihomo" + "-" + runtime.GOOS + "-" + runtime.GOARCH + goamd64 + ".exe" } else if runtime.GOOS == "android" && runtime.GOARCH == "arm64" { updateExeName = "mihomo-android-arm64-v8" } else { - updateExeName = "mihomo" + "-" + runtime.GOOS + "-" + runtime.GOARCH + amd64Compatible + updateExeName = "mihomo" + "-" + runtime.GOOS + "-" + runtime.GOARCH + goamd64 } log.Infoln("updateExeName: %s ", updateExeName) @@ -451,7 +458,7 @@ func updateDownloadURL() { } else if isMIPS(runtime.GOARCH) && gomips != "" { middle = fmt.Sprintf("-%s-%s-%s-%s", runtime.GOOS, runtime.GOARCH, gomips, latestVersion) } else { - middle = fmt.Sprintf("-%s-%s%s-%s", runtime.GOOS, runtime.GOARCH, amd64Compatible, latestVersion) + middle = fmt.Sprintf("-%s-%s%s-%s", runtime.GOOS, runtime.GOARCH, goamd64, latestVersion) } if runtime.GOOS == "windows" { diff --git a/docker/file-name.sh b/docker/file-name.sh index 3b2d61f9..21cb61ef 100644 --- a/docker/file-name.sh +++ b/docker/file-name.sh @@ -2,7 +2,7 @@ os="mihomo-linux-" case $TARGETPLATFORM in "linux/amd64") - arch="amd64-compatible" + arch="amd64-v1" ;; "linux/386") arch="386"