Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(917)

Side by Side Diff: src/pkg/go/build/build.go

Issue 8134043: code review 8134043: go/build: disable cgo when cross compiling (Closed)
Patch Set: diff -r c81bb3def1ef https://code.google.com/p/go Created 11 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package build 5 package build
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "errors" 9 "errors"
10 "fmt" 10 "fmt"
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // c.ReleaseTags = []string{"go1.1", "go1.2", "go1.3"} 294 // c.ReleaseTags = []string{"go1.1", "go1.2", "go1.3"}
295 // and so on. 295 // and so on.
296 c.ReleaseTags = []string{"go1.1"} 296 c.ReleaseTags = []string{"go1.1"}
297 297
298 switch os.Getenv("CGO_ENABLED") { 298 switch os.Getenv("CGO_ENABLED") {
299 case "1": 299 case "1":
300 c.CgoEnabled = true 300 c.CgoEnabled = true
301 case "0": 301 case "0":
302 c.CgoEnabled = false 302 c.CgoEnabled = false
303 default: 303 default:
304 » » c.CgoEnabled = cgoEnabled[c.GOOS+"/"+c.GOARCH] 304 » » // golang.org/issue/5141
305 » » // cgo should only be enabled for non cross compilation builds.
306 » » if runtime.GOARCH == c.GOARCH && runtime.GOOS == c.GOOS {
minux1 2013/03/30 10:51:46 i suggest we just use runtime.GOOS == c.GOOS for t
307 » » » c.CgoEnabled = cgoEnabled[c.GOOS+"/"+c.GOARCH]
308 » » » break
309 » » }
310 » » // linux is a special case, cgo will work cross compiling from
311 » » // amd64 to 386 but not the other way around.
dfc 2013/03/30 05:12:13 I suspect this section might need some tweaking. I
312 » » if runtime.GOOS == "linux" && c.GOOS == "linux" && runtime.GOARC H == "amd64" && c.GOARCH == "386" {
313 » » » c.CgoEnabled = true
314 » » » break
315 » » }
316 » » c.CgoEnabled = false
305 } 317 }
306 318
307 return c 319 return c
308 } 320 }
309 321
310 func envOr(name, def string) string { 322 func envOr(name, def string) string {
311 s := os.Getenv(name) 323 s := os.Getenv(name)
312 if s == "" { 324 if s == "" {
313 return def 325 return def
314 } 326 }
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 switch goarch { 1120 switch goarch {
1109 case "386": 1121 case "386":
1110 return "8", nil 1122 return "8", nil
1111 case "amd64": 1123 case "amd64":
1112 return "6", nil 1124 return "6", nil
1113 case "arm": 1125 case "arm":
1114 return "5", nil 1126 return "5", nil
1115 } 1127 }
1116 return "", errors.New("unsupported GOARCH " + goarch) 1128 return "", errors.New("unsupported GOARCH " + goarch)
1117 } 1129 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b