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/go: TestCgoPkgConfig fails on Windows with pkg-config installed #58889

Closed
qmuntal opened this issue Mar 6, 2023 · 2 comments
Closed

cmd/go: TestCgoPkgConfig fails on Windows with pkg-config installed #58889

qmuntal opened this issue Mar 6, 2023 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Milestone

Comments

@qmuntal
Copy link
Contributor

qmuntal commented Mar 6, 2023

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

$ go version
go version devel go1.21-908310580a Mon Mar 6 10:25:41 2023 +0100 windows/amd64

Does this issue reproduce with the latest release?

No, only on tip.

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

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\***\AppData\Local\go-build
set GOENV=C:\Users\***\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\***\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\***\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\***\code\go\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\***\code\go\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.21-908310580a Mon Mar 6 10:25:41 2023 +0100
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\***\code\go\go\src\go.mod
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=C:\Users\***\AppData\Local\Temp\go-build2848288378=/tmp/go-build -gno-record-gcc-switches

What did you do?

gotip test -run TestCgoPkgConfig cmd/go

What did you expect to see?

ok cmd/go 7.923s

What did you see instead?

--- FAIL: TestCgoPkgConfig (46.16s)
    go_test.go:1582: running testgo [env PKG_CONFIG]
    go_test.go:1582: standard output:
    go_test.go:1582: pkg-config
        
    go_test.go:1618: running testgo [run C:\Users\***\AppData\Local\Temp\cmd-go-test-2864745407\gotest865774581\foo.go]
    go_test.go:1618: standard error:
    go_test.go:1618: command-line-arguments: invalid flag in pkg-config --libs: 
        
    go_test.go:1618: go [run C:\Users\***\AppData\Local\Temp\cmd-go-test-2864745407\gotest865774581\foo.go] failed unexpectedly in c:\Users\***\code\golang-go\src\cmd\go: exit status 1
FAIL

Additional notes

The test only fails if pkg-config is installed, else the test is skipped. Go builders don't have pkg-config, so this failure passed unnoticed when it was introduced in CL 466875 or CL 466864.

@thanm @dmitshur would it be possible to install pkg-config on the Windows builders?

@qmuntal qmuntal added OS-Windows NeedsFix The path to resolution is known, but the work has not been done. labels Mar 6, 2023
@qmuntal
Copy link
Contributor Author

qmuntal commented Mar 6, 2023

This is not an issue with the test, but a bug in the toolchain when pkg-config returns no linker flags but a blank space character. Blank spaces should be trimmed before calling splitPkgConfigOutput in:

if len(out) > 0 {
// We need to handle path with spaces so that C:/Program\ Files can pass
// checkLinkerFlags. Use splitPkgConfigOutput here just like we treat cflags.
ldflags, err = splitPkgConfigOutput(out)
if err != nil {
return nil, nil, err
}
if err := checkLinkerFlags("LDFLAGS", "pkg-config --libs", ldflags); err != nil {
return nil, nil, err
}

Will submit a fix soon.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/473616 mentions this issue: cmd/go: trim spaces in pkg-config ldflags output

@dmitshur dmitshur added this to the Go1.21 milestone Mar 16, 2023
@golang golang locked and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Projects
None yet
Development

No branches or pull requests

3 participants