]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/cmd/dist/build.go
[dev.cc] all: merge master (b8fcae0) into dev.cc
[gostls13.git] / src / cmd / dist / build.go
index e36df51f5dce1afcddebc0c3f652c82c55ea2f82..152655b5086fb51c3eb5219ea43656dbbdef69ba 100644 (file)
@@ -37,6 +37,7 @@ var (
        oldgoarch        string
        oldgochar        string
        slash            string
+       exe              string
        defaultcc        string
        defaultcflags    string
        defaultldflags   string
@@ -356,6 +357,7 @@ var oldtool = []string{
 // not be in release branches.
 var unreleased = []string{
        "src/cmd/link",
+       "src/cmd/objwriter",
        "src/debug/goobj",
        "src/old",
 }
@@ -626,13 +628,20 @@ func install(dir string) {
                ldargs = splitfields(defaultldflags)
        }
 
-       islib := strings.HasPrefix(dir, "lib") || dir == "cmd/gc"
-       ispkg := !islib && !strings.HasPrefix(dir, "cmd/")
-       isgo := ispkg || dir == "cmd/go" || dir == "cmd/cgo"
+       isgo := true
+       ispkg := !strings.HasPrefix(dir, "cmd/") || strings.HasPrefix(dir, "cmd/internal/")
+       islib := false
 
-       exe := ""
-       if gohostos == "windows" {
-               exe = ".exe"
+       // Legacy C exceptions.
+       switch dir {
+       case "lib9", "libbio", "liblink", "cmd/gc":
+               islib = true
+               isgo = false
+       case "cmd/5a", "cmd/5g", "cmd/5l",
+               "cmd/6a", "cmd/6g", "cmd/6l",
+               "cmd/8a", "cmd/8g", "cmd/8l",
+               "cmd/9a", "cmd/9g", "cmd/9l":
+               isgo = false
        }
 
        // Start final link command line.
@@ -902,6 +911,8 @@ func install(dir string) {
                                compile = append(compile,
                                        "-D", fmt.Sprintf("GOOS=%q", goos),
                                        "-D", fmt.Sprintf("GOARCH=%q", goarch),
+                                       "-D", fmt.Sprintf("GOHOSTOS=%q", gohostos),
+                                       "-D", fmt.Sprintf("GOHOSTARCH=%q", gohostarch),
                                        "-D", fmt.Sprintf("GOROOT=%q", goroot_final),
                                        "-D", fmt.Sprintf("GOVERSION=%q", goversion),
                                        "-D", fmt.Sprintf("GOARM=%q", goarm),
@@ -1097,7 +1108,10 @@ func dopack(dst, src string, extra []string) {
 }
 
 // buildorder records the order of builds for the 'go bootstrap' command.
+// The Go packages and commands must be in dependency order,
+// maintained by hand, but the order doesn't change often.
 var buildorder = []string{
+       // Legacy C programs.
        "lib9",
        "libbio",
        "liblink",
@@ -1107,10 +1121,7 @@ var buildorder = []string{
        "cmd/%sa",
        "cmd/%sg",
 
-       // The dependency order here was copied from a buildscript
-       // back when there were build scripts.  Will have to
-       // be maintained by hand, but shouldn't change very
-       // often.
+       // Go libraries and programs for bootstrap.
        "runtime",
        "errors",
        "sync/atomic",
@@ -1133,6 +1144,7 @@ var buildorder = []string{
        "reflect",
        "fmt",
        "encoding",
+       "encoding/binary",
        "encoding/json",
        "flag",
        "path/filepath",
@@ -1152,6 +1164,12 @@ var buildorder = []string{
        "text/template",
        "go/doc",
        "go/build",
+       "cmd/internal/obj",
+       "cmd/internal/obj/arm",
+       "cmd/internal/obj/i386",
+       "cmd/internal/obj/ppc64",
+       "cmd/internal/obj/x86",
+       "cmd/objwriter",
        "cmd/go",
 }
 
@@ -1347,6 +1365,8 @@ func cmdbootstrap() {
 
        setup()
 
+       bootstrapBuildTools()
+
        // For the main bootstrap, building for host os/arch.
        oldgoos = goos
        oldgoarch = goarch
@@ -1359,6 +1379,31 @@ func cmdbootstrap() {
        os.Setenv("GOARCH", goarch)
        os.Setenv("GOOS", goos)
 
+       // TODO(rsc): Enable when appropriate.
+       // This step is only needed if we believe that the Go compiler built from Go 1.4
+       // will produce different object files than the Go compiler built from itself.
+       // In the absence of bugs, that should not happen.
+       // And if there are bugs, they're more likely in the current development tree
+       // than in a standard release like Go 1.4, so don't do this rebuild by default.
+       if false {
+               xprintf("##### Building Go toolchain using itself.\n")
+               for _, pattern := range buildorder {
+                       if pattern == "cmd/go" {
+                               break
+                       }
+                       dir := pattern
+                       if strings.Contains(pattern, "%s") {
+                               dir = fmt.Sprintf(pattern, gohostchar)
+                       }
+                       install(dir)
+                       if oldgochar != gohostchar && strings.Contains(pattern, "%s") {
+                               install(fmt.Sprintf(pattern, oldgochar))
+                       }
+               }
+               xprintf("\n")
+       }
+
+       xprintf("##### Building compilers and go_bootstrap for host, %s/%s.\n", gohostos, gohostarch)
        for _, pattern := range buildorder {
                dir := pattern
                if strings.Contains(pattern, "%s") {