mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cgo: support non intel gcc machine flags
R=adg CC=golang-dev https://golang.org/cl/4528124
This commit is contained in:
parent
5e03143c1a
commit
4881e7744a
1 changed files with 10 additions and 6 deletions
|
|
@ -660,11 +660,14 @@ func (p *Package) gccName() (ret string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// gccMachine returns the gcc -m flag to use, either "-m32" or "-m64".
|
// gccMachine returns the gcc -m flag to use, either "-m32" or "-m64".
|
||||||
func (p *Package) gccMachine() string {
|
func (p *Package) gccMachine() []string {
|
||||||
if p.PtrSize == 8 {
|
switch runtime.GOARCH {
|
||||||
return "-m64"
|
case "amd64":
|
||||||
|
return []string{"-m64"}
|
||||||
|
case "386":
|
||||||
|
return []string{"-m32"}
|
||||||
}
|
}
|
||||||
return "-m32"
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const gccTmp = "_obj/_cgo_.o"
|
const gccTmp = "_obj/_cgo_.o"
|
||||||
|
|
@ -674,7 +677,6 @@ const gccTmp = "_obj/_cgo_.o"
|
||||||
func (p *Package) gccCmd() []string {
|
func (p *Package) gccCmd() []string {
|
||||||
c := []string{
|
c := []string{
|
||||||
p.gccName(),
|
p.gccName(),
|
||||||
p.gccMachine(),
|
|
||||||
"-Wall", // many warnings
|
"-Wall", // many warnings
|
||||||
"-Werror", // warnings are errors
|
"-Werror", // warnings are errors
|
||||||
"-o" + gccTmp, // write object to tmp
|
"-o" + gccTmp, // write object to tmp
|
||||||
|
|
@ -684,6 +686,7 @@ func (p *Package) gccCmd() []string {
|
||||||
"-xc", // input language is C
|
"-xc", // input language is C
|
||||||
}
|
}
|
||||||
c = append(c, p.GccOptions...)
|
c = append(c, p.GccOptions...)
|
||||||
|
c = append(c, p.gccMachine()...)
|
||||||
c = append(c, "-") //read input from standard input
|
c = append(c, "-") //read input from standard input
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
@ -719,7 +722,8 @@ func (p *Package) gccDebug(stdin []byte) *dwarf.Data {
|
||||||
// #defines that gcc encountered while processing the input
|
// #defines that gcc encountered while processing the input
|
||||||
// and its included files.
|
// and its included files.
|
||||||
func (p *Package) gccDefines(stdin []byte) string {
|
func (p *Package) gccDefines(stdin []byte) string {
|
||||||
base := []string{p.gccName(), p.gccMachine(), "-E", "-dM", "-xc"}
|
base := []string{p.gccName(), "-E", "-dM", "-xc"}
|
||||||
|
base = append(base, p.gccMachine()...)
|
||||||
stdout, _ := runGcc(stdin, append(append(base, p.GccOptions...), "-"))
|
stdout, _ := runGcc(stdin, append(append(base, p.GccOptions...), "-"))
|
||||||
return stdout
|
return stdout
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue