From c43e1d5e0bb5f1335bb8a277d99e9fdb09b057b4 Mon Sep 17 00:00:00 2001 From: Julian Yap Date: Sat, 25 Jul 2020 23:29:14 -0700 Subject: [PATCH 1/2] Disable symbol table and DWARF generation by default. Trimpath if compiling with Go >= 1.13 --- build/ci.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/build/ci.go b/build/ci.go index 70caef74d7bb..5c98077a144b 100644 --- a/build/ci.go +++ b/build/ci.go @@ -210,11 +210,10 @@ func doInstall(cmdline []string) { // Check Go version. People regularly open issues about compilation // failure with outdated Go. This should save them the trouble. + // 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 !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 < 11 { log.Println("You have Go version", runtime.Version()) log.Println("go-ethereum requires at least Go version 1.11 and cannot") @@ -230,6 +229,9 @@ func doInstall(cmdline []string) { if *arch == "" || *arch == runtime.GOARCH { goinstall := goTool("install", buildFlags(env)...) + if minor >= 13 { + goinstall.Args = append(goinstall.Args, "-trimpath") + } if runtime.GOARCH == "arm64" { goinstall.Args = append(goinstall.Args, "-p", "1") } @@ -241,6 +243,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...) @@ -268,14 +273,11 @@ func doInstall(cmdline []string) { func buildFlags(env build.Environment) (flags []string) { var ld []string + ld = append(ld, "-s", "-w") if env.Commit != "" { ld = append(ld, "-X", "main.gitCommit="+env.Commit) ld = append(ld, "-X", "main.gitDate="+env.Date) } - if runtime.GOOS == "darwin" { - ld = append(ld, "-s") - } - if len(ld) > 0 { flags = append(flags, "-ldflags", strings.Join(ld, " ")) } From 801573a9558b273f08ed155296c35674590a01a9 Mon Sep 17 00:00:00 2001 From: Julian Yap Date: Tue, 28 Jul 2020 15:08:34 -0700 Subject: [PATCH 2/2] Set Go to minimum version 1.13. Revert debug symbol changes. --- build/ci.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/build/ci.go b/build/ci.go index 5c98077a144b..35c114dd9541 100644 --- a/build/ci.go +++ b/build/ci.go @@ -210,13 +210,14 @@ func doInstall(cmdline []string) { // Check Go version. People regularly open issues about compilation // failure with outdated Go. This should save them the trouble. - // 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 !strings.Contains(runtime.Version(), "devel") { - if minor < 11 { + // 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 < 13 { log.Println("You have Go version", runtime.Version()) - log.Println("go-ethereum requires at least Go version 1.11 and cannot") + log.Println("go-ethereum requires at least Go version 1.13 and cannot") log.Println("be compiled with an earlier version. Please upgrade your Go installation.") os.Exit(1) } @@ -229,12 +230,10 @@ func doInstall(cmdline []string) { if *arch == "" || *arch == runtime.GOARCH { goinstall := goTool("install", buildFlags(env)...) - if minor >= 13 { - goinstall.Args = append(goinstall.Args, "-trimpath") - } if runtime.GOARCH == "arm64" { goinstall.Args = append(goinstall.Args, "-p", "1") } + goinstall.Args = append(goinstall.Args, "-trimpath") goinstall.Args = append(goinstall.Args, "-v") goinstall.Args = append(goinstall.Args, packages...) build.MustRun(goinstall) @@ -243,9 +242,7 @@ 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, "-trimpath") goinstall.Args = append(goinstall.Args, "-v") goinstall.Args = append(goinstall.Args, []string{"-buildmode", "archive"}...) goinstall.Args = append(goinstall.Args, packages...) @@ -273,11 +270,14 @@ func doInstall(cmdline []string) { func buildFlags(env build.Environment) (flags []string) { var ld []string - ld = append(ld, "-s", "-w") if env.Commit != "" { ld = append(ld, "-X", "main.gitCommit="+env.Commit) ld = append(ld, "-X", "main.gitDate="+env.Date) } + if runtime.GOOS == "darwin" { + ld = append(ld, "-s") + } + if len(ld) > 0 { flags = append(flags, "-ldflags", strings.Join(ld, " ")) }