From e636f6f51c073b7539b01fc2fcc7c17e25e29294 Mon Sep 17 00:00:00 2001 From: Mikio Hara Date: Thu, 22 Dec 2011 23:18:34 +0900 Subject: [PATCH] cmd/gc: make sure use of pthread for gcc-4.5 and beyond R=golang-dev, rsc, n13m3y3r, rogpeppe CC=golang-dev https://golang.org/cl/5501060 --- src/cmd/go/build.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go index b79a522dc90..62c8d90d304 100644 --- a/src/cmd/go/build.go +++ b/src/cmd/go/build.go @@ -912,6 +912,16 @@ func (b *builder) gccCmd(objdir string, flags []string, args ...string) []string case "6": a = append(a, "-m64") } + // gcc-4.5 and beyond require explicit "-pthread" flag + // for multithreading with pthread library. + if build.DefaultContext.CgoEnabled { + switch b.goos { + case "windows": + a = append(a, "-mthread") + default: + a = append(a, "-pthread") + } + } a = append(a, flags...) return append(a, args...) }