]> Cypherpunks.ru repositories - gostls13.git/commitdiff
runtime: move sys.DefaultGoroot to runtime.defaultGOROOT
authorRuss Cox <rsc@golang.org>
Wed, 27 Jan 2021 15:47:38 +0000 (10:47 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 19 Feb 2021 00:01:45 +0000 (00:01 +0000)
The default GOROOT has nothing to do with system details.
Move it next to its one use in package runtime.

This CL is part of a stack adding windows/arm64
support (#36439), intended to land in the Go 1.17 cycle.
This CL is, however, not windows/arm64-specific.
It is cleanup meant to make the port (and future ports) easier.

Change-Id: I1a601fad6335336b4616b834bb21bd8437ee1313
Reviewed-on: https://go-review.googlesource.com/c/go/+/288796
Trust: Russ Cox <rsc@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
src/cmd/link/internal/ld/main.go
src/runtime/extern.go
src/runtime/internal/sys/arch.go

index cbd811846b6ffae60d9c3dbd528a549bc431cea0..68dee1859878b7e0d1d7a8f061fa1c67d21219a8 100644 (file)
@@ -116,7 +116,7 @@ func Main(arch *sys.Arch, theArch Arch) {
        }
 
        final := gorootFinal()
-       addstrdata1(ctxt, "runtime/internal/sys.DefaultGoroot="+final)
+       addstrdata1(ctxt, "runtime.defaultGOROOT="+final)
        addstrdata1(ctxt, "cmd/internal/objabi.defaultGOROOT="+final)
 
        // TODO(matloob): define these above and then check flag values here
index dacdf4f38308da4de04b780c5993bf66209c75ff..bbe41dd0d430a4e59894244496c9392aef2d9222 100644 (file)
@@ -229,6 +229,8 @@ func Callers(skip int, pc []uintptr) int {
        return callers(skip, pc)
 }
 
+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.
@@ -237,7 +239,7 @@ func GOROOT() string {
        if s != "" {
                return s
        }
-       return sys.DefaultGoroot
+       return defaultGOROOT
 }
 
 // Version returns the Go tree's version string.
index 69278bf2d5ea89dde8b373e3deb7ec4ab6231957..3c99a2f7da0831048e2aa5ae24cb8914e5d83785 100644 (file)
@@ -52,7 +52,3 @@ const MinFrameSize = _MinFrameSize
 // StackAlign is the required alignment of the SP register.
 // The stack must be at least word aligned, but some architectures require more.
 const StackAlign = _StackAlign
-
-// DefaultGoroot is set by the linker for use by package runtime.
-// It doesn't really belong in this file or this package.
-var DefaultGoroot string