-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: CGO_CFLAGS variable with spaces is parsed incorrectly on windows #45637
Comments
Similar to #41400 |
Is this still an issue? When I run
Notice the strange extra double quote between It appears correct from cmd.exe:
Running go version go1.24.0 windows/amd64 Some compilers don't like this very much:
whereas others build okay:
|
I wonder if the bug is here: https://github.com/golang/go/blob/master/src/cmd/cgo/gcc.go#L140 Or perhaps if the bug is downstream in the GCC compiler. For example, |
Actually, the more I look here, the more I think it's actually a compiler issue, not a Go bug. This issue can probably be closed. |
Thanks for looking into this @bminer! It looks like this is working as intended. CGO_CFLAGS is a space separated list. double quotes can be used to quote elements with spaces. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using?
windows10, amd64, intel
go env
OutputWhat did you do?
While attempting to build a cgo project on windows, I am finding that the value
CGO_CFLAGS
is parsed incorrectly if an include path contains spaces.I've also tried various combinations of quoting and escaping with no change in result:
What did you expect to see?
I would expect the full single string value of "C:/Program Files/Foo" to be passed to the "-I" include flag when compiling.
What did you see instead?
The path is split on spaces, acting like multiple arguments to
gcc
The text was updated successfully, but these errors were encountered: