build: fix version comparison for go1.10 and beyond (#15781)

pull/15807/head
Péter Szilágyi 7 years ago committed by Felix Lange
parent 6882943e39
commit 2fe07c203e
  1. 21
      build/ci.go

@ -179,11 +179,17 @@ func doInstall(cmdline []string) {
// Check Go version. People regularly open issues about compilation // Check Go version. People regularly open issues about compilation
// failure with outdated Go. This should save them the trouble. // failure with outdated Go. This should save them the trouble.
if runtime.Version() < "go1.7" && !strings.Contains(runtime.Version(), "devel") { if !strings.Contains(runtime.Version(), "devel") {
log.Println("You have Go version", runtime.Version()) // Figure out the minor version number since we can't textually compare (1.10 < 1.7)
log.Println("go-ethereum requires at least Go version 1.7 and cannot") var minor int
log.Println("be compiled with an earlier version. Please upgrade your Go installation.") fmt.Sscanf(strings.TrimPrefix(runtime.Version(), "go1."), "%d", &minor)
os.Exit(1)
if minor < 7 {
log.Println("You have Go version", runtime.Version())
log.Println("go-ethereum requires at least Go version 1.7 and cannot")
log.Println("be compiled with an earlier version. Please upgrade your Go installation.")
os.Exit(1)
}
} }
// Compile packages given as arguments, or everything if there are no arguments. // Compile packages given as arguments, or everything if there are no arguments.
packages := []string{"./..."} packages := []string{"./..."}
@ -257,7 +263,10 @@ func goToolArch(arch string, subcmd string, args ...string) *exec.Cmd {
if subcmd == "build" || subcmd == "install" || subcmd == "test" { if subcmd == "build" || subcmd == "install" || subcmd == "test" {
// Go CGO has a Windows linker error prior to 1.8 (https://github.com/golang/go/issues/8756). // Go CGO has a Windows linker error prior to 1.8 (https://github.com/golang/go/issues/8756).
// Work around issue by allowing multiple definitions for <1.8 builds. // Work around issue by allowing multiple definitions for <1.8 builds.
if runtime.GOOS == "windows" && runtime.Version() < "go1.8" { var minor int
fmt.Sscanf(strings.TrimPrefix(runtime.Version(), "go1."), "%d", &minor)
if runtime.GOOS == "windows" && minor < 8 {
cmd.Args = append(cmd.Args, []string{"-ldflags", "-extldflags -Wl,--allow-multiple-definition"}...) cmd.Args = append(cmd.Args, []string{"-ldflags", "-extldflags -Wl,--allow-multiple-definition"}...)
} }
} }

Loading…
Cancel
Save