cmd/go: update to match recent changes to gc
authorIan Lance Taylor <ian@gcc.gnu.org>
Fri, 4 May 2018 01:34:30 +0000 (01:34 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Fri, 4 May 2018 01:34:30 +0000 (01:34 +0000)
    In https://golang.org/cl/111097 the gc version of cmd/go was updated
    to include some gofrontend-specific changes. The gofrontend code
    already has different versions of those changes; this CL makes the
    gofrontend match the upstream code.

    Reviewed-on: https://go-review.googlesource.com/111099

From-SVN: r259918

gcc/go/gofrontend/MERGE
libgo/go/cmd/go/alldocs.go
libgo/go/cmd/go/internal/cfg/cfg.go
libgo/go/cmd/go/internal/help/helpdoc.go
libgo/go/cmd/go/internal/load/pkg.go
libgo/go/go/build/build.go
libgo/go/go/build/gc.go [new file with mode: 0644]
libgo/go/go/build/gccgo.go [new file with mode: 0644]

index 614333d96d73ab45b2e45a5a90a71f100612873e..c45c9181ac44eed68f0b1872af77dd898c0a18db 100644 (file)
@@ -1,4 +1,4 @@
-85ca682349af2cb1aa6b1eecac794aeb73d24f15
+bf6f714559bd7b27b7686811aaf0f6e8e7f1c0d5
 
 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 5e1ac5aaf571f90fa5f6a58aee4a43b131e151c2..aadf97c064f76c9c8ce2cfa5433f1a6b9e6b78cf 100644 (file)
 //
 // Special-purpose environment variables:
 //
 //
 // Special-purpose environment variables:
 //
+//     GCCGOTOOLDIR
+//             If set, where to find gccgo tools, such as cgo.
+//             The default is based on how gccgo was configured.
 //     GOROOT_FINAL
 //             The root of the installed Go tree, when it is
 //             installed in a location other than where it is built.
 //     GOROOT_FINAL
 //             The root of the installed Go tree, when it is
 //             installed in a location other than where it is built.
 //             Defined by Git. A colon-separated list of schemes that are allowed to be used
 //             with git fetch/clone. If set, any scheme not explicitly mentioned will be
 //             considered insecure by 'go get'.
 //             Defined by Git. A colon-separated list of schemes that are allowed to be used
 //             with git fetch/clone. If set, any scheme not explicitly mentioned will be
 //             considered insecure by 'go get'.
-//     GCCGOTOOLDIR
-//             If set, where to find gccgo tools, such as cgo.
-//             The default is based on how gccgo was configured.
 //
 //
 // Import path syntax
 //
 //
 // Import path syntax
index bfdd67e842d3aaa7b9cd42764c33f7bc5e9b6aa9..f0a2277d1b22b411a8c48323b41a2a7270443190 100644 (file)
@@ -92,11 +92,12 @@ var (
 // Update build context to use our computed GOROOT.
 func init() {
        BuildContext.GOROOT = GOROOT
 // Update build context to use our computed GOROOT.
 func init() {
        BuildContext.GOROOT = GOROOT
-       // Note that we must use runtime.GOOS and runtime.GOARCH here,
-       // as the tool directory does not move based on environment variables.
-       // This matches the initialization of ToolDir in go/build,
-       // except for using GOROOT rather than runtime.GOROOT().
        if runtime.Compiler != "gccgo" {
        if runtime.Compiler != "gccgo" {
+               // Note that we must use runtime.GOOS and runtime.GOARCH here,
+               // as the tool directory does not move based on environment
+               // variables. This matches the initialization of ToolDir in
+               // go/build, except for using GOROOT rather than
+               // runtime.GOROOT.
                build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
        }
 }
                build.ToolDir = filepath.Join(GOROOT, "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
        }
 }
@@ -107,6 +108,8 @@ func findGOROOT() string {
        }
        def := filepath.Clean(runtime.GOROOT())
        if runtime.Compiler == "gccgo" {
        }
        def := filepath.Clean(runtime.GOROOT())
        if runtime.Compiler == "gccgo" {
+               // gccgo has no real GOROOT, and it certainly doesn't
+               // depend on the executable's location.
                return def
        }
        exe, err := os.Executable()
                return def
        }
        exe, err := os.Executable()
index 9a9fc4e944891c2eefb8704a242c3c2546684683..6aa449a8e29ecfe5575dbe8c1b26ea4eea614ea8 100644 (file)
@@ -526,6 +526,9 @@ Architecture-specific environment variables:
 
 Special-purpose environment variables:
 
 
 Special-purpose environment variables:
 
+       GCCGOTOOLDIR
+               If set, where to find gccgo tools, such as cgo.
+               The default is based on how gccgo was configured.
        GOROOT_FINAL
                The root of the installed Go tree, when it is
                installed in a location other than where it is built.
        GOROOT_FINAL
                The root of the installed Go tree, when it is
                installed in a location other than where it is built.
@@ -539,9 +542,6 @@ Special-purpose environment variables:
                Defined by Git. A colon-separated list of schemes that are allowed to be used
                with git fetch/clone. If set, any scheme not explicitly mentioned will be
                considered insecure by 'go get'.
                Defined by Git. A colon-separated list of schemes that are allowed to be used
                with git fetch/clone. If set, any scheme not explicitly mentioned will be
                considered insecure by 'go get'.
-       GCCGOTOOLDIR
-               If set, where to find gccgo tools, such as cgo.
-               The default is based on how gccgo was configured.
        `,
 }
 
        `,
 }
 
index 52ff6b8fcd29073a5dcf12c13a72a0f018ec9f9a..d3026072e09d5d2c3f50293c21c41f4d51782963 100644 (file)
@@ -13,7 +13,6 @@ import (
        "os"
        pathpkg "path"
        "path/filepath"
        "os"
        pathpkg "path"
        "path/filepath"
-       "runtime"
        "sort"
        "strings"
        "unicode"
        "sort"
        "strings"
        "unicode"
@@ -976,7 +975,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) {
                        // This is for 'go tool'.
                        // Override all the usual logic and force it into the tool directory.
                        if cfg.BuildToolchainName == "gccgo" {
                        // This is for 'go tool'.
                        // Override all the usual logic and force it into the tool directory.
                        if cfg.BuildToolchainName == "gccgo" {
-                               p.Target = filepath.Join(runtime.GCCGOTOOLDIR, elem)
+                               p.Target = filepath.Join(base.ToolDir, elem)
                        } else {
                                p.Target = filepath.Join(cfg.GOROOTpkg, "tool", full)
                        }
                        } else {
                                p.Target = filepath.Join(cfg.GOROOTpkg, "tool", full)
                        }
index 79024042136952f032ce715e44f6ca34a06af92a..4e779557942cf746fd2e21bd3880fe9842816cc7 100644 (file)
@@ -1595,14 +1595,7 @@ func init() {
        }
 }
 
        }
 }
 
-func getToolDir() string {
-       if runtime.Compiler == "gccgo" {
-               return envOr("GCCGOTOOLDIR", runtime.GCCGOTOOLDIR)
-       } else {
-               return filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
-       }
-}
-
+// ToolDir is the directory containing build tools.
 var ToolDir = getToolDir()
 
 // IsLocalImport reports whether the import path is
 var ToolDir = getToolDir()
 
 // IsLocalImport reports whether the import path is
diff --git a/libgo/go/go/build/gc.go b/libgo/go/go/build/gc.go
new file mode 100644 (file)
index 0000000..3025cd5
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build gc
+
+package build
+
+import (
+       "path/filepath"
+       "runtime"
+)
+
+// getToolDir returns the default value of ToolDir.
+func getToolDir() string {
+       return filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)
+}
diff --git a/libgo/go/go/build/gccgo.go b/libgo/go/go/build/gccgo.go
new file mode 100644 (file)
index 0000000..c6aac9a
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build gccgo
+
+package build
+
+import "runtime"
+
+// getToolDir returns the default value of ToolDir.
+func getToolDir() string {
+       return envOr("GCCGOTOOLDIR", runtime.GCCGOTOOLDIR)
+}