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/go: 'go build' encountered invalid C headers under MacOS #32353

Closed
mylonly opened this issue May 31, 2019 · 7 comments
Closed

cmd/go: 'go build' encountered invalid C headers under MacOS #32353

mylonly opened this issue May 31, 2019 · 7 comments
Labels
FrozenDueToAge OS-Darwin WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@mylonly
Copy link

mylonly commented May 31, 2019

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

$ go version
go version go1.11.5 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output

What did you do?

Actually, I'm using Golang to debug go program, after I hit the debug button, it didn't compile.

The command used to compile is

go build -gcflags "all=-N -l" main.go

What did you expect to see?

No error

What did you see instead?

It reports

runtime/cgo

In file included from gcc_libinit.c:8:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/pthread.h:232:66: error: unknown type name 'size_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/pthread.h:249:43: error: unknown type name 'size_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/pthread.h:256:66: error: unknown type name 'size_t'
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/pthread.h:524:1: error: unknown type name 'size_t'
gcc_libinit.c:97:18: error: variable has incomplete type 'struct timespec'
gcc_libinit.c:97:9: note: forward declaration of 'struct timespec'
gcc_libinit.c:105:14: error: use of undeclared identifier 'EAGAIN'
gcc_libinit.c:110:3: error: implicit declaration of function 'nanosleep' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
gcc_libinit.c:112:9: error: use of undeclared identifier 'EAGAIN'

#30072
i have the problem too

@ianlancetaylor
Copy link
Contributor

You didn't include the go env output.

@bcmills
Copy link
Contributor

bcmills commented May 31, 2019

#30072
i have the problem too

The same comments from #30072 (comment) apply.

Are you able to build C programs in the same environment?

@bcmills bcmills added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. OS-Darwin labels May 31, 2019
@mylonly
Copy link
Author

mylonly commented Jun 4, 2019

go env
OARCH="amd64" GOBIN="" GOCACHE="/Users/txg/Library/Caches/go-build" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/txg/go" GOPROXY="" GORACE="" GOROOT="/usr/local/go" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GCCGO="gccgo" CC="clang" CXX="clang++" 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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/pd/lf65m7sx1dd1017mz10qt3qm0000gp/T/go-build986796838=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

i use the goland and press the debug button

then the error appear
# runtime/cgo In file included from gcc_libinit.c:8: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/pthread.h:232:66: error: unknown type name 'size_t' /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/pthread.h:249:43: error: unknown type name 'size_t' /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/pthread.h:256:66: error: unknown type name 'size_t' /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/pthread.h:524:1: error: unknown type name 'size_t' gcc_libinit.c:97:18: error: variable has incomplete type 'struct timespec' gcc_libinit.c:97:9: note: forward declaration of 'struct timespec' gcc_libinit.c:110:3: error: implicit declaration of function 'nanosleep' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

@ianlancetaylor

my os version is majove

@mylonly
Copy link
Author

mylonly commented Jun 4, 2019

#30072
i have the problem too

The same comments from #30072 (comment) apply.

Are you able to build C programs in the same environment?

yes, the c programs build well

@mylonly
Copy link
Author

mylonly commented Jun 4, 2019

i take my friends computer doing the same thing ,and verything is ok, it's so strange

@mylonly
Copy link
Author

mylonly commented Jun 4, 2019

i take my friends computer doing the same thing ,and verything is ok, it's so strange

the OS is mojove too

@mylonly
Copy link
Author

mylonly commented Jun 13, 2019

i fixed the problem by delete the /usr/include directory

@mylonly mylonly closed this as completed Jun 13, 2019
@golang golang locked and limited conversation to collaborators Jun 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge OS-Darwin WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants