PR 66574 aka https://golang.org/issue/11222 points out that libgo is only retrieving the current time in microseconds, when it should be using nanoseconds. This patch fixes the problem. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 230689) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -f79db38cf3484b63f7807abef05eecb23e9d0806 +b839c8c35af49bd6d86306ad34449654a4657cb1 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/configure.ac =================================================================== --- libgo/configure.ac (revision 230463) +++ libgo/configure.ac (working copy) @@ -501,9 +501,10 @@ PTHREAD_LIBS= AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS=-lpthread) AC_SUBST(PTHREAD_LIBS) -dnl Test if -lrt is required for sched_yield and/or nanosleep. +dnl Test if -lrt is required for sched_yield or nanosleep or clock_gettime. AC_SEARCH_LIBS([sched_yield], [rt]) AC_SEARCH_LIBS([nanosleep], [rt]) +AC_SEARCH_LIBS([clock_gettime], [rt]) AC_C_BIGENDIAN Index: libgo/runtime/go-now.c =================================================================== --- libgo/runtime/go-now.c (revision 230463) +++ libgo/runtime/go-now.c (working copy) @@ -13,11 +13,11 @@ struct time_now_ret now() { - struct timeval tv; + struct timespec ts; struct time_now_ret ret; - gettimeofday (&tv, NULL); - ret.sec = tv.tv_sec; - ret.nsec = tv.tv_usec * 1000; + clock_gettime (CLOCK_REALTIME, &ts); + ret.sec = ts.tv_sec; + ret.nsec = ts.tv_nsec; return ret; }