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

Open
kazmccullum opened this issue Aug 6, 2020 · 1 comment
Open

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

kazmccullum opened this issue Aug 6, 2020 · 1 comment
Milestone

Comments

@kazmccullum
Copy link

@kazmccullum kazmccullum commented Aug 6, 2020

Problem

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.

https://github.com/golang/go/blob/master/src/runtime/cgo/gcc_libinit.c#L9

Workaround

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

Or,

  • 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
@ianlancetaylor
Copy link
Contributor

@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 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.