cmd/link: add debug print in hostobjCopy
In external linking mode, when the external linker fails to handle
something in a host object file, it usually reports the name of
the host object which is a copied file named 000NNN.o. This is
often not helpful to determine what file it is. Add some debug
print so at least in -v mode it is more helpful.
Change-Id: Ibe762bff6a25640d16ee0dc082736ba5161b7522
Reviewed-on: https://go-review.googlesource.com/c/go/+/458735
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
index ffa2d83..3772b8ba 100644
--- a/src/cmd/link/internal/ld/lib.go
+++ b/src/cmd/link/internal/ld/lib.go
@@ -1222,13 +1222,16 @@
// hostobjCopy creates a copy of the object files in hostobj in a
// temporary directory.
-func hostobjCopy() (paths []string) {
+func (ctxt *Link) hostobjCopy() (paths []string) {
var wg sync.WaitGroup
sema := make(chan struct{}, runtime.NumCPU()) // limit open file descriptors
for i, h := range hostobj {
h := h
dst := filepath.Join(*flagTmpdir, fmt.Sprintf("%06d.o", i))
paths = append(paths, dst)
+ if ctxt.Debugvlog != 0 {
+ ctxt.Logf("host obj copy: %s from pkg %s -> %s\n", h.pn, h.pkg, dst)
+ }
wg.Add(1)
go func() {
@@ -1311,7 +1314,7 @@
}
argv = append(argv, *flagOutfile)
argv = append(argv, filepath.Join(*flagTmpdir, "go.o"))
- argv = append(argv, hostobjCopy()...)
+ argv = append(argv, ctxt.hostobjCopy()...)
if ctxt.Debugvlog != 0 {
ctxt.Logf("archive: %s\n", strings.Join(argv, " "))
@@ -1650,7 +1653,7 @@
}
argv = append(argv, filepath.Join(*flagTmpdir, "go.o"))
- argv = append(argv, hostobjCopy()...)
+ argv = append(argv, ctxt.hostobjCopy()...)
if ctxt.HeadType == objabi.Haix {
// We want to have C files after Go files to remove
// trampolines csects made by ld.