Skip to content

cmd/go: handle space in path to C compiler #43808

@apmckinlay

Description

@apmckinlay

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

$ go version
go version go1.15.7 windows/amd64

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\andrew\AppData\Local\go-build
set GOENV=C:\Users\andrew\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\andrew\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\andrew\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=V:\gsuneido\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\andrew\AppData\Local\Temp\go-build158816006=/tmp/go-build -gno-record-gcc-switches
GOROOT/bin/go version: go version go1.15.7 windows/amd64
GOROOT/bin/go tool compile -V: compile version go1.15.7
gdb --version: GNU gdb (GDB) 8.1

What did you do?

> go build -v -ldflags "-s -w -X 'main.builtDate=Jan 20 2021 11:17:27' -X main.mode=gui -H windowsgui"

What did you expect to see?

Successful build

What did you see instead?

# github.com/apmckinlay/gsuneido/builtin/goc
cgo: exec c:\Program: exec: "c:\\Program": file does not exist

It builds successfully on 1.15.6 (and 1.16beta1)

I cut my path down to:

PATH=C:\WINDOWS\System32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\system32;C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;C:\Go\bin;C:\Users\andrew\go\bin

In particular, mingw-w64 is in c:\program files
I think that was the default, but I can't remember for sure.

Cmd finds g++ using this path

> g++ --version
g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions