File tree Expand file tree Collapse file tree 6 files changed +56
-4
lines changed Expand file tree Collapse file tree 6 files changed +56
-4
lines changed Original file line number Diff line number Diff line change
1
+ package updater
2
+
3
+ // getGOAMD64level is implemented in cpu_amd64.s. Returns number in [1,4].
4
+ func getGOAMD64level () int32
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ #include "textflag.h"
6
+
7
+ // func getGOAMD64level() int32
8
+ TEXT ·getGOAMD64level(SB),NOSPLIT,$0 -4
9
+ #ifdef GOAMD64_v4
10
+ MOVL $4 , ret +0 (FP)
11
+ #else
12
+ #ifdef GOAMD64_v3
13
+ MOVL $3 , ret +0 (FP)
14
+ #else
15
+ #ifdef GOAMD64_v2
16
+ MOVL $2 , ret +0 (FP)
17
+ #else
18
+ MOVL $1 , ret +0 (FP)
19
+ #endif
20
+ #endif
21
+ #endif
22
+ RET
Original file line number Diff line number Diff line change
1
+ //go:build !amd64
2
+
3
+ package updater
4
+
5
+ // getGOAMD64level is always return 0 when not in amd64 platfrom.
6
+ func getGOAMD64level () int32 {
7
+ return 0
8
+ }
Original file line number Diff line number Diff line change
1
+ package updater
2
+
3
+ import (
4
+ "fmt"
5
+ "runtime"
6
+ "testing"
7
+
8
+ "github.com/stretchr/testify/assert"
9
+ )
10
+
11
+ func TestGOAMD64level (t * testing.T ) {
12
+ level := getGOAMD64level ()
13
+ fmt .Printf ("GOAMD64=%d\n " , level )
14
+ if runtime .GOARCH == "amd64" {
15
+ assert .True (t , level > 0 )
16
+ assert .True (t , level <= 4 )
17
+ } else {
18
+ assert .Equal (t , level , int32 (0 ))
19
+ }
20
+ }
Original file line number Diff line number Diff line change @@ -18,8 +18,6 @@ import (
18
18
mihomoHttp "github.com/metacubex/mihomo/component/http"
19
19
C "github.com/metacubex/mihomo/constant"
20
20
"github.com/metacubex/mihomo/log"
21
-
22
- "github.com/klauspost/cpuid/v2"
23
21
)
24
22
25
23
// modify from https://github.com/AdguardTeam/AdGuardHome/blob/595484e0b3fb4c457f9bb727a6b94faa78a66c5f/internal/updater/updater.go
48
46
)
49
47
50
48
func init () {
51
- if runtime .GOARCH == "amd64" && cpuid . CPU . X64Level () < 3 {
49
+ if runtime .GOARCH == "amd64" && getGOAMD64level () < 3 {
52
50
amd64Compatible = "-compatible"
53
51
}
54
52
if ! strings .HasPrefix (C .Version , "alpha" ) {
Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ require (
14
14
github.com/gofrs/uuid/v5 v5.3.2
15
15
github.com/insomniacslk/dhcp v0.0.0-20250109001534-8abf58130905
16
16
github.com/klauspost/compress v1.17.9 // lastest version compatible with golang1.20
17
- github.com/klauspost/cpuid/v2 v2.2.9 // lastest version compatible with golang1.20
18
17
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40
19
18
github.com/mdlayher/netlink v1.7.2
20
19
github.com/metacubex/amneziawg-go v0.0.0-20240922133038-fdf3a4d5a4ab
@@ -86,6 +85,7 @@ require (
86
85
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
87
86
github.com/hashicorp/yamux v0.1.2 // indirect
88
87
github.com/josharian/native v1.1.0 // indirect
88
+ github.com/klauspost/cpuid/v2 v2.2.9 // indirect
89
89
github.com/kr/text v0.2.0 // indirect
90
90
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
91
91
github.com/mailru/easyjson v0.7.7 // indirect
You can’t perform that action at this time.
0 commit comments