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

cmd/cgo: cgo-related compile errors yield poor error messages #29195

Closed
MMulthaupt opened this issue Dec 12, 2018 · 2 comments
Closed

cmd/cgo: cgo-related compile errors yield poor error messages #29195

MMulthaupt opened this issue Dec 12, 2018 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@MMulthaupt
Copy link

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

go version go1.11.2 linux/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env Output
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/martin/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/martin/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build515058236=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Natively compile a modularized Go project with CGO_ENABLED=1 on Linux.

What did you expect to see?

A descriptive error informing me which import-statement in which .go-file caused the problem.

What did you see instead?

The following mostly C-related error output, which requires me to debug the issue by selectively removing module dependencies and such until the problem is resolved to get closer to identifying the offending import/include:

# runtime/cgo
In file included from _cgo_export.c:3:0:
/usr/include/stdlib.h:25:10: fatal error: bits/libc-header-start.h: No such file or directory
 #include <bits/libc-header-start.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

While runtime/cgo is mentioned, this is certainly not being imported by me directly. Also great would be to report common missing dependencies in case of known failures. (I.e. answer the question "What am I missing which contains the missing file?")

@ALTree ALTree changed the title CGO-related compile errors yield poor error messages cmd/cgo: cgo-related compile errors yield poor error messages Dec 12, 2018
@ALTree ALTree added this to the Unplanned milestone Dec 12, 2018
@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 12, 2018
@ianlancetaylor
Copy link
Contributor

It's a hard problem. The code that failed to compile is in fact in the standard library's runtime/cgo package. That package does a #include <stdlib.h>. It appears that on your system that does not work. So there seems to be something deeply broken in your C compiler installation. Since we didn't write or install the C compiler, it's very hard for us to give you a useful error report, or to answer a question like what you are missing.

The first result on a Google search for the C compiler error message suggested

sudo apt-get install gcc-multilib g++-multilib

so I would try that.

@ianlancetaylor
Copy link
Contributor

I don't really see what we can do better here, so I'm going to close this issue. Please comment if you have a suggestion.

@golang golang locked and limited conversation to collaborators Dec 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants