-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: flag validation fails when pkg-config --libs
reports a path containing spaces
#35262
Comments
pkg-config --libs
reports a path containing spaces
I'm not aware of any. Send a PR (and, ideally, a regression test) and we can discuss on the code review? |
In 2016, an issue was raised that #cgo pkg-config: annotations did not work with paths that have spaces in them. The relevant issue is golang#16455. This was fixed, but only for CFLAGS. Because a Windows user was not available, the windows use case was overlooked (linux is unlikely to have libs folders with spaces). The same logic developed for golang#16455 is now applied to --libs output in addition to --cflags output, and tests have been created for the getPkgConfigFlags method in exec.go. Fixes golang#35262
In 2016, an issue was raised that #cgo pkg-config: annotations did not work with paths that have spaces in them. The relevant issue is golang#16455. This was fixed, but only for CFLAGS. Because a Windows user was not available, the windows use case was overlooked (linux is unlikely to have libs folders with spaces). The same logic developed for golang#16455 is now applied to --libs output in addition to --cflags output, and tests have been created for the getPkgConfigFlags method in exec.go. Fixes golang#35262
In 2016, an issue was raised that #cgo pkg-config: annotations did not work with paths that have spaces in them. The relevant issue is golang#16455. This was fixed, but only for CFLAGS. Because a Windows user was not available, the windows use case was overlooked (linux is unlikely to have libs folders with spaces). The same logic developed for golang#16455 is now applied to --libs output in addition to --cflags output, and tests have been created for the getPkgConfigFlags method in exec.go. Fixes golang#35262
Change https://golang.org/cl/209437 mentions this issue: |
Change https://go.dev/cl/466875 mentions this issue: |
Change https://go.dev/cl/466864 mentions this issue: |
golang#16455 handled escapes in pkg-config output but only for cflags. The fix for golang#41400 left a note that we don't need to parse quotes and unescapes, but it is still necessary to handle spaces in pkg-config output. As cflags has already been processed correctly, we apply the same logic to ldflags here. Fixes golang#35262 Change-Id: Id01d422b103780f67f89e99ff1df0d8f51a7a137 GitHub-Last-Rev: c67e511 GitHub-Pull-Request: golang#58429 Reviewed-on: https://go-review.googlesource.com/c/go/+/466875 Run-TryBot: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: David Chase <[email protected]>
In reviewing CL 466875, I noticed that the implementation of splitPkgConfigOutput from CL 86541 referred to another specific implementation, and that implementation has had recent changes to fix deviations from the POSIX specification for shell argument parsing. Curious about those changes, I decided to fuzz the function to check whether it agreed in practice with the way a real shell parses arguments in POSIX mode. It turned out to deviate in several edge cases, such as backslash-escapes within single quotes, quoted empty strings, and carriage returns. (We do not expect to see carriage returns in pkg-config output anyway, but the quote handling might matter.) This change updates the implementation to refer to the POSIX documentation instead of another implementation, and confirms the behavior with a fuzz test. It may introduce minor deviations from the pkgconf implementation that was previously used as a reference, but if so it is plausible that those could be fixed upstream in pkgconf (like the other recent changes there). For #35262. Updates ##23373. Change-Id: Ifab76e94af0ca9a6d826379f4a6e2028561e615c Reviewed-on: https://go-review.googlesource.com/c/go/+/466864 Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Auto-Submit: Bryan Mills <[email protected]>
In reviewing CL 466875, I noticed that the implementation of splitPkgConfigOutput from CL 86541 referred to another specific implementation, and that implementation has had recent changes to fix deviations from the POSIX specification for shell argument parsing. Curious about those changes, I decided to fuzz the function to check whether it agreed in practice with the way a real shell parses arguments in POSIX mode. It turned out to deviate in several edge cases, such as backslash-escapes within single quotes, quoted empty strings, and carriage returns. (We do not expect to see carriage returns in pkg-config output anyway, but the quote handling might matter.) This change updates the implementation to refer to the POSIX documentation instead of another implementation, and confirms the behavior with a fuzz test. It may introduce minor deviations from the pkgconf implementation that was previously used as a reference, but if so it is plausible that those could be fixed upstream in pkgconf (like the other recent changes there). For golang#35262. Updates #golang#23373. Change-Id: Ifab76e94af0ca9a6d826379f4a6e2028561e615c Reviewed-on: https://go-review.googlesource.com/c/go/+/466864 Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Auto-Submit: Bryan Mills <[email protected]>
Change https://go.dev/cl/473616 mentions this issue: |
Fixes #58889 Updates #35262 Change-Id: I1d51aa03f445faaf4f4e9cc412d5499cad526663 Reviewed-on: https://go-review.googlesource.com/c/go/+/473616 Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Quim Muntal <[email protected]> Auto-Submit: Quim Muntal <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
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 (
go env
)?go env
OutputWhat did you do?
Place the -L directory of a C lib into a directory with a space in it, and access it a pkg-config .pc file.
Attempt to build:
What did you expect to see?
Successful build.
What did you see instead?
Context
In 2016, this issue was brought up and was successfully solved, but only for CFlags: #16455
Commit: https://go-review.googlesource.com/c/go/+/32735/6/src/cmd/go/build.go
However, on windows where the (git bash) mingw
/usr
directory is inC:\Program Files
, both the include and lib directories have spaces in them. In issue 16455, it was determined to wait on windows until more information was provided. However, the linked commit fixes linux as well as windows. The only problem is that the fix was only applied to CFLAGS and not LDFLAGS. Having LDFLAGS also usesplitPkgConfigOutput
instead ofstrings.Fields
would solve this problem entirely. Are there any considerations that might prevent me from PRing a straight 1:1 replacement?The text was updated successfully, but these errors were encountered: