Skip to content

cgo: C compiler "D:\\Program" not found. Is space symbol in CC variable bugged again ? #59512

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

Closed
vault-thirteen opened this issue Apr 9, 2023 · 2 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@vault-thirteen
Copy link

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

go version
go1.20.3 windows/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

Windows 10,
Intel x86-64.

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=J:\Go\cache
set GOENV=C:\Users\***\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=J:\Go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=J:\Go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=D:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=D:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.3
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=D:\Program Files\LLVM\bin\clang.exe
set CXX=g++
set CGO_ENABLED=1
set GOMOD=J:\Go\src\test\sdl-wrapper\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=. -m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\***\AppData\Local\Temp\go-build***=/tmp/go-build -gno-record-gcc-switches

What did you do?

I am trying to compile a binary using CGO.

go build .

The compiler exists at the path specified in CC variable.
Proof:

go env CC
D:\Program Files\LLVM\bin\clang.exe

"D:\Program Files\LLVM\bin\clang.exe" -v
clang version 16.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: D:\Program Files\LLVM\bin

What did you expect to see?

Successful compilation.

What did you see instead?

# runtime/cgo
cgo: C compiler "D:\\Program" not found: exec: "D:\\Program": file does not exist
@seankhliao
Copy link
Member

From the fix in #41400, I believe you're expected to quote the CC path if it contains spaces

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 9, 2023
@vault-thirteen
Copy link
Author

OK. I have found out that I have two ways to do it.

  1. Golang way:
go env -w CC="\"D:\Program Files\LLVM\bin\clang.exe\""
go env CC
"D:\Program Files\LLVM\bin\clang.exe"
  1. Windows way:
SET CC="D:\Program Files\LLVM\bin\clang.exe"

ECHO %CC%
"D:\Program Files\LLVM\bin\clang.exe"

go env CC
"D:\Program Files\LLVM\bin\clang.exe"

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Apr 10, 2023
@golang golang locked and limited conversation to collaborators Apr 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants