Skip to content
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

Please provide verbose output of compiler commands when building code with C/C++ libs #45724

Closed
vkuznet opened this issue Apr 23, 2021 · 2 comments
Closed

Comments

@vkuznet
Copy link

@vkuznet vkuznet commented Apr 23, 2021

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

$ go version
1.16.3

Does this issue reproduce with the latest release?

yes

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

darwin/amd64

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/vk/Library/Caches/go-build"
GOENV="/Users/vk/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/vk/Work/Languages/Go/gopath/pkg/mod"
GONOPROXY=""
GONOSUMDB="github.com/galeone/tensorflow"
GOOS="darwin"
GOPATH="/Users/vk/Work/Languages/Go/gopath"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/local/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/local/lib/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.3"
GCCGO="gccgo"
AR="ar"
CC="/usr/bin/clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/vk/tmp/gotorch/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/vp/p89gqpvd4f93zzqpz4g5jnvm0000gp/T/go-build4146055528=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Any code which requires C-binding, e.g. in my case I was trying to build against opencv and libtorch libraries.

What did you expect to see?

The go build command provides no output of how underlying C/C++ build is performed. When I provide -v verbose flag I expect to see a full output of underlying gcc/g++/clang++ commands which were called from the go build. Otherwise it is extremely hard to understand details of the build.

What did you see instead?

Here is a simple example:

# I'm building an example code from github.com/wangkuiyi/gotorch
cd gotorch/example/mnist
go build

# gocv.io/x/gocv
In file included from dnn.cpp:1:
/Users/vk/Work/Languages/Go/gopath/pkg/mod/gocv.io/x/gocv@v0.24.0/dnn.h:8:10: fatal error: 'opencv2/dnn.hpp' file not found

This output tells me that I'm missing opencv2 includes. Ok, I can supply the include dirs, e.g.

CGO_CPPFLAGS="-I/opt/local/include" CGO_LDFLAGS="-L/opt/local/lib" go build -v
# gocv.io/x/gocv
features2d.cpp:219:146: error: no type named 'DetectorType' in 'cv::FastFeatureDetector'
features2d.cpp:429:54: error: no matching conversion for static_cast from 'int' to 'cv::DrawMatchesFlags'
/opt/local/include/opencv2/features2d.hpp:1273:19: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const cv::DrawMatchesFlags' for 1st argument
/opt/local/include/opencv2/features2d.hpp:1273:19: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'cv::DrawMatchesFlags' for 1st argument
/opt/local/include/opencv2/features2d.hpp:1273:19: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided

From this output I have no clue how build was done, which compiler commands were issued, etc. Here I expect to see something like (which I was able to grab of ps output during my build):

/opt/local/libexec/llvm-9.0/bin/clang++ -I /Users/vk/Work/Languages/Go/gopath/pkg/mod/gocv.io/x/gocv@v0.24.0 -fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/vp/p89gqpvd4f93zzqpz4g5jnvm0000gp/T/go-build3227765425/b068=/tmp/go-build -gno-record-gcc-switches -fno-common -I/opt/local/include -I/opt/local/include/opencv4 -I /var/folders/vp/p89gqpvd4f93zzqpz4g5jnvm0000gp/T/go-build3227765425/b068/ -g -O2 --std=c++11 -o /var/folders/vp/p89gqpvd4f93zzqpz4g5jnvm0000gp/T/go-build3227765425/b068/_x019.o -c core.cpp

Please provide full verbose output of underlying c/c++ compiler commands issued by go build. This will allows developers save time to debug the issues with C binding libraries and know exactly how to reproduce the build issues. For instance, I can get the compiler commands from ps output command, but it requires lots of jumping between windows, but still does not guarantee that I can catch exact commands which fails. We need to see full c/c++/clang output including errors, warnings, etc., as we usually do when compiling C/C++ code. I suggest to capture go build stdout/stderr output and allow developers to see these outputs during go build command.

@randall77
Copy link
Contributor

@randall77 randall77 commented Apr 23, 2021

Does the -x option work for you?

@gopherbot
Copy link

@gopherbot gopherbot commented May 23, 2021

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this May 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants