]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/make.rc
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / src / make.rc
index 60162045ede4b077275631489a0eaa0ffe1434d9..b10be7dbd177c797102552436caf357278df8366 100755 (executable)
@@ -41,21 +41,63 @@ rm -f ./runtime/runtime_defs.go
 # Determine the host compiler toolchain.
 eval `{grep '^(CC|LD|O)=' /$objtype/mkfile}
 
-echo '##### Building Go bootstrap tool.'
-echo cmd/dist
+vflag=()
+if(~ $1 -v) {
+       vflag=(-v)
+       shift
+}
+
+fn nogoenv {
+       GO111MODULE=off GOENV=off GOOS=() GOARCH=() GOEXPERIMENT=() GOFLAGS=() $*
+}
+
+bootgo = 1.20.6
 GOROOT = `{cd .. && pwd}
-if(! ~ $#GOROOT_BOOTSTRAP 1)
+goroot_bootstrap_set = 'true'
+if(! ~ $#GOROOT_BOOTSTRAP 1){
+       goroot_bootstrap_set = 'false'
        GOROOT_BOOTSTRAP = $home/go1.4
+       for(d in sdk/go$bootgo go$bootgo)
+               if(test -d $home/$d)
+                       GOROOT_BOOTSTRAP = $home/$d
+}
+for(p in $path){
+       if(! test -x $GOROOT_BOOTSTRAP/bin/go){
+               if(go_exe = `{path=$p whatis go}){
+                       goroot = `{GOROOT=() nogoenv $go_exe env GOROOT}
+                       if(! ~ $goroot $GOROOT){
+                               if(~ $goroot_bootstrap_set 'true'){
+                                       echo 'WARNING: '$GOROOT_BOOTSTRAP'/bin/go does not exist, found '$go_exe' from env' >[1=2]
+                                       echo 'WARNING: set '$goroot' as GOROOT_BOOTSTRAP' >[1=2]
+                               }
+                               GOROOT_BOOTSTRAP = $goroot
+                       }
+               }
+       }
+}
 if(! test -x $GOROOT_BOOTSTRAP/bin/go){
        echo 'ERROR: Cannot find '$GOROOT_BOOTSTRAP'/bin/go.' >[1=2]
-       echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.' >[1=2]
+       echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go '$bootgo'.' >[1=2]
+       exit bootstrap
+}
+if(~ $GOROOT_BOOTSTRAP $GOROOT){
+       echo 'ERROR: $GOROOT_BOOTSTRAP must not be set to $GOROOT' >[1=2]
+       echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go '$bootgo'.' >[1=2]
        exit bootstrap
 }
-rm -f cmd/dist/dist
-GOROOT=$GOROOT_BOOTSTRAP GOOS='' GOARCH='' $GOROOT_BOOTSTRAP/bin/go build -o cmd/dist/dist ./cmd/dist
+
+# Get the exact bootstrap toolchain version to help with debugging.
+# We clear GOOS and GOARCH to avoid an ominous but harmless warning if
+# the bootstrap doesn't support them.
+GOROOT_BOOTSTRAP_VERSION=`{nogoenv $GOROOT_BOOTSTRAP/bin/go version | sed 's/go version //'}
+echo 'Building Go cmd/dist using '$GOROOT_BOOTSTRAP'. ('$"GOROOT_BOOTSTRAP_VERSION')'
+if(~ $#vflag 1)
+       echo cmd/dist
+GOROOT=$GOROOT_BOOTSTRAP nogoenv $GOROOT_BOOTSTRAP/bin/go build -o cmd/dist/dist ./cmd/dist
 
 eval `{./cmd/dist/dist env -9}
-echo
+if(~ $#vflag 1)
+       echo
 
 if(~ $1 --dist-tool){
        # Stop after building dist tool.
@@ -66,32 +108,14 @@ if(~ $1 --dist-tool){
        exit
 }
 
-buildall = -a
-if(~ $1 --no-clean)
-       buildall = ()
-./cmd/dist/dist bootstrap $buildall -v # builds go_bootstrap
-# Delay move of dist tool to now, because bootstrap may clear tool directory.
-mv cmd/dist/dist $GOTOOLDIR/dist
-echo
-
-# Run only one process at a time on 9vx.
-if(~ $sysname vx32)
-       pflag = (-p 1)
-
-if(! ~ $GOHOSTARCH $GOARCH || ! ~ $GOHOSTOS $GOOS){
-       echo '##### Building packages and commands for host,' $GOHOSTOS/$GOHOSTARCH^.
-       GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \
-               $GOTOOLDIR/go_bootstrap install -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v $pflag std cmd
-       echo
-}
-
-echo '##### Building packages and commands for' $GOOS/$GOARCH^.
-$GOTOOLDIR/go_bootstrap install -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v $pflag std cmd
-echo
-
-rm -f $GOTOOLDIR/go_bootstrap
-
-if(! ~ $1 --no-banner)
-       $GOTOOLDIR/dist banner
+# Run dist bootstrap to complete make.bash.
+# Bootstrap installs a proper cmd/dist, built with the new toolchain.
+# Throw ours, built with the bootstrap toolchain, away after bootstrap.
+./cmd/dist/dist bootstrap -a $vflag $*
+rm -f ./cmd/dist/dist
 
-status=''
+# DO NOT ADD ANY NEW CODE HERE.
+# The bootstrap+rm above are the final step of make.rc.
+# If something must be added, add it to cmd/dist's cmdbootstrap,
+# to avoid needing three copies in three different shell languages
+# (make.bash, make.bat, make.rc).