From: Cherry Mui Date: Wed, 21 Dec 2022 00:31:40 +0000 (-0500) Subject: cmd/link: add debug print in hostobjCopy X-Git-Tag: go1.21rc1~1701 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=780db9a63d73f26dd9614b67e6129b55e854a174;p=gostls13.git 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 Run-TryBot: Cherry Mui TryBot-Result: Gopher Robot --- diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index ffa2d83505..3772b8ba90 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1222,13 +1222,16 @@ func hostlinksetup(ctxt *Link) { // 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 @@ func (ctxt *Link) archive() { } 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 @@ func (ctxt *Link) hostlink() { } 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.