]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link/internal/ld: handle "\r" in MinGW "--print-prog-name" output
authorDavis Goodin <dagood@microsoft.com>
Fri, 21 Jun 2024 23:44:44 +0000 (16:44 -0700)
committerGopher Robot <gobot@golang.org>
Sun, 23 Jun 2024 00:52:20 +0000 (00:52 +0000)
Fix the "gcc --print-prog-name" output parser to handle "\r\n", not only
"\n". The MinGW compiler on Windows uses "\r\n" as line endings, causing
the existing parser to create paths like
".../x86_64-w64-mingw32/bin/ar.exe\r", which is not correct. By trimming
the "\r\n" cutset, both types of line endings are handled correctly.

Fixes #68121

Change-Id: I04b8bf9b6a5b29a1e59a6aa07fa4faa4c5bdeee6
Reviewed-on: https://go-review.googlesource.com/c/go/+/593916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>

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

index 3bec04e0b8d41c44fe5ebc5937dcdc7d342e405f..c29a532bfd29737bb69a79a9183531b0ad1b36c4 100644 (file)
@@ -2917,6 +2917,6 @@ func (ctxt *Link) findExtLinkTool(toolname string) string {
        if err != nil {
                Exitf("%s: finding %s failed: %v\n%s", os.Args[0], toolname, err, out)
        }
-       cmdpath := strings.TrimSuffix(string(out), "\n")
+       cmdpath := strings.TrimRight(string(out), "\r\n")
        return cmdpath
 }