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

runtime: gcc_libinit.c _cgo_try_pthread_create 'EAGAIN' undeclared #40617

kazmccullum opened this issue Aug 6, 2020 · 1 comment

runtime: gcc_libinit.c _cgo_try_pthread_create 'EAGAIN' undeclared #40617

kazmccullum opened this issue Aug 6, 2020 · 1 comment


Copy link

@kazmccullum kazmccullum commented Aug 6, 2020


Hi, I'm getting the below error when compiling a CGO project.

# runtime/cgo
gcc_libinit.c: In function '_cgo_try_pthread_create':
gcc_libinit.c:106:14: error: 'EAGAIN' undeclared (first use in this function)
   if (err != EAGAIN) {
gcc_libinit.c:106:14: note: each undeclared identifier is reported only once for each function it appears in
gcc_libinit.c:114:1: error: control reaches end of non-void function [-Werror=return-type]

The C code compiles successfully. This seems to be an issue in CGO ?

Some basic investigation

I checked the code in /usr/local/go/src/runtime/cgo/gcc_libinit.c and it does include #include <errno.h>. But still the error 'EAGAIN' undeclared appears.


  • Adding #define EAGAIN 11 in /usr/local/go/src/runtime/cgo/gcc_libinit.c solves this.


  • Including #include <asm-generic/errno.h> in /usr/local/go/src/runtime/cgo/gcc_libinit.c solves this.

Other details

  • OS: Debian 10
  • Go version: go version go1.14.6 linux/amd64
  • gcc & gccgo version: gcc (Debian 8.3.0-6) 8.3.0
Copy link

@ianlancetaylor ianlancetaylor commented Aug 6, 2020

The file runtime/cgo/gcc_libinit.c has a line #include <errno.h>. That should be enough to define EAGAIN.

@toothrot toothrot added the NeedsInvestigation label Aug 7, 2020
@toothrot toothrot added this to the Backlog milestone Aug 7, 2020
@toothrot toothrot changed the title gcc_libinit.c _cgo_try_pthread_create 'EAGAIN' undeclared runtime: gcc_libinit.c _cgo_try_pthread_create 'EAGAIN' undeclared Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants