]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: make sure use of pthread for gcc-4.5 and beyond
authorMikio Hara <mikioh.mikioh@gmail.com>
Thu, 22 Dec 2011 14:18:34 +0000 (23:18 +0900)
committerMikio Hara <mikioh.mikioh@gmail.com>
Thu, 22 Dec 2011 14:18:34 +0000 (23:18 +0900)
R=golang-dev, rsc, n13m3y3r, rogpeppe
CC=golang-dev
https://golang.org/cl/5501060

src/cmd/go/build.go

index b79a522dc901d592b1bb48f6c9083d2e6e600e9f..62c8d90d304efafed93c1e1c5f47da57d7aa7cd6 100644 (file)
@@ -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...)
 }