Skip to content

Commit

Permalink
Disable symbol table and DWARF generation by default.
Browse files Browse the repository at this point in the history
Trimpath if compiling with Go >= 1.13
  • Loading branch information
jyap808 committed Dec 26, 2019
1 parent 2fc29f9 commit 638f2a2
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ func doInstall(cmdline []string) {
flag.CommandLine.Parse(cmdline)
env := build.Env()

// Figure out the minor version number since we can't textually compare (1.10 < 1.9)
var minor int
fmt.Sscanf(strings.TrimPrefix(runtime.Version(), "go1."), "%d", &minor)

// Check Go version. People regularly open issues about compilation
// failure with outdated Go. This should save them the trouble.
if !strings.Contains(runtime.Version(), "devel") {
// Figure out the minor version number since we can't textually compare (1.10 < 1.9)
var minor int
fmt.Sscanf(strings.TrimPrefix(runtime.Version(), "go1."), "%d", &minor)

if minor < 9 {
log.Println("You have Go version", runtime.Version())
log.Println("go-ethereum requires at least Go version 1.9 and cannot")
Expand All @@ -210,6 +210,9 @@ func doInstall(cmdline []string) {

if *arch == "" || *arch == runtime.GOARCH {
goinstall := goTool("install", buildFlags(env)...)
if minor >= 13 {
goinstall.Args = append(goinstall.Args, "-trimpath")
}
goinstall.Args = append(goinstall.Args, "-v")
goinstall.Args = append(goinstall.Args, packages...)
build.MustRun(goinstall)
Expand All @@ -224,6 +227,9 @@ func doInstall(cmdline []string) {
}
// Seems we are cross compiling, work around forbidden GOBIN
goinstall := goToolArch(*arch, *cc, "install", buildFlags(env)...)
if minor >= 13 {
goinstall.Args = append(goinstall.Args, "-trimpath")
}
goinstall.Args = append(goinstall.Args, "-v")
goinstall.Args = append(goinstall.Args, []string{"-buildmode", "archive"}...)
goinstall.Args = append(goinstall.Args, packages...)
Expand Down Expand Up @@ -253,9 +259,7 @@ func buildFlags(env build.Environment) (flags []string) {
var ld []string
if env.Commit != "" {
ld = append(ld, "-X", "main.gitCommit="+env.Commit)
}
if runtime.GOOS == "darwin" {
ld = append(ld, "-s")
ld = append(ld, "-s", "-w")
}

if len(ld) > 0 {
Expand Down

0 comments on commit 638f2a2

Please sign in to comment.