-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
What version of Go are you using (go version)?
$ go version go version go1.13.1 windows/amd64
Does this issue reproduce with the latest release?
Yes
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\Stephen Baynham\AppData\Local\go-build set GOENV=C:\Users\Stephen Baynham\AppData\Roaming\go\env set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\Stephen Baynham\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=c:\go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=c:\go\pkg\tool\windows_amd64 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=C:\Users\Stephen Baynham\source\repos\go-luajit\go.mod set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\STEPHE~1\AppData\Local\Temp\go-build884938030=/tmp/go-build -gno-record-gcc-switches
What 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.
/*
#cgo pkg-config: luajit
#include "go_luajit.h"
*/
import "C"
func main() {}
Attempt to build:
$ pkg-config --cflags luajit
-IC:/Program\ Files/Git/usr/local/include/luajit-2.0
$ pkg-config --libs luajit
-LC:/Program\ Files/Git/usr/local/lib -lluajit-5.1
$ go build ./...
go build github.com/cannibalvox/luajitter: invalid flag in pkg-config --libs: Files/Git/usr/local/lib
What did you expect to see?
Successful build.
What did you see instead?
go build github.com/cannibalvox/luajitter: invalid flag in pkg-config --libs: Files/Git/usr/local/lib
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 in C:\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 use splitPkgConfigOutput instead of strings.Fields would solve this problem entirely. Are there any considerations that might prevent me from PRing a straight 1:1 replacement?