Go-ethereum编译过程分析(一)

督飞羽
2023-12-01

入口文件:Makefile 指定编译对象(geth为例),直接调用build/env.sh,初始化一些环境,然后直接调用go run build/ci.go install ./cmd/geth 运行ci.go,ci.go被当作编译脚本使用,拼接编译字符串,geth为例,得到编译字符串:


   cmd:
      0(string) "/usr/local/go/bin/go"
      1(string) "install"
      2(string) "-ldflags"
      3(string) "-X main.gitCommit=7e8988470090554fbedd46b6d50df8cd30ab085d"
      4(string) "-v"
      5(string) "./cmd/geth"

即:go install -ldflags -X main.gitCommit=7e8988470090554fbedd46b6d50df8cd30ab085d -v ./cmd/geth

即编译./cmd/geth工程

 类似资料: