runtime: set runtime.GOROOT value at build time
authorIan Lance Taylor <iant@golang.org>
Tue, 21 Sep 2021 18:44:26 +0000 (11:44 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 21 Sep 2021 21:31:10 +0000 (14:31 -0700)
In Go 1.17 the gc toolchain changed to set runtime.GOROOT in cmd/link
(previously it was runtime/internal/sys.GOROOT).  Do the same in libgo.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/351313

gotools/:
* Makefile.am (check-runtime): Add goroot.go to --extrafiles.
* Makefile.in: Regenerate.

gcc/go/gofrontend/MERGE
gotools/Makefile.am
gotools/Makefile.in
libgo/Makefile.am
libgo/Makefile.in
libgo/go/runtime/extern.go

index e2abd5f..edfbe46 100644 (file)
@@ -1,4 +1,4 @@
-850235e4b974b9c5c2d7a1f9860583bd07f2a45c
+e3bfc0889237a5bb8aa7ae30e1cff14f90a5f941
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 6576fe7..199899b 100644 (file)
@@ -245,14 +245,14 @@ check-runtime: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc
        export LD_LIBRARY_PATH; \
        GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \
        GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \
        export LD_LIBRARY_PATH; \
        GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \
        GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \
-       files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_linknames.go $(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go" --tag=libffi`; \
+       files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_linknames.go $(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go $(libgodir)/goroot.go" --tag=libffi`; \
        echo "$(ECHO_ENV) GC='$(abs_builddir)/check-gccgo -fgo-compiling-runtime' GOARCH=$${GOARCH} GOOS=$${GOOS} $(SHELL) $(libgosrcdir)/../testsuite/gotest --goarch=$${GOARCH} --goos=$${GOOS} --basedir=$(libgosrcdir)/.. --srcdir=$(libgosrcdir)/runtime --pkgpath=runtime --pkgfiles='$${files}' $(GOTESTFLAGS) -test.timeout=$(GOTOOLS_TEST_TIMEOUT)s -test.v" > runtime-testlog
        $(CHECK_ENV) \
        GC="$${GCCGO} -fgo-compiling-runtime"; \
        export GC; \
        GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \
        GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \
        echo "$(ECHO_ENV) GC='$(abs_builddir)/check-gccgo -fgo-compiling-runtime' GOARCH=$${GOARCH} GOOS=$${GOOS} $(SHELL) $(libgosrcdir)/../testsuite/gotest --goarch=$${GOARCH} --goos=$${GOOS} --basedir=$(libgosrcdir)/.. --srcdir=$(libgosrcdir)/runtime --pkgpath=runtime --pkgfiles='$${files}' $(GOTESTFLAGS) -test.timeout=$(GOTOOLS_TEST_TIMEOUT)s -test.v" > runtime-testlog
        $(CHECK_ENV) \
        GC="$${GCCGO} -fgo-compiling-runtime"; \
        export GC; \
        GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \
        GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \
-       files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_linknames.go $(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go" --tag=libffi`; \
+       files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_linknames.go $(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go $(libgodir)/goroot.go" --tag=libffi`; \
        $(SHELL) $(libgosrcdir)/../testsuite/gotest --goarch=$${GOARCH} --goos=$${GOOS} --basedir=$(libgosrcdir)/.. --srcdir=$(libgosrcdir)/runtime --pkgpath=runtime --pkgfiles="$${files}" $(GOTESTFLAGS) -test.timeout=$(GOTOOLS_TEST_TIMEOUT)s -test.v >> runtime-testlog 2>&1 || echo "--- $${fl}: go test runtime (0.00s)" >> runtime-testlog
        grep '^--- ' runtime-testlog | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' | sort -k 2
 
        $(SHELL) $(libgosrcdir)/../testsuite/gotest --goarch=$${GOARCH} --goos=$${GOOS} --basedir=$(libgosrcdir)/.. --srcdir=$(libgosrcdir)/runtime --pkgpath=runtime --pkgfiles="$${files}" $(GOTESTFLAGS) -test.timeout=$(GOTOOLS_TEST_TIMEOUT)s -test.v >> runtime-testlog 2>&1 || echo "--- $${fl}: go test runtime (0.00s)" >> runtime-testlog
        grep '^--- ' runtime-testlog | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' | sort -k 2
 
index c442686..e2c30bf 100644 (file)
@@ -703,8 +703,8 @@ distclean-generic:
 maintainer-clean-generic:
        @echo "This command is intended for maintainers to use"
        @echo "it deletes files that may require special tools to rebuild."
 maintainer-clean-generic:
        @echo "This command is intended for maintainers to use"
        @echo "it deletes files that may require special tools to rebuild."
-@NATIVE_FALSE@uninstall-local:
 @NATIVE_FALSE@install-exec-local:
 @NATIVE_FALSE@install-exec-local:
+@NATIVE_FALSE@uninstall-local:
 clean: clean-am
 
 clean-am: clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \
 clean: clean-am
 
 clean-am: clean-binPROGRAMS clean-generic clean-noinstPROGRAMS \
@@ -916,14 +916,14 @@ mostlyclean-local:
 @NATIVE_TRUE@  export LD_LIBRARY_PATH; \
 @NATIVE_TRUE@  GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \
 @NATIVE_TRUE@  GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \
 @NATIVE_TRUE@  export LD_LIBRARY_PATH; \
 @NATIVE_TRUE@  GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \
 @NATIVE_TRUE@  GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \
-@NATIVE_TRUE@  files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_linknames.go $(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go" --tag=libffi`; \
+@NATIVE_TRUE@  files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_linknames.go $(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go $(libgodir)/goroot.go" --tag=libffi`; \
 @NATIVE_TRUE@  echo "$(ECHO_ENV) GC='$(abs_builddir)/check-gccgo -fgo-compiling-runtime' GOARCH=$${GOARCH} GOOS=$${GOOS} $(SHELL) $(libgosrcdir)/../testsuite/gotest --goarch=$${GOARCH} --goos=$${GOOS} --basedir=$(libgosrcdir)/.. --srcdir=$(libgosrcdir)/runtime --pkgpath=runtime --pkgfiles='$${files}' $(GOTESTFLAGS) -test.timeout=$(GOTOOLS_TEST_TIMEOUT)s -test.v" > runtime-testlog
 @NATIVE_TRUE@  $(CHECK_ENV) \
 @NATIVE_TRUE@  GC="$${GCCGO} -fgo-compiling-runtime"; \
 @NATIVE_TRUE@  export GC; \
 @NATIVE_TRUE@  GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \
 @NATIVE_TRUE@  GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \
 @NATIVE_TRUE@  echo "$(ECHO_ENV) GC='$(abs_builddir)/check-gccgo -fgo-compiling-runtime' GOARCH=$${GOARCH} GOOS=$${GOOS} $(SHELL) $(libgosrcdir)/../testsuite/gotest --goarch=$${GOARCH} --goos=$${GOOS} --basedir=$(libgosrcdir)/.. --srcdir=$(libgosrcdir)/runtime --pkgpath=runtime --pkgfiles='$${files}' $(GOTESTFLAGS) -test.timeout=$(GOTOOLS_TEST_TIMEOUT)s -test.v" > runtime-testlog
 @NATIVE_TRUE@  $(CHECK_ENV) \
 @NATIVE_TRUE@  GC="$${GCCGO} -fgo-compiling-runtime"; \
 @NATIVE_TRUE@  export GC; \
 @NATIVE_TRUE@  GOARCH=`$(abs_builddir)/go$(EXEEXT) env GOARCH`; \
 @NATIVE_TRUE@  GOOS=`$(abs_builddir)/go$(EXEEXT) env GOOS`; \
-@NATIVE_TRUE@  files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_linknames.go $(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go" --tag=libffi`; \
+@NATIVE_TRUE@  files=`$(SHELL) $(libgosrcdir)/../match.sh --goarch=$${GOARCH} --goos=$${GOOS} --srcdir=$(libgosrcdir)/runtime --extrafiles="$(libgodir)/runtime_linknames.go $(libgodir)/runtime_sysinfo.go $(libgodir)/sigtab.go $(libgodir)/goroot.go" --tag=libffi`; \
 @NATIVE_TRUE@  $(SHELL) $(libgosrcdir)/../testsuite/gotest --goarch=$${GOARCH} --goos=$${GOOS} --basedir=$(libgosrcdir)/.. --srcdir=$(libgosrcdir)/runtime --pkgpath=runtime --pkgfiles="$${files}" $(GOTESTFLAGS) -test.timeout=$(GOTOOLS_TEST_TIMEOUT)s -test.v >> runtime-testlog 2>&1 || echo "--- $${fl}: go test runtime (0.00s)" >> runtime-testlog
 @NATIVE_TRUE@  grep '^--- ' runtime-testlog | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' | sort -k 2
 
 @NATIVE_TRUE@  $(SHELL) $(libgosrcdir)/../testsuite/gotest --goarch=$${GOARCH} --goos=$${GOOS} --basedir=$(libgosrcdir)/.. --srcdir=$(libgosrcdir)/runtime --pkgpath=runtime --pkgfiles="$${files}" $(GOTESTFLAGS) -test.timeout=$(GOTOOLS_TEST_TIMEOUT)s -test.v >> runtime-testlog 2>&1 || echo "--- $${fl}: go test runtime (0.00s)" >> runtime-testlog
 @NATIVE_TRUE@  grep '^--- ' runtime-testlog | sed -e 's/^--- \(.*\) ([^)]*)$$/\1/' | sort -k 2
 
index 92fedcf..5c377a3 100644 (file)
@@ -545,6 +545,14 @@ s-gcpu: Makefile
        $(SHELL) $(srcdir)/mvifdiff.sh gcpugen.go.tmp gcpugen.go
        $(STAMP) $@
 
        $(SHELL) $(srcdir)/mvifdiff.sh gcpugen.go.tmp gcpugen.go
        $(STAMP) $@
 
+goroot.go: s-goroot; @true
+s-goroot: Makefile
+       rm -f goroot.go.tmp
+       echo "package runtime" > goroot.go.tmp
+       echo 'var defaultGOROOT = `$(prefix)`' >> goroot.go.tmp
+       $(SHELL) $(srcdir)/mvifdiff.sh goroot.go.tmp goroot.go
+       $(STAMP) $@
+
 buildcfg.go: s-buildcfg; @true
 s-buildcfg: Makefile
        rm -f buildcfg.go.tmp
 buildcfg.go: s-buildcfg; @true
 s-buildcfg: Makefile
        rm -f buildcfg.go.tmp
@@ -1005,7 +1013,8 @@ math_lo_GOCFLAGS = $(MATH_FLAG)
 math_check_GOCFLAGS = $(MATH_FLAG)
 
 # Add generated files to the runtime package.
 math_check_GOCFLAGS = $(MATH_FLAG)
 
 # Add generated files to the runtime package.
-extra_go_files_runtime = runtime_linknames.go runtime_sysinfo.go sigtab.go
+extra_go_files_runtime = \
+       runtime_linknames.go runtime_sysinfo.go sigtab.go goroot.go
 runtime.lo.dep: $(extra_go_files_runtime)
 
 # Add generated files to the syscall package.
 runtime.lo.dep: $(extra_go_files_runtime)
 
 # Add generated files to the syscall package.
index 3b2bdf9..1240b16 100644 (file)
@@ -1098,7 +1098,9 @@ math_lo_GOCFLAGS = $(MATH_FLAG)
 math_check_GOCFLAGS = $(MATH_FLAG)
 
 # Add generated files to the runtime package.
 math_check_GOCFLAGS = $(MATH_FLAG)
 
 # Add generated files to the runtime package.
-extra_go_files_runtime = runtime_linknames.go runtime_sysinfo.go sigtab.go
+extra_go_files_runtime = \
+       runtime_linknames.go runtime_sysinfo.go sigtab.go goroot.go
+
 
 # Add generated files to the syscall package.
 extra_go_files_syscall = \
 
 # Add generated files to the syscall package.
 extra_go_files_syscall = \
@@ -2752,6 +2754,14 @@ s-gcpu: Makefile
        $(SHELL) $(srcdir)/mvifdiff.sh gcpugen.go.tmp gcpugen.go
        $(STAMP) $@
 
        $(SHELL) $(srcdir)/mvifdiff.sh gcpugen.go.tmp gcpugen.go
        $(STAMP) $@
 
+goroot.go: s-goroot; @true
+s-goroot: Makefile
+       rm -f goroot.go.tmp
+       echo "package runtime" > goroot.go.tmp
+       echo 'var defaultGOROOT = `$(prefix)`' >> goroot.go.tmp
+       $(SHELL) $(srcdir)/mvifdiff.sh goroot.go.tmp goroot.go
+       $(STAMP) $@
+
 buildcfg.go: s-buildcfg; @true
 s-buildcfg: Makefile
        rm -f buildcfg.go.tmp
 buildcfg.go: s-buildcfg; @true
 s-buildcfg: Makefile
        rm -f buildcfg.go.tmp
index 0d7f357..6bd612f 100644 (file)
@@ -211,8 +211,6 @@ func Caller(skip int) (pc uintptr, file string, line int, ok bool)
 // program counter adjustment.
 func Callers(skip int, pc []uintptr) int
 
 // program counter adjustment.
 func Callers(skip int, pc []uintptr) int
 
-var defaultGOROOT string // set by cmd/link
-
 // GOROOT returns the root of the Go tree. It uses the
 // GOROOT environment variable, if set at process start,
 // or else the root used during the Go build.
 // GOROOT returns the root of the Go tree. It uses the
 // GOROOT environment variable, if set at process start,
 // or else the root used during the Go build.