summaryrefslogtreecommitdiffstats
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2022-02-12 17:12:41 -0800
committerIan Lance Taylor <iant@golang.org>2022-02-13 11:03:45 -0800
commit58aeb75d4097010ad9bb72b964265b18ab284f93 (patch)
tree849876c3156f676db4c951f9b9f6a77e452b6a06 /libgo
parentcompiler: don't set ptrmask bit for pointer to notinheap type (diff)
downloadgcc-58aeb75d4097010ad9bb72b964265b18ab284f93.tar.gz
gcc-58aeb75d4097010ad9bb72b964265b18ab284f93.tar.bz2
gcc-58aeb75d4097010ad9bb72b964265b18ab284f93.tar.xz
runtime: call timer functions via syscall
It turns out to be painful to require linking against -lrt on GNU/Linux, as that makes it harder to link Go code into C programs. Instead just call the timer syscalls directly. That is what the upstream library does anyhow. gcc/go/ * gospec.cc: Revert 2022-02-09 change: (RTLIB, RT_LIBRARY): Don't define. (lang_specific_driver): Don't add -lrt if linking statically on GNU/Linux. gotools/ * configure.ac: Revert 2022-02-09 change: (RT_LIBS): Don't define. * Makefile.am (check-runtime): Don't set GOLIBS to $(RT_LIBS). * configure, Makefile.in: Regenerate. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/385475
Diffstat (limited to 'libgo')
-rw-r--r--libgo/Makefile.am5
-rw-r--r--libgo/Makefile.in9
-rwxr-xr-xlibgo/configure11
-rw-r--r--libgo/configure.ac6
-rw-r--r--libgo/go/runtime/os_linux.go21
-rw-r--r--libgo/testsuite/Makefile.in1
6 files changed, 18 insertions, 35 deletions
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index be889f2a984..9318f38714a 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -832,8 +832,7 @@ libgo_ldflags = \
832 832
833libgo_libadd = \ 833libgo_libadd = \
834 $(libgo_go_objs) ../libbacktrace/libbacktrace.la \ 834 $(libgo_go_objs) ../libbacktrace/libbacktrace.la \
835 $(LIBATOMIC) $(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) \ 835 $(LIBATOMIC) $(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS)
836 $(NET_LIBS) $(RT_LIBS)
837 836
838libgo_la_SOURCES = $(runtime_files) 837libgo_la_SOURCES = $(runtime_files)
839libgo_la_LDFLAGS = $(libgo_ldflags) 838libgo_la_LDFLAGS = $(libgo_ldflags)
@@ -924,7 +923,7 @@ GOBENCH =
924CHECK = \ 923CHECK = \
925 GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs"; \ 924 GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs"; \
926 export GC; \ 925 export GC; \
927 GOLIBS="$(extra_check_libs_$(subst .,_,$(subst /,_,$(@D)))) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS) $(RT_LIBS) $(LIBS)"; \ 926 GOLIBS="$(extra_check_libs_$(subst .,_,$(subst /,_,$(@D)))) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS) $(LIBS)"; \
928 export GOLIBS; \ 927 export GOLIBS; \
929 RUNTESTFLAGS="$(RUNTESTFLAGS)"; \ 928 RUNTESTFLAGS="$(RUNTESTFLAGS)"; \
930 export RUNTESTFLAGS; \ 929 export RUNTESTFLAGS; \
diff --git a/libgo/Makefile.in b/libgo/Makefile.in
index 216be43f14a..642688e9dae 100644
--- a/libgo/Makefile.in
+++ b/libgo/Makefile.in
@@ -233,8 +233,7 @@ am__DEPENDENCIES_4 =
233am__DEPENDENCIES_5 = $(am__DEPENDENCIES_3) \ 233am__DEPENDENCIES_5 = $(am__DEPENDENCIES_3) \
234 ../libbacktrace/libbacktrace.la $(am__DEPENDENCIES_4) \ 234 ../libbacktrace/libbacktrace.la $(am__DEPENDENCIES_4) \
235 $(am__DEPENDENCIES_4) $(am__DEPENDENCIES_4) \ 235 $(am__DEPENDENCIES_4) $(am__DEPENDENCIES_4) \
236 $(am__DEPENDENCIES_4) $(am__DEPENDENCIES_4) \ 236 $(am__DEPENDENCIES_4) $(am__DEPENDENCIES_4)
237 $(am__DEPENDENCIES_4)
238libgo_llgo_la_DEPENDENCIES = $(am__DEPENDENCIES_5) 237libgo_llgo_la_DEPENDENCIES = $(am__DEPENDENCIES_5)
239@LIBGO_IS_LINUX_TRUE@@LIBGO_IS_X86_TRUE@am__objects_1 = \ 238@LIBGO_IS_LINUX_TRUE@@LIBGO_IS_X86_TRUE@am__objects_1 = \
240@LIBGO_IS_LINUX_TRUE@@LIBGO_IS_X86_TRUE@ runtime/go-context.lo 239@LIBGO_IS_LINUX_TRUE@@LIBGO_IS_X86_TRUE@ runtime/go-context.lo
@@ -466,7 +465,6 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
466PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ 465PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
467PTHREAD_LIBS = @PTHREAD_LIBS@ 466PTHREAD_LIBS = @PTHREAD_LIBS@
468RANLIB = @RANLIB@ 467RANLIB = @RANLIB@
469RT_LIBS = @RT_LIBS@
470SED = @SED@ 468SED = @SED@
471SET_MAKE = @SET_MAKE@ 469SET_MAKE = @SET_MAKE@
472SHELL = @SHELL@ 470SHELL = @SHELL@
@@ -972,8 +970,7 @@ libgo_ldflags = \
972 970
973libgo_libadd = \ 971libgo_libadd = \
974 $(libgo_go_objs) ../libbacktrace/libbacktrace.la \ 972 $(libgo_go_objs) ../libbacktrace/libbacktrace.la \
975 $(LIBATOMIC) $(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) \ 973 $(LIBATOMIC) $(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS)
976 $(NET_LIBS) $(RT_LIBS)
977 974
978libgo_la_SOURCES = $(runtime_files) 975libgo_la_SOURCES = $(runtime_files)
979libgo_la_LDFLAGS = $(libgo_ldflags) 976libgo_la_LDFLAGS = $(libgo_ldflags)
@@ -1047,7 +1044,7 @@ GOBENCH =
1047CHECK = \ 1044CHECK = \
1048 GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs"; \ 1045 GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs"; \
1049 export GC; \ 1046 export GC; \
1050 GOLIBS="$(extra_check_libs_$(subst .,_,$(subst /,_,$(@D)))) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS) $(RT_LIBS) $(LIBS)"; \ 1047 GOLIBS="$(extra_check_libs_$(subst .,_,$(subst /,_,$(@D)))) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS) $(LIBS)"; \
1051 export GOLIBS; \ 1048 export GOLIBS; \
1052 RUNTESTFLAGS="$(RUNTESTFLAGS)"; \ 1049 RUNTESTFLAGS="$(RUNTESTFLAGS)"; \
1053 export RUNTESTFLAGS; \ 1050 export RUNTESTFLAGS; \
diff --git a/libgo/configure b/libgo/configure
index e2403634281..ffe17c9be55 100755
--- a/libgo/configure
+++ b/libgo/configure
@@ -649,7 +649,6 @@ HAVE_SYS_MMAN_H_FALSE
649HAVE_SYS_MMAN_H_TRUE 649HAVE_SYS_MMAN_H_TRUE
650PTHREAD_LIBS 650PTHREAD_LIBS
651PTHREAD_CFLAGS 651PTHREAD_CFLAGS
652RT_LIBS
653NET_LIBS 652NET_LIBS
654MATH_LIBS 653MATH_LIBS
655GOC_IS_LLGO_FALSE 654GOC_IS_LLGO_FALSE
@@ -11545,7 +11544,7 @@ else
11545 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 11544 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
11546 lt_status=$lt_dlunknown 11545 lt_status=$lt_dlunknown
11547 cat > conftest.$ac_ext <<_LT_EOF 11546 cat > conftest.$ac_ext <<_LT_EOF
11548#line 11548 "configure" 11547#line 11547 "configure"
11549#include "confdefs.h" 11548#include "confdefs.h"
11550 11549
11551#if HAVE_DLFCN_H 11550#if HAVE_DLFCN_H
@@ -11651,7 +11650,7 @@ else
11651 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 11650 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
11652 lt_status=$lt_dlunknown 11651 lt_status=$lt_dlunknown
11653 cat > conftest.$ac_ext <<_LT_EOF 11652 cat > conftest.$ac_ext <<_LT_EOF
11654#line 11654 "configure" 11653#line 11653 "configure"
11655#include "confdefs.h" 11654#include "confdefs.h"
11656 11655
11657#if HAVE_DLFCN_H 11656#if HAVE_DLFCN_H
@@ -14748,12 +14747,6 @@ $as_echo "$libgo_cv_lib_sockets" >&6; }
14748NET_LIBS="$libgo_cv_lib_sockets" 14747NET_LIBS="$libgo_cv_lib_sockets"
14749 14748
14750 14749
14751RT_LIBS=
14752case ${host} in
14753 *-*-linux*) RT_LIBS=-lrt ;;
14754esac
14755
14756
14757{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is supported" >&5 14750{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is supported" >&5
14758$as_echo_n "checking whether -pthread is supported... " >&6; } 14751$as_echo_n "checking whether -pthread is supported... " >&6; }
14759if ${libgo_cv_lib_pthread+:} false; then : 14752if ${libgo_cv_lib_pthread+:} false; then :
diff --git a/libgo/configure.ac b/libgo/configure.ac
index 1b44b226f62..7e2b98ba67c 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -549,12 +549,6 @@ AC_CACHE_CHECK([for socket libraries], libgo_cv_lib_sockets,
549NET_LIBS="$libgo_cv_lib_sockets" 549NET_LIBS="$libgo_cv_lib_sockets"
550AC_SUBST(NET_LIBS) 550AC_SUBST(NET_LIBS)
551 551
552RT_LIBS=
553case ${host} in
554 *-*-linux*) RT_LIBS=-lrt ;;
555esac
556AC_SUBST(RT_LIBS)
557
558dnl Test whether the compiler supports the -pthread option. 552dnl Test whether the compiler supports the -pthread option.
559AC_CACHE_CHECK([whether -pthread is supported], 553AC_CACHE_CHECK([whether -pthread is supported],
560[libgo_cv_lib_pthread], 554[libgo_cv_lib_pthread],
diff --git a/libgo/go/runtime/os_linux.go b/libgo/go/runtime/os_linux.go
index 6ffd8980c5f..96fb178870e 100644
--- a/libgo/go/runtime/os_linux.go
+++ b/libgo/go/runtime/os_linux.go
@@ -18,7 +18,7 @@ type mOS struct {
18 // creates and manages its own timer, and these fields are read and written 18 // creates and manages its own timer, and these fields are read and written
19 // only by this thread. But because some of the reads on profileTimerValid 19 // only by this thread. But because some of the reads on profileTimerValid
20 // are in signal handling code, access to that field uses atomic operations. 20 // are in signal handling code, access to that field uses atomic operations.
21 profileTimer uintptr 21 profileTimer int32
22 profileTimerValid uint32 22 profileTimerValid uint32
23} 23}
24 24
@@ -243,16 +243,17 @@ func osinit() {
243 physHugePageSize = getHugePageSize() 243 physHugePageSize = getHugePageSize()
244} 244}
245 245
246//go:noescape 246func timer_create(clockid int32, sevp *_sigevent, timerid *int32) int32 {
247//extern-sysinfo timer_create 247 return int32(syscall(_SYS_timer_create, uintptr(clockid), uintptr(unsafe.Pointer(sevp)), uintptr(unsafe.Pointer(timerid)), 0, 0, 0))
248func timer_create(clockid int32, sevp *_sigevent, timerid *uintptr) int32 248}
249 249
250//go:noescape 250func timer_settime(timerid int32, flags int32, new, old *_itimerspec) int32 {
251//extern-sysinfo timer_settime 251 return int32(syscall(_SYS_timer_settime, uintptr(timerid), uintptr(flags), uintptr(unsafe.Pointer(new)), uintptr(unsafe.Pointer(old)), 0, 0))
252func timer_settime(timerid uintptr, flags int32, new, old *_itimerspec) int32 252}
253 253
254//extern-sysinfo timer_delete 254func timer_delete(timerid int32) int32 {
255func timer_delete(timerid uintptr) int32 255 return int32(syscall(_SYS_timer_delete, uintptr(timerid), 0, 0, 0, 0, 0))
256}
256 257
257// go118UseTimerCreateProfiler enables the per-thread CPU profiler. 258// go118UseTimerCreateProfiler enables the per-thread CPU profiler.
258const go118UseTimerCreateProfiler = true 259const go118UseTimerCreateProfiler = true
@@ -360,7 +361,7 @@ func setThreadCPUProfiler(hz int32) {
360 spec.it_value.setNsec(1 + int64(fastrandn(uint32(1e9/hz)))) 361 spec.it_value.setNsec(1 + int64(fastrandn(uint32(1e9/hz))))
361 spec.it_interval.setNsec(1e9 / int64(hz)) 362 spec.it_interval.setNsec(1e9 / int64(hz))
362 363
363 var timerid uintptr 364 var timerid int32
364 var sevp _sigevent 365 var sevp _sigevent
365 sevp.sigev_notify = _SIGEV_THREAD_ID 366 sevp.sigev_notify = _SIGEV_THREAD_ID
366 sevp.sigev_signo = _SIGPROF 367 sevp.sigev_signo = _SIGPROF
diff --git a/libgo/testsuite/Makefile.in b/libgo/testsuite/Makefile.in
index 6e143fa3bab..7869265851c 100644
--- a/libgo/testsuite/Makefile.in
+++ b/libgo/testsuite/Makefile.in
@@ -215,7 +215,6 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
215PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ 215PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
216PTHREAD_LIBS = @PTHREAD_LIBS@ 216PTHREAD_LIBS = @PTHREAD_LIBS@
217RANLIB = @RANLIB@ 217RANLIB = @RANLIB@
218RT_LIBS = @RT_LIBS@
219SED = @SED@ 218SED = @SED@
220SET_MAKE = @SET_MAKE@ 219SET_MAKE = @SET_MAKE@
221SHELL = @SHELL@ 220SHELL = @SHELL@