libgo patch committed: set runtime.GOROOT at build time

Message ID CAOyqgcU8WoLDH1JzgQBwXAJEfMNHa5n2khf6jnyBoPPSxKDOFw@mail.gmail.com
State Committed
Commit 09e18d113b3c3dae896ac1a8ad1e0087adbb153b
Headers
Series libgo patch committed: set runtime.GOROOT at build time |

Commit Message

Ian Lance Taylor Sept. 21, 2021, 9:31 p.m. UTC
  This patch changes libto to set runtime.GOROOT value at build time.
In Go 1.17 the gc toolchain changed to set runtime.GOROOT in cmd/link
(previously it was runtime/internal/sys.GOROOT).  This patch does the
same in libgo.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian

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

Patch

diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index e2abd5fc4b7..edfbe46d8f4 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -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.
diff --git a/gotools/Makefile.am b/gotools/Makefile.am
index 6576fe77b85..199899b9ef0 100644
--- a/gotools/Makefile.am
+++ b/gotools/Makefile.am
@@ -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`; \
-	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`; \
-	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
 
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index 92fedcf6eb8..5c377a30df9 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -545,6 +545,14 @@  s-gcpu: Makefile
 	$(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
@@ -1005,7 +1013,8 @@  math_lo_GOCFLAGS = $(MATH_FLAG)
 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.
diff --git a/libgo/go/runtime/extern.go b/libgo/go/runtime/extern.go
index 0d7f3577913..6bd612fcf32 100644
--- a/libgo/go/runtime/extern.go
+++ b/libgo/go/runtime/extern.go
@@ -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
 
-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.