From 75791bab05ec4a45a5c6a4dccd7f824ea8f4487c Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 30 Aug 2016 21:07:47 +0000 Subject: runtime: use -fgo-c-header to build C header file Use the new -fgo-c-header option to build a header file for the Go runtime code in libgo/go/runtime, and use the new header file in the C runtime code in libgo/runtime. This will ensure that the Go code and C code share the same data structures as we convert the runtime from C to Go. The new file libgo/go/runtime/runtime2.go is copied from the Go 1.7 release, and then edited to remove unnecessary data structures and modify others for use with libgo. The new file libgo/go/runtime/mcache.go is an initial version of the same files in the Go 1.7 release, and will be replaced by the Go 1.7 file when we convert to the new memory allocator. The new file libgo/go/runtime/type.go describes the gccgo version of the reflection data structures, and replaces the Go 1.7 runtime file which describes the gc version of those structures. Using the new header file means changing a number of struct fields to use Go naming conventions (that is, no underscores) and to rename constants to have a leading underscore so that they are not exported from the Go package. These names were updated in the C code. The C code was also changed to drop the thread-local variable m, as was done some time ago in the gc sources. Now the m field is always accessed using g->m, where g is the single remaining thread-local variable. This in turn required some adjustments to set g->m correctly in all cases. Also pass the new -fgo-compiling-runtime option when compiling the runtime package, although that option doesn't do anything yet. Reviewed-on: https://go-review.googlesource.com/28051 From-SVN: r239872 --- libgo/Makefile.in | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'libgo/Makefile.in') diff --git a/libgo/Makefile.in b/libgo/Makefile.in index 568683a..d9c5100 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -1162,7 +1162,7 @@ BUILDDEPS = \ BUILDPACKAGE = \ $(MKDIR_P) $(@D); \ files=`echo $^ | sed -e 's/[^ ]*\.gox//g' -e 's/[^ ]*\.dep//'`; \ - $(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//' -e 's/-go$$//'` -o $@ $$files + $(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//' -e 's/-go$$//'` $($(subst -,_,$(subst .,_,$(subst /,_,$@)))_GOCFLAGS) -o $@ $$files # Build deps for netgo.o. @@ -1235,7 +1235,8 @@ CHECK_DEPS = $(toolexeclibgo_DATA) $(toolexeclibgoarchive_DATA) \ @HAVE_STAT_TIMESPEC_FALSE@@LIBGO_IS_SOLARIS_TRUE@matchargs_os = @HAVE_STAT_TIMESPEC_TRUE@@LIBGO_IS_SOLARIS_TRUE@matchargs_os = --tag=solaristag @LIBGO_IS_SOLARIS_FALSE@matchargs_os = -extra_go_files_runtime = version.go +extra_go_files_runtime = runtime_sysinfo.go version.go +runtime_go_lo_GOCFLAGS = -fgo-c-header=runtime.inc.tmp -fgo-compiling-runtime @LIBGO_IS_BSD_TRUE@golang_org_x_net_route_lo = \ @LIBGO_IS_BSD_TRUE@ golang_org/x/net/route/route.lo @@ -3570,6 +3571,16 @@ s-version: Makefile $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go $(STAMP) $@ +runtime_sysinfo.go: s-runtime_sysinfo; @true +s-runtime_sysinfo: sysinfo.go + rm -f tmp-runtime_sysinfo.go + echo 'package runtime' > tmp-runtime_sysinfo.go + echo >> tmp-runtime_sysinfo.go + grep 'const _sizeof_ucontext_t ' sysinfo.go >> tmp-runtime_sysinfo.go + grep 'type _sigset_t ' sysinfo.go >> tmp-runtime_sysinfo.go + $(SHELL) $(srcdir)/mvifdiff.sh tmp-runtime_sysinfo.go runtime_sysinfo.go + $(STAMP) $@ + # Generate the list of go std packages that were included in libgo zstdpkglist.go: s-zstdpkglist; @true s-zstdpkglist: Makefile @@ -3639,6 +3650,13 @@ s-epoll: Makefile $(SHELL) $(srcdir)/mvifdiff.sh epoll.go.tmp epoll.go $(STAMP) $@ +# Make sure runtime.inc is built before compiling any .c file. +$(libgo_la_OBJECTS): runtime.inc +$(libgo_llgo_la_OBJECTS): runtime.inc +$(libgobegin_a_OBJECTS): runtime.inc +$(libgobegin_llgo_a_OBJECTS): runtime.inc +$(libgolibbegin_a_OBJECTS): runtime.inc + @go_include@ bufio.lo.dep bufio.lo.dep: $(srcdir)/go/bufio/*.go $(BUILDDEPS) @@ -3653,7 +3671,7 @@ bytes.lo.dep: $(srcdir)/go/bytes/*.go $(BUILDDEPS) bytes.lo: $(BUILDPACKAGE) -bytes/index.lo: go/bytes/indexbyte.c +bytes/index.lo: go/bytes/indexbyte.c runtime.inc @$(MKDIR_P) bytes $(LTCOMPILE) -c -o bytes/index.lo $(srcdir)/go/bytes/indexbyte.c bytes/check: $(CHECK_DEPS) @@ -3828,7 +3846,7 @@ reflect-go.lo: $(BUILDPACKAGE) reflect/check: $(CHECK_DEPS) @$(CHECK) -reflect/makefunc_ffi_c.lo: go/reflect/makefunc_ffi_c.c +reflect/makefunc_ffi_c.lo: go/reflect/makefunc_ffi_c.c runtime.inc @$(MKDIR_P) reflect $(LTCOMPILE) -c -o $@ $< .PHONY: reflect/check @@ -3843,10 +3861,14 @@ regexp/check: $(CHECK_DEPS) .PHONY: regexp/check @go_include@ runtime-go.lo.dep -runtime-go.lo.dep: $(srcdir)/go/runtime/*.go +runtime-go.lo.dep: $(srcdir)/go/runtime/*.go $(extra_go_files_runtime) $(BUILDDEPS) runtime-go.lo: $(BUILDPACKAGE) +runtime.inc: s-runtime-inc; @true +s-runtime-inc: runtime-go.lo + $(SHELL) $(srcdir)/mvifdiff.sh runtime.inc.tmp runtime.inc + $(STAMP) $@ runtime/check: $(CHECK_DEPS) @$(CHECK) .PHONY: runtime/check @@ -3874,7 +3896,7 @@ strings.lo.dep: $(srcdir)/go/strings/*.go $(BUILDDEPS) strings.lo: $(BUILDPACKAGE) -strings/index.lo: go/strings/indexbyte.c +strings/index.lo: go/strings/indexbyte.c runtime.inc @$(MKDIR_P) strings $(LTCOMPILE) -c -o strings/index.lo $(srcdir)/go/strings/indexbyte.c strings/check: $(CHECK_DEPS) @@ -4688,7 +4710,7 @@ log/syslog.lo.dep: $(srcdir)/go/log/syslog/*.go $(BUILDDEPS) log/syslog.lo: $(BUILDPACKAGE) -log/syslog/syslog_c.lo: go/log/syslog/syslog_c.c log/syslog.lo +log/syslog/syslog_c.lo: go/log/syslog/syslog_c.c runtime.inc log/syslog.lo @$(MKDIR_P) log/syslog $(LTCOMPILE) -c -o $@ $(srcdir)/go/log/syslog/syslog_c.c log/syslog/check: $(CHECK_DEPS) @@ -4970,7 +4992,7 @@ sync/atomic.lo.dep: $(srcdir)/go/sync/atomic/*.go $(BUILDDEPS) sync/atomic.lo: $(BUILDPACKAGE) -sync/atomic_c.lo: go/sync/atomic/atomic.c sync/atomic.lo +sync/atomic_c.lo: go/sync/atomic/atomic.c runtime.inc sync/atomic.lo $(LTCOMPILE) -c -o $@ $(srcdir)/go/sync/atomic/atomic.c sync/atomic/check: $(CHECK_DEPS) @$(CHECK) @@ -5049,17 +5071,17 @@ unicode/utf8/check: $(CHECK_DEPS) .PHONY: unicode/utf8/check @go_include@ syscall.lo.dep -syscall.lo.dep: $(srcdir)/go/syscall/*.go +syscall.lo.dep: $(srcdir)/go/syscall/*.go $(extra_go_files_syscall) $(BUILDDEPS) syscall.lo: $(BUILDPACKAGE) -syscall/errno.lo: go/syscall/errno.c +syscall/errno.lo: go/syscall/errno.c runtime.inc @$(MKDIR_P) syscall $(LTCOMPILE) -c -o $@ $< -syscall/signame.lo: go/syscall/signame.c +syscall/signame.lo: go/syscall/signame.c runtime.inc @$(MKDIR_P) syscall $(LTCOMPILE) -c -o $@ $< -syscall/wait.lo: go/syscall/wait.c +syscall/wait.lo: go/syscall/wait.c runtime.inc @$(MKDIR_P) syscall $(LTCOMPILE) -c -o $@ $< syscall/check: $(CHECK_DEPS) -- cgit v1.1