Skip to content

Commit e0fb4d1

Browse files
committed
build: work around CGO linker bug on pre-1.8 Go
1 parent ac2a0e6 commit e0fb4d1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

build/ci.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ func goToolArch(arch string, subcmd string, args ...string) *exec.Cmd {
236236
gocmd := filepath.Join(runtime.GOROOT(), "bin", "go")
237237
cmd := exec.Command(gocmd, subcmd)
238238
cmd.Args = append(cmd.Args, args...)
239+
240+
if subcmd == "build" || subcmd == "install" || subcmd == "test" {
241+
// Go CGO has a Windows linker error prior to 1.8 (https://github.com/golang/go/issues/8756).
242+
// Work around issue by allowing multiple definitions for <1.8 builds.
243+
if runtime.GOOS == "windows" && runtime.Version() < "go1.8" {
244+
cmd.Args = append(cmd.Args, []string{"-ldflags", "-extldflags -Wl,--allow-multiple-definition"}...)
245+
}
246+
}
239247
cmd.Env = []string{
240248
"GO15VENDOREXPERIMENT=1",
241249
"GOPATH=" + build.GOPATH(),

0 commit comments

Comments
 (0)