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
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@kazmccullum
Copy link

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

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 Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. 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
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
Status: Triage Backlog
Development

No branches or pull requests

4 participants