mirror of https://github.com/golang/go.git
cmd/ssadump: disable run mode with runtime package
Changes `ssadump -run` to ensure that the package runtime is not imported (changed from must be imported). For several years, the runtime package has used unsafe constructs x/tools/go/ssa/interp cannot interpret. This must have been failing a similar amount of time. This is unfortunate, but is unlikely to be addressed soon. For golang/go#43163 Change-Id: I9e2aee640ff7b1123e591e6c49cac9967c5e8da8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/441817 Run-TryBot: Tim King <taking@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
29429f53af
commit
ab79327e05
|
|
@ -157,12 +157,15 @@ func doMain() error {
|
|||
// Build SSA for all packages.
|
||||
prog.Build()
|
||||
|
||||
// The interpreter needs the runtime package.
|
||||
// It is a limitation of go/packages that
|
||||
// we cannot add "runtime" to its initial set,
|
||||
// we can only check that it is present.
|
||||
if prog.ImportedPackage("runtime") == nil {
|
||||
return fmt.Errorf("-run: program does not depend on runtime")
|
||||
// Earlier versions of the interpreter needed the runtime
|
||||
// package; however, interp cannot handle unsafe constructs
|
||||
// used during runtime's package initialization at the moment.
|
||||
// The key construct blocking support is:
|
||||
// *((*T)(unsafe.Pointer(p)))
|
||||
// Unfortunately, this means only trivial programs can be
|
||||
// interpreted by ssadump.
|
||||
if prog.ImportedPackage("runtime") != nil {
|
||||
return fmt.Errorf("-run: program depends on runtime package (interpreter can run only trivial programs)")
|
||||
}
|
||||
|
||||
if runtime.GOARCH != build.Default.GOARCH {
|
||||
|
|
|
|||
Loading…
Reference in New Issue