| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 main | 5 package main |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bufio" | 8 "bufio" |
| 9 "bytes" | 9 "bytes" |
| 10 "container/heap" | 10 "container/heap" |
| (...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1734 } | 1734 } |
| 1735 } | 1735 } |
| 1736 if !extld { | 1736 if !extld { |
| 1737 var compiler []string | 1737 var compiler []string |
| 1738 if cxx { | 1738 if cxx { |
| 1739 compiler = envList("CXX", defaultCXX) | 1739 compiler = envList("CXX", defaultCXX) |
| 1740 } else { | 1740 } else { |
| 1741 compiler = envList("CC", defaultCC) | 1741 compiler = envList("CC", defaultCC) |
| 1742 } | 1742 } |
| 1743 ldflags = append(ldflags, "-extld="+compiler[0]) | 1743 ldflags = append(ldflags, "-extld="+compiler[0]) |
| 1744 if goos == "android" { | |
| 1745 compiler = append(compiler, "-llog") | |
|
minux
2014/07/02 04:21:14
put -llog as a #cgo LDFLAGS in runtime/cgo/cgo.go
dave_cheney.net
2014/07/02 04:33:05
yup, good idea
crawshaw
2014/07/02 14:57:21
Done.
| |
| 1746 } | |
| 1744 if len(compiler) > 1 { | 1747 if len(compiler) > 1 { |
| 1745 extldflags := false | 1748 extldflags := false |
| 1746 add := strings.Join(compiler[1:], " ") | 1749 add := strings.Join(compiler[1:], " ") |
| 1747 for i, f := range ldflags { | 1750 for i, f := range ldflags { |
| 1748 if f == "-extldflags" && i+1 < len(ldflags) { | 1751 if f == "-extldflags" && i+1 < len(ldflags) { |
| 1749 ldflags[i+1] = add + " " + ldflags[i+1] | 1752 ldflags[i+1] = add + " " + ldflags[i+1] |
| 1750 extldflags = true | 1753 extldflags = true |
| 1751 break | 1754 break |
| 1752 } else if strings.HasPrefix(f, "-extldflags=") { | 1755 } else if strings.HasPrefix(f, "-extldflags=") { |
| 1753 ldflags[i] = "-extldflags=" + add + " " + ldflags[i][len("-extldflags="):] | 1756 ldflags[i] = "-extldflags=" + add + " " + ldflags[i][len("-extldflags="):] |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2255 ofile := obj + cgoRe.ReplaceAllString(file, "_") + ".o" | 2258 ofile := obj + cgoRe.ReplaceAllString(file, "_") + ".o" |
| 2256 if err := b.gcc(p, ofile, cflags, file); err != nil { | 2259 if err := b.gcc(p, ofile, cflags, file); err != nil { |
| 2257 return nil, nil, err | 2260 return nil, nil, err |
| 2258 } | 2261 } |
| 2259 linkobj = append(linkobj, ofile) | 2262 linkobj = append(linkobj, ofile) |
| 2260 outObj = append(outObj, ofile) | 2263 outObj = append(outObj, ofile) |
| 2261 } | 2264 } |
| 2262 | 2265 |
| 2263 linkobj = append(linkobj, p.SysoFiles...) | 2266 linkobj = append(linkobj, p.SysoFiles...) |
| 2264 dynobj := obj + "_cgo_.o" | 2267 dynobj := obj + "_cgo_.o" |
| 2265 » if goarch == "arm" && goos == "linux" { // we need to use -pie for Linux /ARM to get accurate imported sym | 2268 » if goos == "android" { |
| 2269 » » cgoLDFLAGS = append(cgoLDFLAGS, "-llog") | |
| 2270 » } | |
| 2271 » if goarch == "arm" && (goos == "linux" || goos == "android") { // we nee d to use -pie for Linux/ARM to get accurate imported sym | |
| 2266 cgoLDFLAGS = append(cgoLDFLAGS, "-pie") | 2272 cgoLDFLAGS = append(cgoLDFLAGS, "-pie") |
| 2267 } | 2273 } |
| 2268 if err := b.gccld(p, dynobj, cgoLDFLAGS, linkobj); err != nil { | 2274 if err := b.gccld(p, dynobj, cgoLDFLAGS, linkobj); err != nil { |
| 2269 return nil, nil, err | 2275 return nil, nil, err |
| 2270 } | 2276 } |
| 2271 if goarch == "arm" && goos == "linux" { // but we don't need -pie for no rmal cgo programs | 2277 if goarch == "arm" && goos == "linux" { // but we don't need -pie for no rmal cgo programs |
| 2272 cgoLDFLAGS = cgoLDFLAGS[0 : len(cgoLDFLAGS)-1] | 2278 cgoLDFLAGS = cgoLDFLAGS[0 : len(cgoLDFLAGS)-1] |
| 2273 } | 2279 } |
| 2274 | 2280 |
| 2275 if _, ok := buildToolchain.(gccgoToolchain); ok { | 2281 if _, ok := buildToolchain.(gccgoToolchain); ok { |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2575 func defaultSuffix() string { | 2581 func defaultSuffix() string { |
| 2576 switch runtime.GOOS { | 2582 switch runtime.GOOS { |
| 2577 case "windows": | 2583 case "windows": |
| 2578 return ".bat" | 2584 return ".bat" |
| 2579 case "plan9": | 2585 case "plan9": |
| 2580 return ".rc" | 2586 return ".rc" |
| 2581 default: | 2587 default: |
| 2582 return ".bash" | 2588 return ".bash" |
| 2583 } | 2589 } |
| 2584 } | 2590 } |
| OLD | NEW |