mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-20 17:10:08 +08:00
chore: use the compile-time GOAMD64 flag in the updater
Some checks are pending
Test / test (1.20, macos-13) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-13) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-13) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-13) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-13) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
Some checks are pending
Test / test (1.20, macos-13) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-13) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-13) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-13) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-13) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run
This commit is contained in:
parent
63ad95e10f
commit
9f1da11792
4
component/updater/cpu_amd64.go
Normal file
4
component/updater/cpu_amd64.go
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package updater
|
||||||
|
|
||||||
|
// getGOAMD64level is implemented in cpu_amd64.s. Returns number in [1,4].
|
||||||
|
func getGOAMD64level() int32
|
||||||
22
component/updater/cpu_amd64.s
Normal file
22
component/updater/cpu_amd64.s
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
// func getGOAMD64level() int32
|
||||||
|
TEXT ·getGOAMD64level(SB),NOSPLIT,$0-4
|
||||||
|
#ifdef GOAMD64_v4
|
||||||
|
MOVL $4, ret+0(FP)
|
||||||
|
#else
|
||||||
|
#ifdef GOAMD64_v3
|
||||||
|
MOVL $3, ret+0(FP)
|
||||||
|
#else
|
||||||
|
#ifdef GOAMD64_v2
|
||||||
|
MOVL $2, ret+0(FP)
|
||||||
|
#else
|
||||||
|
MOVL $1, ret+0(FP)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
RET
|
||||||
8
component/updater/cpu_others.go
Normal file
8
component/updater/cpu_others.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
//go:build !amd64
|
||||||
|
|
||||||
|
package updater
|
||||||
|
|
||||||
|
// getGOAMD64level is always return 0 when not in amd64 platfrom.
|
||||||
|
func getGOAMD64level() int32 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
20
component/updater/cpu_test.go
Normal file
20
component/updater/cpu_test.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package updater
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"runtime"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGOAMD64level(t *testing.T) {
|
||||||
|
level := getGOAMD64level()
|
||||||
|
fmt.Printf("GOAMD64=%d\n", level)
|
||||||
|
if runtime.GOARCH == "amd64" {
|
||||||
|
assert.True(t, level > 0)
|
||||||
|
assert.True(t, level <= 4)
|
||||||
|
} else {
|
||||||
|
assert.Equal(t, level, int32(0))
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -18,8 +18,6 @@ import (
|
|||||||
mihomoHttp "github.com/metacubex/mihomo/component/http"
|
mihomoHttp "github.com/metacubex/mihomo/component/http"
|
||||||
C "github.com/metacubex/mihomo/constant"
|
C "github.com/metacubex/mihomo/constant"
|
||||||
"github.com/metacubex/mihomo/log"
|
"github.com/metacubex/mihomo/log"
|
||||||
|
|
||||||
"github.com/klauspost/cpuid/v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// modify from https://github.com/AdguardTeam/AdGuardHome/blob/595484e0b3fb4c457f9bb727a6b94faa78a66c5f/internal/updater/updater.go
|
// modify from https://github.com/AdguardTeam/AdGuardHome/blob/595484e0b3fb4c457f9bb727a6b94faa78a66c5f/internal/updater/updater.go
|
||||||
@ -48,7 +46,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if runtime.GOARCH == "amd64" && cpuid.CPU.X64Level() < 3 {
|
if runtime.GOARCH == "amd64" && getGOAMD64level() < 3 {
|
||||||
amd64Compatible = "-compatible"
|
amd64Compatible = "-compatible"
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(C.Version, "alpha") {
|
if !strings.HasPrefix(C.Version, "alpha") {
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -14,7 +14,6 @@ require (
|
|||||||
github.com/gofrs/uuid/v5 v5.3.2
|
github.com/gofrs/uuid/v5 v5.3.2
|
||||||
github.com/insomniacslk/dhcp v0.0.0-20250109001534-8abf58130905
|
github.com/insomniacslk/dhcp v0.0.0-20250109001534-8abf58130905
|
||||||
github.com/klauspost/compress v1.17.9 // lastest version compatible with golang1.20
|
github.com/klauspost/compress v1.17.9 // lastest version compatible with golang1.20
|
||||||
github.com/klauspost/cpuid/v2 v2.2.9 // lastest version compatible with golang1.20
|
|
||||||
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40
|
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40
|
||||||
github.com/mdlayher/netlink v1.7.2
|
github.com/mdlayher/netlink v1.7.2
|
||||||
github.com/metacubex/amneziawg-go v0.0.0-20240922133038-fdf3a4d5a4ab
|
github.com/metacubex/amneziawg-go v0.0.0-20240922133038-fdf3a4d5a4ab
|
||||||
@ -86,6 +85,7 @@ require (
|
|||||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
|
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
|
||||||
github.com/hashicorp/yamux v0.1.2 // indirect
|
github.com/hashicorp/yamux v0.1.2 // indirect
|
||||||
github.com/josharian/native v1.1.0 // indirect
|
github.com/josharian/native v1.1.0 // indirect
|
||||||
|
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/kr/text v0.2.0 // indirect
|
||||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||||
github.com/mailru/easyjson v0.7.7 // indirect
|
github.com/mailru/easyjson v0.7.7 // indirect
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user