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 failed #17846

Closed
patricksuo opened this issue Nov 8, 2016 · 10 comments
Closed

cmd/go: TestCgoPkgConfig failed #17846

patricksuo opened this issue Nov 8, 2016 · 10 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@patricksuo
Copy link

Please answer these questions before submitting your issue. Thanks!

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

8a2a999311c22079c3b9f2e6fac2bbd38435a7ab
bootstrap go1.7
go version devel +8a2a999 Tue Nov 8 00:51:14 2016 +0000 linux/amd64
Linux centos65x64TopHighoocwbezz 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/xxxxx/projectgo"
GORACE=""
GOROOT="/home/xxxxx/go"
GOTOOLDIR="/home/xxxxx/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build170177454=/tmp/go-build"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
./all.bash
version: 8a2a999

What did you expect to see?

no failure

What did you see instead?

ok     	cmd/fix	0.011s
--- FAIL: TestCgoPkgConfig (0.12s)
       	go_test.go:252: running testgo [env PKG_CONFIG]
       	go_test.go:259: running testgo ./testgo
       	go_test.go:269: standard output:
       	go_test.go:270: pkg-config

       	go_test.go:252: running testgo [run /tmp/gotest805869295/foo.go]
       	go_test.go:259: running testgo ./testgo
       	go_test.go:273: standard error:
       	go_test.go:274: # command-line-arguments
       		gcc: world: No such file or directory

       	go_test.go:283: go [run /tmp/gotest805869295/foo.go] failed unexpectedly: exit status 2
FAIL
FAIL   	cmd/go 	27.501s
ok     	cmd/gofmt      	0.022
@quentinmit
Copy link
Contributor

@sillyousu What Linux distribution are you running? Can you please try:

cat <<EOF > foo.pc
Name: foo
Description: The foo library
Version: 1.0.0
Cflags: -Dhello=10 -Dworld=+32 -DDEFINED_FROM_PKG_CONFIG=hello\ world
EOF
PKG_CONFIG_PATH=. pkg-config --cflags foo

and reply with the output from the pkg-config command? This test failure indicates that somehow we lost the backslash after the "hello".

@quentinmit quentinmit added this to the Go1.8 milestone Nov 8, 2016
@quentinmit quentinmit added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Nov 8, 2016
@quentinmit quentinmit self-assigned this Nov 8, 2016
@quentinmit quentinmit changed the title all.bash: TestCgoPkgConfig failed cmd/go: TestCgoPkgConfig failed Nov 8, 2016
@patricksuo
Copy link
Author

What Linux distribution are you running?
CentOS 6.5/x86_64/2.6.32-431.el6.x86_64

centos65x64TopHighoocwbezz➜  ~ cat <<EOF > foo.pc
heredoc> Name: foo
heredoc> Description: The foo library
heredoc> Version: 1.0.0
heredoc> Cflags: -Dhello=10 -Dworld=+32 -DDEFINED_FROM_PKG_CONFIG=hello\ world
heredoc> EOF
centos65x64TopHighoocwbezz➜  ~ PKG_CONFIG_PATH=. pkg-config --cflags foo
-Dhello=10 -Dworld=+32 -DDEFINED_FROM_PKG_CONFIG=hello world

@quentinmit
Copy link
Contributor

Okay, so this confirms that your pkg-config did not properly handle the whitespace. CentOS 6.5 appears to include pkg-config 0.23, which dates from 6 years ago. Looking at the source code, it simply has no handling for escape sequences at all. I'm a bit confused though, because it does say in a comment

A '' proceding any other character is ignored and written into the output buffer unmodified.

which does seem like it applies here. Ironically support for whitespace in paths was added later in 2010: https://cgit.freedesktop.org/pkg-config/commit/?id=69a7eaa6

@rsc I'm not sure what to do here. Should the test run pkg-config --version and try to parse the output? Or just ignore the test failure on very old distros?

@sillyousu This test failure is harmless and your Go is otherwise fine; feel free to ignore it and use the resulting go. You simply won't be able to link pkg-config libraries that are in paths containing whitespace (unlikely on CentOS).

@rsc
Copy link
Contributor

rsc commented Nov 10, 2016

@quentinmit Does the test work if you quote "-DDEFINED_FROM_PKG_CONFIG=hello world" on the Cflags line in the pc file? If that is more reliable with older versions of pkg-config, then that seems fine. We're checking our handling of pkg-config's output, not pkg-config's input parser.

@quentinmit
Copy link
Contributor

Neither double quotes nor backslashes work in pkg-config 0.23. AFAICT there is simply no way to get whitespace into an argument in pkg-config 0.23.

Double quotes also don't work in OpenBSD's pkg-config, which is why I put backslashes into the test.

@rsc
Copy link
Contributor

rsc commented Nov 10, 2016

How about running something like pkg-config --version and t.Skip for older versions?

@quentinmit
Copy link
Contributor

That's what I suggested above. Yeah, we can do that. I'm not sure what the best way to compare the version number is - parse with a regex?

@sillyousu Can you confirm what pkg-config --version prints for you? I'm expecting "0.23".

@gopherbot
Copy link

CL https://golang.org/cl/33027 mentions this issue.

@patricksuo
Copy link
Author

patricksuo commented Nov 11, 2016

@sillyousu Can you confirm what pkg-config --version prints for you? I'm expecting "0.23".

centos65x64TopHighoocwbezz➜ ~ pkg-config --version
0.23

@patricksuo
Copy link
Author

@sillyousu This test failure is harmless and your Go is otherwise fine; feel free to ignore it and use the resulting go. You simply won't be able to link pkg-config libraries that are in paths containing whitespace (unlikely on CentOS).

The lack of pkg-config functionality doesn't bother me.
This failure stopping the subsequent test cases is a little bit annoying.

@golang golang locked and limited conversation to collaborators Nov 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. 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