go version
)?go version go1.10 linux/amd64 vgo:2018-02-20.1
go env
)?$ vgo env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mark/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/mark/Prog/golang"
GORACE=""
GOROOT="/home/mark/go1.10"
GOTMPDIR=""
GOTOOLDIR="/home/mark/go1.10/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build793572054=/tmp/go-build -gno-record-gcc-switches"
VGOMODROOT=""
Differences from go1.10 to vgo:
$ diff -U0 <(go env) <(vgo env)
--- /dev/fd/63 2018-02-21 09:41:31.642358384 +1100
+++ /dev/fd/62 2018-02-21 09:41:31.642358384 +1100
@@ -14,2 +14,2 @@
-CC="gcc"
-CXX="g++"
+CC="clang"
+CXX="clang++"
@@ -23 +23,2 @@
-GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build308581873=/tmp/go-build -gno-record-gcc-switches"
+GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build660393002=/tmp/go-build -gno-record-gcc-switches"
+VGOMODROOT=""
vgo build with a dependency on CGO:
$ vgo build
# runtime/cgo
exec: "clang": executable file not found in $PATH
vgo should use the same compiler as go.
zdefaultcc.go as shipped by go1.10 linux/amd64 uses gcc/g++.
Separately, perhaps zdefaultcc.go should use cc/c++ instead? It is generally available and could be clang or gcc.
I can't use vgo to compile code that uses the net package unless I use CGO_ENABLED=0
because of this issue.
@rogpeppe As a temporary workaround, have you tried something like CC=gcc vgo build
? It worked for me.
@ngrilly Good point! That worked, thanks.
both CGO_ENABLED=0 vgo build
and CC=gcc vgo build
works for me.
But I'm still in doubt. Is this a bug (given that the behavior is different from actual go
compiler) or is some expected situation for the new vgo
implemenation?
I expect this is an oversight - zdefaultcc.go
is usually generated by go tool dist
. When go
was duplicated for the vgo
experiment it would have inherited the local configuration.
Afaik, using cc
/c++
instead of gcc/clang would work in most places, but I'm not familiar with every OS that Go supports. It may be a better choice for wider distribution.
golang.org/x/vgo/vendor/cmd/go/internal/cfg/cfg.go has an objabi function that reads various defaults out of the Go tree source code. There should be a similar function for initializing the default CC settings. (We're avoiding invoking the go command so that there are no problems if someone installs a fake "go" command that invokes vgo.)
Change https://golang.org/cl/109975 mentions this issue: cmd/go/internal/cfg: read default CC and CXX from Go source code.
sorry to comment such an old issue, but with the commit
https://github.com/golang/vgo/commit/20939850793927db78c179dcfcd5d4d6f44f2c01
the fix from here (https://go-review.googlesource.com/c/vgo/+/109975/4/vendor/cmd/go/internal/cfg/zdefaultcc.go)
seems to be reverted:
https://github.com/golang/vgo/commit/20939850793927db78c179dcfcd5d4d6f44f2c01#diff-983ae2c32b0c34dc25b2df4c51b25940
--> i now get the same error as this ticket describes.
~~~
$ vgo build
exec: "clang": executable file not found in $PATH
~~~
Most helpful comment
sorry to comment such an old issue, but with the commit
https://github.com/golang/vgo/commit/20939850793927db78c179dcfcd5d4d6f44f2c01
the fix from here (https://go-review.googlesource.com/c/vgo/+/109975/4/vendor/cmd/go/internal/cfg/zdefaultcc.go)
seems to be reverted:
https://github.com/golang/vgo/commit/20939850793927db78c179dcfcd5d4d6f44f2c01#diff-983ae2c32b0c34dc25b2df4c51b25940
--> i now get the same error as this ticket describes.
~~~
$ vgo build
runtime/cgo
exec: "clang": executable file not found in $PATH
~~~