Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: command line too long running gcc #60183

Closed
jernejs opened this issue May 14, 2023 · 7 comments
Closed

cmd/link: command line too long running gcc #60183

jernejs opened this issue May 14, 2023 · 7 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. OS-Windows WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@jernejs
Copy link

jernejs commented May 14, 2023

What version of Go are you using (go version)?

$ go version

go version go1.20.2 windows/amd64

Does this issue reproduce with the latest release?

Unsure how to test

What operating system and processor architecture are you using (go env)?

Windows 11 22H2, msys2 environment

go env Output
$ go env

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=G:\G
set GOENV=W:\Users\ender\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=W:\Users\ender\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=W:\Users\ender\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=W:\msys64-gtk4\mingw64\lib\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=W:\msys64-gtk4\mingw64\lib\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.2
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 -fdebug-prefix-map=W:\msys64-gtk4\tmp\go-build3989973909=/tmp/go-build -gno-record-gcc-switches

What did you do?

I tried building gtkcord4. The build works fine right up to the link step, where it fails with W:\msys64-gtk4\mingw64\lib\go\pkg\tool\windows_amd64\link.exe: running gcc failed: fork/exec W:\msys64-gtk4\mingw64\bin\gcc.exe: The filename or extension is too long.. Running the linker manually with -v parameter shows that it's trying to pass over 1000 .o files with full path to gcc, resulting in command line that's almost 60 kB, while the command line length in Windows is limited to 32 kB.

What did you expect to see?

Successful link.

What did you see instead?

W:\msys64-gtk4\mingw64\lib\go\pkg\tool\windows_amd64\link.exe: running gcc failed: fork/exec W:\msys64-gtk4\mingw64\bin\gcc.exe: The filename or extension is too long.

Is there any way to tell link.exe to use a @‍response file instead?

@jernejs jernejs changed the title affected/package: affected/package: link.exe produces too long command line on Windows May 14, 2023
@jernejs jernejs changed the title affected/package: link.exe produces too long command line on Windows link.exe produces too long command line on Windows May 14, 2023
@seankhliao seankhliao changed the title link.exe produces too long command line on Windows cmd/link: command line too long running gcc May 14, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label May 14, 2023
@seankhliao seankhliao added OS-Windows NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 14, 2023
@qmuntal
Copy link
Contributor

qmuntal commented May 15, 2023

Thanks for reporting this issue @jernejs. I can reproduce it with go1.20.2, but it seems to be unintentionally fixed on master thanks to https://go-review.googlesource.com/c/go/+/414654.

Could you try building on master? You can get it like this:

go install golang.org/dl/gotip@latest
gotip download

And then use gotip build instead of go build.

@qmuntal qmuntal added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels May 15, 2023
@jernejs
Copy link
Author

jernejs commented May 15, 2023

Unfortunately getting the latest golang doesn't seem to work – when I ran go install golang.org/dl/gotip@latest the first time, it said it downloaded something, but running gotip afterwards resulted in -bash: gotip: command not found. I tried restarting msys2, now there's no output from go install, and still no gotip command.

Note that I'm using msys2, because the program I'm trying to build depends on GTK4, and I have no desire to compile GTK and its dependencies myself.

I'll test again once this lands in msys2, but from the description of 414654, it'll probably solve my problem.

@seankhliao
Copy link
Member

gotip will be in $GOPATH/bin

@seankhliao seankhliao added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels May 15, 2023
@jernejs
Copy link
Author

jernejs commented May 15, 2023

OK, found it – for some reason $GOPATH points to my Windows user profile\go instead of inside msys2 root. Anyway, gotip install was successful.

@qmuntal
Copy link
Contributor

qmuntal commented May 16, 2023

OK, found it – for some reason $GOPATH points to my Windows user profile\go instead of inside msys2 root. Anyway, gotip install was successful.

Could you build gtkcord4 with gotip?

@jernejs
Copy link
Author

jernejs commented May 16, 2023

Sorry, I wasn't clear – gtkcord4 built fine with gotip.

@qmuntal
Copy link
Contributor

qmuntal commented May 16, 2023

Sorry, I wasn't clear – gtkcord4 built fine with gotip.

Then I'll close this issue as done.

@qmuntal qmuntal closed this as completed May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. OS-Windows WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants