Build started to fail with 1.10

621 views
Skip to first unread message

Владислав Митов

unread,
Feb 22, 2018, 11:38:43 AM2/22/18
to golang-nuts
Hey guys, 

One of my build started failing with 1.10. Basically I'm building a wrapper around a C library and it fails with: 

# runtime/cgo
gcc_libinit
.c: In function '_cgo_try_pthread_create':
gcc_libinit
.c:97:18: error: storage size of 'ts' isn't known
  struct timespec ts;
                  ^~
gcc_libinit.c:110:3: error: implicit declaration of function '
nanosleep' [-Werror=implicit-function-declaration]
   nanosleep(&ts, nil);
   ^~~~~~~~~
gcc_libinit.c:97:18: error: unused variable '
ts' [-Werror=unused-variable]
  struct timespec ts;
                  ^~
cc1: all warnings being treated as errors

Any hint's what's causing this? 

Cheers, 
Vladi

Ian Lance Taylor

unread,
Feb 22, 2018, 11:48:34 AM2/22/18
to Владислав Митов, golang-nuts
You say this started failing with 1.10. That file
(runtime/cgo/gcc_libinit.c) hasn't changed since 1.9, so I think
something else must have changed.

timespec and nanosleep are normally defined in <time.h>. What system
are you using?

Ian

Владислав Митов

unread,
Feb 22, 2018, 4:52:14 PM2/22/18
to golang-nuts
I'm not sure where the issue is but I tried with 1.9 - both locally and in Travis it passes with the same code. 
https://github.com/miracl/gomiracl/compare/fix-build?expand=1 - code 

Nic Pottier

unread,
Feb 22, 2018, 6:57:53 PM2/22/18
to golang-nuts
This is almost certainly because your .travis file is specifying your version as `1.10` vs `"1.10"`

So your build is building with go 1.1 instead of 1.10.

Ran into this myself this morning.

-Nic

Владислав Митов

unread,
Feb 23, 2018, 4:02:59 AM2/23/18
to golang-nuts
Ah, I read about that but ti says `go version go1.10 linux/amd64`. I'll try putting it in quotes now.

Владислав Митов

unread,
Feb 23, 2018, 4:09:02 AM2/23/18
to golang-nuts
Nah, it's not that - https://travis-ci.org/miracl/gomiracl/jobs/345158452. If fails also in golang:latest where the yaml gotcha it's not a thing. Solid suggestion though, thanks.

Dave Cheney

unread,
Feb 23, 2018, 5:26:27 AM2/23/18
to golang-nuts
The failing line was added in december last year,


This also adds a dependency on time.h. Is time.h available in your build container?

Vladislav Mitov

unread,
Feb 23, 2018, 11:32:29 AM2/23/18
to golang-nuts
Not sure, I'l building in golang:latest https://github.com/miracl/gomiracl/blob/master/Dockerfile#L23.

Vladislav Mitov

unread,
Feb 23, 2018, 11:53:46 AM2/23/18
to golang-nuts
Interesting fact is that if I remove "-std=c99" from CGO_CFLAGS it works locally, fails in Travis though.

adam.a...@10xgenomics.com

unread,
Feb 28, 2018, 5:41:55 PM2/28/18
to golang-nuts
I've run into this as well.  It looks somewhat related to

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=314435

As the maintainers explained there, nanosleep isn't part of the c99 standard (it is part of the posix standard).

When you set -std=c99, that turns off -D_GNU_SOURCE, which turns off _POSIX_C_SOURCE in features.h, which turns off nanosleep, amongst other things.  Not clear on exactly why this didn't matter in go 1.9, however.
Reply all
Reply to author
Forward
0 new messages