mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: more robust detection of clang
Fixes #10453. Change-Id: I77470279865d4c954df615d6594c69edf68c28ca Reviewed-on: https://go-review.googlesource.com/9090 Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
05efc18c20
commit
93402383ea
3 changed files with 7 additions and 2 deletions
|
|
@ -199,6 +199,10 @@ func (p *Package) loadDefines(f *File) {
|
||||||
val = strings.TrimSpace(line[tabIndex:])
|
val = strings.TrimSpace(line[tabIndex:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if key == "__clang__" {
|
||||||
|
p.GccIsClang = true
|
||||||
|
}
|
||||||
|
|
||||||
if n := f.Name[key]; n != nil {
|
if n := f.Name[key]; n != nil {
|
||||||
if *debugDefine {
|
if *debugDefine {
|
||||||
fmt.Fprintf(os.Stderr, "#define %s %s\n", key, val)
|
fmt.Fprintf(os.Stderr, "#define %s %s\n", key, val)
|
||||||
|
|
@ -762,7 +766,7 @@ func (p *Package) gccCmd() []string {
|
||||||
"-c", // do not link
|
"-c", // do not link
|
||||||
"-xc", // input language is C
|
"-xc", // input language is C
|
||||||
)
|
)
|
||||||
if strings.Contains(c[0], "clang") {
|
if p.GccIsClang {
|
||||||
c = append(c,
|
c = append(c,
|
||||||
"-ferror-limit=0",
|
"-ferror-limit=0",
|
||||||
// Apple clang version 1.7 (tags/Apple/clang-77) (based on LLVM 2.9svn)
|
// Apple clang version 1.7 (tags/Apple/clang-77) (based on LLVM 2.9svn)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ type Package struct {
|
||||||
PtrSize int64
|
PtrSize int64
|
||||||
IntSize int64
|
IntSize int64
|
||||||
GccOptions []string
|
GccOptions []string
|
||||||
|
GccIsClang bool
|
||||||
CgoFlags map[string][]string // #cgo flags (CFLAGS, LDFLAGS)
|
CgoFlags map[string][]string // #cgo flags (CFLAGS, LDFLAGS)
|
||||||
Written map[string]bool
|
Written map[string]bool
|
||||||
Name map[string]*Name // accumulated Name from Files
|
Name map[string]*Name // accumulated Name from Files
|
||||||
|
|
|
||||||
|
|
@ -626,7 +626,7 @@ func (p *Package) writeGccgoOutputFunc(fgcc *os.File, n *Name) {
|
||||||
// and http://golang.org/issue/5603.
|
// and http://golang.org/issue/5603.
|
||||||
func (p *Package) packedAttribute() string {
|
func (p *Package) packedAttribute() string {
|
||||||
s := "__attribute__((__packed__"
|
s := "__attribute__((__packed__"
|
||||||
if !strings.Contains(p.gccBaseCmd()[0], "clang") && (goarch == "amd64" || goarch == "386") {
|
if !p.GccIsClang && (goarch == "amd64" || goarch == "386") {
|
||||||
s += ", __gcc_struct__"
|
s += ", __gcc_struct__"
|
||||||
}
|
}
|
||||||
return s + "))"
|
return s + "))"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue