out := p.Name + ".o"
ofile = obj + out
gcargs := []string{"-g"}
+ gcargs = append(gcargs, b.gccArchArgs()...)
if pkgpath := gccgoPkgpath(p); pkgpath != "" {
gcargs = append(gcargs, "-fgo-pkgpath="+pkgpath)
}
if pkgpath := gccgoCleanPkgpath(p); pkgpath != "" {
defs = append(defs, `-D`, `GOPKGPATH="`+pkgpath+`"`)
}
+ defs = append(defs, b.gccArchArgs()...)
return b.run(p.Dir, p.ImportPath, "gccgo", "-I", obj, "-o", ofile, defs, sfile)
}
// and all LDFLAGS from cgo dependencies.
afiles := make(map[*Package]string)
sfiles := make(map[*Package][]string)
- ldflags := []string{}
+ ldflags := b.gccArchArgs()
cgoldflags := []string{}
usesCgo := false
for _, a := range allactions {
inc := filepath.Join(goroot, "pkg", fmt.Sprintf("%s_%s", goos, goarch))
cfile = mkAbs(p.Dir, cfile)
defs := []string{"-D", "GOOS_" + goos, "-D", "GOARCH_" + goarch}
+ defs = append(defs, b.gccArchArgs()...)
if pkgpath := gccgoCleanPkgpath(p); pkgpath != "" {
defs = append(defs, `-D`, `GOPKGPATH="`+pkgpath+`"`)
}
if goos != "windows" {
a = append(a, "-fPIC")
}
- switch archChar {
- case "8":
- a = append(a, "-m32")
- case "6":
- a = append(a, "-m64")
- case "5":
- a = append(a, "-marm") // not thumb
- }
+ a = append(a, b.gccArchArgs()...)
// gcc-4.5 and beyond require explicit "-pthread" flag
// for multithreading with pthread library.
if buildContext.CgoEnabled {
return a
}
+// gccArchArgs returns arguments to pass to gcc based on the architecture.
+func (b *builder) gccArchArgs() []string {
+ switch archChar {
+ case "8":
+ return []string{"-m32"}
+ case "6":
+ return []string{"-m64"}
+ case "5":
+ return []string{"-marm"} // not thumb
+ }
+ return nil
+}
+
func envList(key string) []string {
return strings.Fields(os.Getenv(key))
}