github.com/zxy12/go_duplicate_112_new@v0.0.0-20200807091221-747231827200/src/cmd/dist/build_var.go (about)

     1  package main
     2  
     3  import (
     4  	"os"
     5  	"sync"
     6  	"time"
     7  )
     8  
     9  // Initialization for any invocation.
    10  
    11  // The usual variables.
    12  var (
    13  	goarch           string
    14  	gobin            string
    15  	gohostarch       string
    16  	gohostos         string
    17  	goos             string
    18  	goarm            string
    19  	go386            string
    20  	gomips           string
    21  	gomips64         string
    22  	goroot           string
    23  	goroot_final     string
    24  	goextlinkenabled string
    25  	gogcflags        string // For running built compiler
    26  	goldflags        string
    27  	workdir          string
    28  	tooldir          string
    29  	oldgoos          string
    30  	oldgoarch        string
    31  	exe              string
    32  	defaultcc        map[string]string
    33  	defaultcxx       map[string]string
    34  	defaultcflags    string
    35  	defaultldflags   string
    36  	defaultpkgconfig string
    37  
    38  	rebuildall   bool
    39  	defaultclang bool
    40  
    41  	vflag int // verbosity
    42  )
    43  
    44  // The known architectures.
    45  var okgoarch = []string{
    46  	"386",
    47  	"amd64",
    48  	"amd64p32",
    49  	"arm",
    50  	"arm64",
    51  	"mips",
    52  	"mipsle",
    53  	"mips64",
    54  	"mips64le",
    55  	"ppc64",
    56  	"ppc64le",
    57  	"riscv64",
    58  	"s390x",
    59  	"sparc64",
    60  	"wasm",
    61  }
    62  
    63  // The known operating systems.
    64  var okgoos = []string{
    65  	"darwin",
    66  	"dragonfly",
    67  	"js",
    68  	"linux",
    69  	"android",
    70  	"solaris",
    71  	"freebsd",
    72  	"nacl",
    73  	"netbsd",
    74  	"openbsd",
    75  	"plan9",
    76  	"windows",
    77  	"aix",
    78  }
    79  
    80  // cleanlist is a list of packages with generated files and commands.
    81  var cleanlist = []string{
    82  	"runtime/internal/sys",
    83  	"cmd/cgo",
    84  	"cmd/go/internal/cfg",
    85  	"go/build",
    86  }
    87  
    88  var runtimegen = []string{
    89  	"zaexperiment.h",
    90  	"zversion.go",
    91  }
    92  
    93  // gentab records how to generate some trivial files.
    94  var gentab = []struct {
    95  	nameprefix string
    96  	gen        func(string, string)
    97  }{
    98  	{"zdefaultcc.go", mkzdefaultcc},
    99  	{"zosarch.go", mkzosarch},
   100  	{"zversion.go", mkzversion},
   101  	{"zcgo.go", mkzcgo},
   102  
   103  	// not generated anymore, but delete the file if we see it
   104  	{"enam.c", nil},
   105  	{"anames5.c", nil},
   106  	{"anames6.c", nil},
   107  	{"anames8.c", nil},
   108  	{"anames9.c", nil},
   109  }
   110  
   111  // Cannot use go/build directly because cmd/dist for a new release
   112  // builds against an old release's go/build, which may be out of sync.
   113  // To reduce duplication, we generate the list for go/build from this.
   114  //
   115  // We list all supported platforms in this list, so that this is the
   116  // single point of truth for supported platforms. This list is used
   117  // by 'go tool dist list'.
   118  var cgoEnabled = map[string]bool{
   119  	"aix/ppc64":       false,
   120  	"darwin/386":      true,
   121  	"darwin/amd64":    true,
   122  	"darwin/arm":      true,
   123  	"darwin/arm64":    true,
   124  	"dragonfly/amd64": true,
   125  	"freebsd/386":     true,
   126  	"freebsd/amd64":   true,
   127  	"freebsd/arm":     false,
   128  	"linux/386":       true,
   129  	"linux/amd64":     true,
   130  	"linux/arm":       true,
   131  	"linux/arm64":     true,
   132  	"linux/ppc64":     false,
   133  	"linux/ppc64le":   true,
   134  	"linux/mips":      true,
   135  	"linux/mipsle":    true,
   136  	"linux/mips64":    true,
   137  	"linux/mips64le":  true,
   138  	"linux/riscv64":   true,
   139  	"linux/s390x":     true,
   140  	"linux/sparc64":   true,
   141  	"android/386":     true,
   142  	"android/amd64":   true,
   143  	"android/arm":     true,
   144  	"android/arm64":   true,
   145  	"js/wasm":         false,
   146  	"nacl/386":        false,
   147  	"nacl/amd64p32":   false,
   148  	"nacl/arm":        false,
   149  	"netbsd/386":      true,
   150  	"netbsd/amd64":    true,
   151  	"netbsd/arm":      true,
   152  	"openbsd/386":     true,
   153  	"openbsd/amd64":   true,
   154  	"openbsd/arm":     true,
   155  	"plan9/386":       false,
   156  	"plan9/amd64":     false,
   157  	"plan9/arm":       false,
   158  	"solaris/amd64":   true,
   159  	"windows/386":     true,
   160  	"windows/amd64":   true,
   161  	"windows/arm":     false,
   162  }
   163  
   164  // List of platforms which are supported but not complete yet. These get
   165  // filtered out of cgoEnabled for 'dist list'. See golang.org/issue/28944
   166  var incomplete = map[string]bool{
   167  	"linux/riscv64": true,
   168  	"linux/sparc64": true,
   169  }
   170  
   171  var (
   172  	timeLogEnabled = os.Getenv("GOBUILDTIMELOGFILE") != ""
   173  	timeLogMu      sync.Mutex
   174  	timeLogFile    *os.File
   175  	timeLogStart   time.Time
   176  )
   177  
   178  var toolchain = []string{"cmd/asm", "cmd/cgo", "cmd/compile", "cmd/link"}
   179  
   180  // installed maps from a dir name (as given to install) to a chan
   181  // closed when the dir's package is installed.
   182  var installed = make(map[string]chan struct{})
   183  var installedMu sync.Mutex
   184  
   185  /*
   186   * Tool building
   187   */
   188  
   189  // deptab lists changes to the default dependencies for a given prefix.
   190  // deps ending in /* read the whole directory; deps beginning with -
   191  // exclude files with that prefix.
   192  // Note that this table applies only to the build of cmd/go,
   193  // after the main compiler bootstrap.
   194  var deptab = []struct {
   195  	prefix string   // prefix of target
   196  	dep    []string // dependency tweaks for targets with that prefix
   197  }{
   198  	{"cmd/go/internal/cfg", []string{
   199  		"zdefaultcc.go",
   200  		"zosarch.go",
   201  	}},
   202  	{"runtime/internal/sys", []string{
   203  		"zversion.go",
   204  	}},
   205  	{"go/build", []string{
   206  		"zcgo.go",
   207  	}},
   208  }
   209  
   210  // depsuffix records the allowed suffixes for source files.
   211  var depsuffix = []string{
   212  	".s",
   213  	".go",
   214  }
   215  
   216  // The old tools that no longer live in $GOBIN or $GOROOT/bin.
   217  var oldtool = []string{
   218  	"5a", "5c", "5g", "5l",
   219  	"6a", "6c", "6g", "6l",
   220  	"8a", "8c", "8g", "8l",
   221  	"9a", "9c", "9g", "9l",
   222  	"6cov",
   223  	"6nm",
   224  	"6prof",
   225  	"cgo",
   226  	"ebnflint",
   227  	"goapi",
   228  	"gofix",
   229  	"goinstall",
   230  	"gomake",
   231  	"gopack",
   232  	"gopprof",
   233  	"gotest",
   234  	"gotype",
   235  	"govet",
   236  	"goyacc",
   237  	"quietgcc",
   238  }
   239  
   240  // Unreleased directories (relative to $GOROOT) that should
   241  // not be in release branches.
   242  var unreleased = []string{
   243  	"src/cmd/newlink",
   244  	"src/cmd/objwriter",
   245  	"src/debug/goobj",
   246  	"src/old",
   247  }