mirror of
https://github.com/golang/go
synced 2024-11-26 03:17:57 -07:00
cmd/go: cgo for Linux/ARM
Part 4 of CL 5601044 (cgo: Linux/ARM support) R=golang-dev, dave, rsc CC=golang-dev https://golang.org/cl/5989058
This commit is contained in:
parent
9602dd5e87
commit
e7a0a7595a
@ -1394,6 +1394,8 @@ func (b *builder) gccCmd(objdir string) []string {
|
|||||||
a = append(a, "-m32")
|
a = append(a, "-m32")
|
||||||
case "6":
|
case "6":
|
||||||
a = append(a, "-m64")
|
a = append(a, "-m64")
|
||||||
|
case "5":
|
||||||
|
a = append(a, "-marm") // not thumb
|
||||||
}
|
}
|
||||||
// gcc-4.5 and beyond require explicit "-pthread" flag
|
// gcc-4.5 and beyond require explicit "-pthread" flag
|
||||||
// for multithreading with pthread library.
|
// for multithreading with pthread library.
|
||||||
@ -1513,9 +1515,15 @@ func (b *builder) cgo(p *Package, cgoExe, obj string, gccfiles []string) (outGo,
|
|||||||
outObj = append(outObj, ofile)
|
outObj = append(outObj, ofile)
|
||||||
}
|
}
|
||||||
dynobj := obj + "_cgo_.o"
|
dynobj := obj + "_cgo_.o"
|
||||||
|
if goarch == "arm" && goos == "linux" { // we need to use -pie for Linux/ARM to get accurate imported sym
|
||||||
|
cgoLDFLAGS = append(cgoLDFLAGS, "-pie")
|
||||||
|
}
|
||||||
if err := b.gccld(p, dynobj, cgoLDFLAGS, linkobj); err != nil {
|
if err := b.gccld(p, dynobj, cgoLDFLAGS, linkobj); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
if goarch == "arm" && goos == "linux" { // but we don't need -pie for normal cgo programs
|
||||||
|
cgoLDFLAGS = cgoLDFLAGS[0 : len(cgoLDFLAGS)-1]
|
||||||
|
}
|
||||||
|
|
||||||
if _, ok := buildToolchain.(gccgcToolchain); ok {
|
if _, ok := buildToolchain.(gccgcToolchain); ok {
|
||||||
// we don't use dynimport when using gccgo.
|
// we don't use dynimport when using gccgo.
|
||||||
|
Loading…
Reference in New Issue
Block a user