Go version
go version go1.23rc1 windows/amd64
Output of go env
in your module/workspace:
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\dagood\AppData\Local\go-build
set GOENV=C:\Users\dagood\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\dagood\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\dagood\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\dagood\sdk\go1.23rc1
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=local
set GOTOOLDIR=C:\Users\dagood\sdk\go1.23rc1\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.23rc1
set GODEBUG=
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\dagood\AppData\Roaming\go\telemetry
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\dagood\AppData\Local\Temp\go-build2043855877=/tmp/go-build -gno-record-gcc-switches
What did you do?
go1.23rc1 test cmd/cgo/internal/testcarchive -run TestInstall -v
Also repros with go version devel go1.23-0af2148fdc Fri Jun 21 21:01:30 2024 +0000 windows/amd64
(latest master, 0af2148fdc)
What did you see happen?
=== RUN TestInstall
carchive_test.go:487: [go tool cgo -objdir C:\Users\dagood\AppData\Local\Temp\carchive_test2892176246\_obj2451795512 -exportheader p.h p\p.go]
carchive_test.go:489: [go install -buildmode=c-archive ./libgo]
carchive_test.go:489: # testcarchive/libgo
C:\Users\dagood\sdk\go1.23rc1\pkg\tool\windows_amd64\link.exe: running C:/Program Files/mingw-w64/x86_64-11.2.0-release-win32-seh-rt_v9-rev1/mingw64/bin failed: exec: "C:/Program Files/mingw-w64/x86_64-11.2.0-release-win32-seh-rt_v9-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ar.exe\r": file does not exist
carchive_test.go:489: exit status 1
--- FAIL: TestInstall (4.66s)
FAIL
FAIL cmd/cgo/internal/testcarchive 5.423s
FAIL
Note: bin/ar.exe\r": file does not exist
.
I'm not sure if all builds of MinGW use \r\n
in their output, but I confirmed that a few other versions also fail in the same way:
* https://github.com/niXman/mingw-builds-binaries/releases/download/12.2.0-rt_v10-rev2/x86_64-12.2.0-release-win32-seh-ucrt-rt_v10-rev2.7z
* https://github.com/niXman/mingw-builds-binaries/releases/download/13.2.0-rt_v11-rev0/x86_64-13.2.0-release-win32-seh-ucrt-rt_v11-rev0.7z
* https://github.com/brechtsanders/winlibs_mingw/releases/download/13.2.0posix-17.0.5-11.0.1-ucrt-r3/winlibs-x86_64-posix-seh-gcc-13.2.0-mingw-w64ucrt-11.0.1-r3.7z
https://github.com/golang/go/blob/0af2148fdcd047e5aa15776a54ccc29d9aa36f7f/src/cmd/link/internal/ld/lib.go#L2911-L2922
Changing the strings.TrimSuffix
to strings.TrimRight(string(out), "\r\n")
fixes the test. ~~I'm planning to send a CL but need to dust off the contrib tools. 🙂~~ Submitted https://go-review.googlesource.com/c/go/+/593916 with this change.
What did you expect to see?
Success.
Comment From: gabyhelp
Similar Issues
- misc/cgo/testcarchive: fails with "Permission denied" #17439
- cmd/link: misc/cgo/test suite crashes on Windows when linked against UCRT with `-linkmode=internal` #62887
- cmd/go: create zip: malformed file path: invalid char '→' #40749
- x/build/cmd/gorebuild: uses wrong path separator for running make.bat on Windows #61951
- cmd/cgo: strdup(0): not defined #7555
- cgo -buildmode=c-archive out ar file not current ar archive random library at macOS #47546
- cmd/link: cross compile from MacOS to Windows with CGO_ENABLED=1 and -buildmode=c-archive not working #59221
- cmd/compile: test -race failed on Windows #49433
- cmd/go: TestScript/cgo_stale_precompiled fails with Clang 14.0.6 #64423
- cmd/ld: Link to a shared library fails on windows #5273
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: gopherbot
Change https://go.dev/cl/593916 mentions this issue: cmd/link/internal/ld: handle "\r" in MinGW "--print-prog-name" output
Comment From: gopherbot
Change https://go.dev/cl/594855 mentions this issue: cmd/link/internal/ld: handle "\r" in MinGW "--print-prog-name" output
Comment From: dagood
go version go1.23rc1 windows/amd64
I realized that a cherry-pick is necessary to fix this in 1.23, so took a look at https://go.dev/wiki/Go-Release-Cycle#timeline, and I think what I need to do is open a cherry-pick CL and reopen this issue because it still applies to 1.23.
Comment From: cherrymui
@dagood a cherry-pick may not be necessary. The main branch is not opened for general development, so everything in the main branch should be still included in Go 1.23. We may just do a merge to release branch, instead of cherry-picking each CL. Thanks.