使用旧配置前先确认内核
先确认正在使用的内核,再决定是否采用旧配置;历史版本的限制不能直接套用到其他实现。涉及权限或平台能力时,应核对对应项目说明。
获取可执行程序有现成构建和源码构建两条路径,选择时应先核对目标设备。
预编译程序的获取与核对
查找已有构建时,先从发布来源核对文件说明,再参考下方的分支介绍:增强分支的获取说明
在本机构建程序
本机具备 Go 编译环境后,可参考下面的构建命令;环境要求应核对对应源码说明:
shell
$ go install github.com/Dreamacro/clash@latest
go: downloading github.com/Dreamacro/clash version-unrecorded构建产物所在的位置为 $GOPATH/bin,运行前可先核对该路径:
shell
$ $GOPATH/bin/clash -v
程序版本 unknown version darwin arm64 with go-version-unrecorded unknown time面向目标平台构建
目标设备与构建机器不一致时,可以利用 Go 的交叉编译能力。示例通过 make 选择构建目标,随后检查生成文件:
shell
$ git clone --depth 1 https://github.com/Dreamacro/clash
Cloning into 'clash'...
remote: Enumerating objects: …, done.
remote: Counting objects: …(进度略) (计数略), done.
remote: Compressing objects: …(进度略) (计数略), done.
remote: Total … (delta …), reused … (delta …), pack-reused …
Receiving objects: …(进度略) (计数与传输量略) | … (传输速率略), done.
Resolving deltas: …(进度略) (计数略), done.
$ cd clash && make darwin-arm64
fatal: No names found, cannot describe anything.
GOARCH=arm64 GOOS=darwin CGO_ENABLED=0 go build -trimpath -ldflags '-X "github.com/Dreamacro/clash/constant.Version=unknown" -X "github.com/Dreamacro/clash/constant.BuildTime=unknown" -w -s -buildid=' -o bin/clash-darwin-arm64
$ file bin/clash-darwin-arm64
bin/clash-darwin-arm64: Mach-O 64-bit executable arm64还需选择其他系统或架构时,可继续查阅 跨平台构建指引。
