diff options
Diffstat (limited to 'libgo/go/cmd/cgo/main.go')
-rw-r--r-- | libgo/go/cmd/cgo/main.go | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/libgo/go/cmd/cgo/main.go b/libgo/go/cmd/cgo/main.go index 6171b9d067..c91c830260 100644 --- a/libgo/go/cmd/cgo/main.go +++ b/libgo/go/cmd/cgo/main.go @@ -1,4 +1,4 @@ -// Copyright 2009 The Go Authors. All rights reserved. +// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. @@ -42,7 +42,6 @@ type Package struct { GoFiles []string // list of Go files GccFiles []string // list of gcc output files Preamble string // collected preamble for _cgo_export.h - CgoChecks []string // see unsafeCheckPointerName } // A File collects information about a single Go input file. @@ -52,7 +51,7 @@ type File struct { Package string // Package name Preamble string // C preamble (doc comment on import "C") Ref []*Ref // all references to C.xxx in AST - Calls []*ast.CallExpr // all calls to C.xxx in AST + Calls []*Call // all calls to C.xxx in AST ExpFunc []*ExpFunc // exported functions for this file Name map[string]*Name // map from Go name to Name } @@ -66,6 +65,12 @@ func nameKeys(m map[string]*Name) []string { return ks } +// A Call refers to a call of a C.xxx function in the AST. +type Call struct { + Call *ast.CallExpr + Deferred bool +} + // A Ref refers to an expression of the form C.xxx in the AST. type Ref struct { Name *Name @@ -144,6 +149,8 @@ var ptrSizeMap = map[string]int64{ "mipsn32": 4, "mipso64": 8, "mipsn64": 8, + "mips": 4, + "mipsle": 4, "mips64": 8, "mips64le": 8, "ppc": 4, @@ -166,6 +173,8 @@ var intSizeMap = map[string]int64{ "mipsn32": 4, "mipso64": 8, "mipsn64": 8, + "mips": 4, + "mipsle": 4, "mips64": 8, "mips64le": 8, "ppc": 4, @@ -191,6 +200,7 @@ var dynlinker = flag.Bool("dynlinker", false, "record dynamic linker information // constant values used in the host's C libraries and system calls. var godefs = flag.Bool("godefs", false, "for bootstrap: write Go definitions for C file to standard output") +var srcDir = flag.String("srcdir", "", "source directory") var objDir = flag.String("objdir", "", "object directory") var importPath = flag.String("importpath", "", "import path of package being built (for comments in generated files)") var exportHeader = flag.String("exportheader", "", "where to write export header if any exported functions") @@ -208,9 +218,9 @@ func main() { if *dynobj != "" { // cgo -dynimport is essentially a separate helper command - // built into the cgo binary. It scans a gcc-produced executable + // built into the cgo binary. It scans a gcc-produced executable // and dumps information about the imported symbols and the - // imported libraries. The 'go build' rules for cgo prepare an + // imported libraries. The 'go build' rules for cgo prepare an // appropriate executable and then use its import information // instead of needing to make the linkers duplicate all the // specialized knowledge gcc has about where to look for imported @@ -245,6 +255,12 @@ func main() { goFiles := args[i:] + for _, arg := range args[:i] { + if arg == "-fsanitize=thread" { + tsanProlog = yesTsanProlog + } + } + p := newPackage(args[:i]) // Record CGO_LDFLAGS from the environment for external linking. @@ -263,6 +279,9 @@ func main() { // Use the beginning of the md5 of the input to disambiguate. h := md5.New() for _, input := range goFiles { + if *srcDir != "" { + input = filepath.Join(*srcDir, input) + } f, err := os.Open(input) if err != nil { fatalf("%s", err) @@ -274,6 +293,9 @@ func main() { fs := make([]*File, len(goFiles)) for i, input := range goFiles { + if *srcDir != "" { + input = filepath.Join(*srcDir, input) + } f := new(File) f.ReadGo(input) f.DiscardCgoDirectives() |