]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/link: add debug print in hostobjCopy
authorCherry Mui <cherryyz@google.com>
Wed, 21 Dec 2022 00:31:40 +0000 (19:31 -0500)
committerCherry Mui <cherryyz@google.com>
Tue, 31 Jan 2023 19:45:12 +0000 (19:45 +0000)
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>

src/cmd/link/internal/ld/lib.go

index ffa2d835051ef10a94e182a301d47f8eae4bce2b..3772b8ba9092478677ddd355a5a75407540b5365 100644 (file)
@@ -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.