]> Cypherpunks.ru repositories - gostls13.git/blob - src/make.rc
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / src / make.rc
1 #!/bin/rc -e
2 # Copyright 2012 The Go Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style
4 # license that can be found in the LICENSE file.
5
6 # See golang.org/s/go15bootstrap for an overview of the build process.
7
8 # Environment variables that control make.rc:
9 #
10 # GOROOT_FINAL: The expected final Go root, baked into binaries.
11 # The default is the location of the Go tree during the build.
12 #
13 # GOHOSTARCH: The architecture for host tools (compilers and
14 # binaries).  Binaries of this type must be executable on the current
15 # system, so the only common reason to set this is to set
16 # GOHOSTARCH=386 on an amd64 machine.
17 #
18 # GOARCH: The target architecture for installed packages and tools.
19 #
20 # GOOS: The target operating system for installed packages and tools.
21 #
22 # GO_GCFLAGS: Additional go tool compile arguments to use when
23 # building the packages and commands.
24 #
25 # GO_LDFLAGS: Additional go tool link arguments to use when
26 # building the commands.
27 #
28 # CGO_ENABLED: Controls cgo usage during the build. Set it to 1
29 # to include all cgo related files, .c and .go file with "cgo"
30 # build directive, in the build. Set it to 0 to ignore them.
31
32 rfork e
33 if(! test -f run.rc){
34         echo 'make.rc must be run from $GOROOT/src' >[1=2]
35         exit wrongdir
36 }
37
38 # Clean old generated file that will cause problems in the build.
39 rm -f ./runtime/runtime_defs.go
40
41 # Determine the host compiler toolchain.
42 eval `{grep '^(CC|LD|O)=' /$objtype/mkfile}
43
44 vflag=()
45 if(~ $1 -v) {
46         vflag=(-v)
47         shift
48 }
49
50 fn nogoenv {
51         GO111MODULE=off GOENV=off GOOS=() GOARCH=() GOEXPERIMENT=() GOFLAGS=() $*
52 }
53
54 bootgo = 1.20.6
55 GOROOT = `{cd .. && pwd}
56 goroot_bootstrap_set = 'true'
57 if(! ~ $#GOROOT_BOOTSTRAP 1){
58         goroot_bootstrap_set = 'false'
59         GOROOT_BOOTSTRAP = $home/go1.4
60         for(d in sdk/go$bootgo go$bootgo)
61                 if(test -d $home/$d)
62                         GOROOT_BOOTSTRAP = $home/$d
63 }
64 for(p in $path){
65         if(! test -x $GOROOT_BOOTSTRAP/bin/go){
66                 if(go_exe = `{path=$p whatis go}){
67                         goroot = `{GOROOT=() nogoenv $go_exe env GOROOT}
68                         if(! ~ $goroot $GOROOT){
69                                 if(~ $goroot_bootstrap_set 'true'){
70                                         echo 'WARNING: '$GOROOT_BOOTSTRAP'/bin/go does not exist, found '$go_exe' from env' >[1=2]
71                                         echo 'WARNING: set '$goroot' as GOROOT_BOOTSTRAP' >[1=2]
72                                 }
73                                 GOROOT_BOOTSTRAP = $goroot
74                         }
75                 }
76         }
77 }
78 if(! test -x $GOROOT_BOOTSTRAP/bin/go){
79         echo 'ERROR: Cannot find '$GOROOT_BOOTSTRAP'/bin/go.' >[1=2]
80         echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go '$bootgo'.' >[1=2]
81         exit bootstrap
82 }
83 if(~ $GOROOT_BOOTSTRAP $GOROOT){
84         echo 'ERROR: $GOROOT_BOOTSTRAP must not be set to $GOROOT' >[1=2]
85         echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go '$bootgo'.' >[1=2]
86         exit bootstrap
87 }
88
89 # Get the exact bootstrap toolchain version to help with debugging.
90 # We clear GOOS and GOARCH to avoid an ominous but harmless warning if
91 # the bootstrap doesn't support them.
92 GOROOT_BOOTSTRAP_VERSION=`{nogoenv $GOROOT_BOOTSTRAP/bin/go version | sed 's/go version //'}
93 echo 'Building Go cmd/dist using '$GOROOT_BOOTSTRAP'. ('$"GOROOT_BOOTSTRAP_VERSION')'
94 if(~ $#vflag 1)
95         echo cmd/dist
96 GOROOT=$GOROOT_BOOTSTRAP nogoenv $GOROOT_BOOTSTRAP/bin/go build -o cmd/dist/dist ./cmd/dist
97
98 eval `{./cmd/dist/dist env -9}
99 if(~ $#vflag 1)
100         echo
101
102 if(~ $1 --dist-tool){
103         # Stop after building dist tool.
104         mkdir -p $GOTOOLDIR
105         if(! ~ $2 '')
106                 cp cmd/dist/dist $2
107         mv cmd/dist/dist $GOTOOLDIR/dist
108         exit
109 }
110
111 # Run dist bootstrap to complete make.bash.
112 # Bootstrap installs a proper cmd/dist, built with the new toolchain.
113 # Throw ours, built with the bootstrap toolchain, away after bootstrap.
114 ./cmd/dist/dist bootstrap -a $vflag $*
115 rm -f ./cmd/dist/dist
116
117 # DO NOT ADD ANY NEW CODE HERE.
118 # The bootstrap+rm above are the final step of make.rc.
119 # If something must be added, add it to cmd/dist's cmdbootstrap,
120 # to avoid needing three copies in three different shell languages
121 # (make.bash, make.bat, make.rc).