From: Ian Lance Taylor Date: Fri, 16 Jul 2010 18:01:04 +0000 (-0700) Subject: cgo: If CC is set in environment, use it rather than "gcc". X-Git-Tag: weekly.2010-07-29~89 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8a95821694e8aa126446d9fc2d6fa63961d191d3;p=gostls13.git cgo: If CC is set in environment, use it rather than "gcc". R=rsc CC=golang-dev https://golang.org/cl/1842042 --- diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index 7638e32d85..6cfd4d4646 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -450,6 +450,16 @@ func (p *Package) rewriteRef(f *File) { } } +// gccName returns the name of the compiler to run. Use CC if set in +// the environment, otherwise just "gcc". + +func (p *Package) gccName() (ret string) { + if ret = os.Getenv("CC"); ret == "" { + ret = "gcc" + } + return +} + // gccMachine returns the gcc -m flag to use, either "-m32" or "-m64". func (p *Package) gccMachine() string { if p.PtrSize == 8 { @@ -464,7 +474,7 @@ const gccTmp = "_cgo_.o" // the input. func (p *Package) gccCmd() []string { return []string{ - "gcc", + p.gccName(), p.gccMachine(), "-Wall", // many warnings "-Werror", // warnings are errors @@ -506,7 +516,7 @@ func (p *Package) gccDebug(stdin []byte) *dwarf.Data { // #defines that gcc encountered while processing the input // and its included files. func (p *Package) gccDefines(stdin []byte) string { - base := []string{"gcc", p.gccMachine(), "-E", "-dM", "-xc", "-"} + base := []string{p.gccName(), p.gccMachine(), "-E", "-dM", "-xc", "-"} stdout, _ := runGcc(stdin, concat(base, p.GccOptions)) return stdout }