mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: add -dolinkobj flag
When set to false, the -dolinkobj flag instructs the compiler not to generate or emit linker information. This is handy when you need the compiler's export data, e.g. for use with go/importer, but you want to avoid the cost of full compilation. This must be used with care, since the resulting files are unusable for linking. This CL interacts with #18369, where adding gcflags and ldflags to buildid has been mooted. On the one hand, adding gcflags would make safe use of this flag easier, since if the full object files were needed, a simple 'go install' would fix it. On the other hand, this would mean that 'go install -gcflags=-dolinkobj=false' would rebuild the object files, although any existing object files would probably suffice. Change-Id: I8dc75ab5a40095c785c1a4d2260aeb63c4d10f73 Reviewed-on: https://go-review.googlesource.com/37384 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
2b2870fff8
commit
005c77dde8
3 changed files with 37 additions and 29 deletions
|
|
@ -118,6 +118,7 @@ var pragcgobuf string
|
|||
|
||||
var outfile string
|
||||
var linkobj string
|
||||
var dolinkobj bool
|
||||
|
||||
var bout *bio.Writer
|
||||
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ func Main() {
|
|||
obj.Flagcount("live", "debug liveness analysis", &debuglive)
|
||||
obj.Flagcount("m", "print optimization decisions", &Debug['m'])
|
||||
flag.BoolVar(&flag_msan, "msan", false, "build code compatible with C/C++ memory sanitizer")
|
||||
flag.BoolVar(&dolinkobj, "dolinkobj", true, "generate linker-specific objects; if false, some invalid code may compile")
|
||||
flag.BoolVar(&nolocalimports, "nolocalimports", false, "reject local (relative) imports")
|
||||
flag.StringVar(&outfile, "o", "", "write output to `file`")
|
||||
flag.StringVar(&myimportpath, "p", "", "set expected package import `path`")
|
||||
|
|
@ -450,6 +451,7 @@ func Main() {
|
|||
timings.Start("fe", "escapes")
|
||||
escapes(xtop)
|
||||
|
||||
if dolinkobj {
|
||||
// Phase 7: Transform closure bodies to properly reference captured variables.
|
||||
// This needs to happen before walk, because closures must be transformed
|
||||
// before walk reaches a call of a closure.
|
||||
|
|
@ -483,6 +485,7 @@ func Main() {
|
|||
if compiling_runtime {
|
||||
checknowritebarrierrec()
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 9: Check external declarations.
|
||||
timings.Start("be", "externaldcls")
|
||||
|
|
|
|||
|
|
@ -41,12 +41,16 @@ const (
|
|||
)
|
||||
|
||||
func dumpobj() {
|
||||
if !dolinkobj {
|
||||
dumpobj1(outfile, modeCompilerObj)
|
||||
return
|
||||
}
|
||||
if linkobj == "" {
|
||||
dumpobj1(outfile, modeCompilerObj|modeLinkerObj)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
dumpobj1(outfile, modeCompilerObj)
|
||||
dumpobj1(linkobj, modeLinkerObj)
|
||||
}
|
||||
}
|
||||
|
||||
func dumpobj1(outfile string, mode int) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue