-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: handle pkg-config output containing spaces #16455
Comments
This appears to be the same as #7906. |
This is related #11868. |
It looks like those CGO_LDFLAGS are coming from git.go:
Can you please try running I would like to know if we're misparsing the output of pkg-config, or if it is not outputting the correctly-escaped string. |
We are certainly misparsing the output of pkg-config, since we use strings.Fields. There's no way that can possibly handle a path like C:/Program Files correctly. The question is how the output is defined so that we can parse it correctly. On Linux, I get:
That is, on Linux pkg-config seems to escape spaces with a backslash. We don't handle that (and we should), but if pkg-config on Windows were emitting those, we'd see them in the CGO_LDFLAGS print, and we don't. For example, if I continue on Linux:
So it looks like, even if we were handling spaces correctly on Linux, handling them correctly on Windows would require different code. The big question, then, is what pkg-config prints on Windows. It would be great if it printed one arg per line or something like that, so we could split at newline. @ktsakas, can you please send the output of
on your Windows machine? Thanks. |
@ktsakas I tried installing MinGW-w64 and MSys2 to debug this, only to discover that their libgit2 package is installed to |
As far as I try this on msys2 on my environment, backslash separator
slash separator
backslash escaped
quoted includedir
|
@ktsakas we are waiting on more info from you about pkg-config on your Windows system. In the meanwhile, we will fix the Unix case and leave Windows using strings.Fields. |
CL https://golang.org/cl/32735 mentions this issue. |
It looks like this is caused by libgit2 generating an incorrect The includedir= argument needs to be quoted if the path contains a space, otherwise pkg-config treats it as multiple arguments. |
I am using Go v1.6.2 on Windows 10.
I tried to build the git2go package in MinGW-w64 using
go build
but it fails.When I run
go build -x
, I get the following:Notice how "-LC:/Program" "Files" "(x86)/libgit2/lib" flag is split up on every space and the parts are put in quotes, which seems to cause the issue.
I understand that mingw has problems with spaces in paths, however this should be fixable in build.go.
The issue has been mentioned again in git2go#155.
The text was updated successfully, but these errors were encountered: