]> 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 5fe30aced7ca2e5ba3ec400009b1946313e66437..b10be7dbd177c797102552436caf357278df8366 100755 (executable)
 #
 # GOOS: The target operating system for installed packages and tools.
 #
-# GO_GCFLAGS: Additional 5g/6g/8g arguments to use when
+# GO_GCFLAGS: Additional go tool compile arguments to use when
 # building the packages and commands.
 #
-# GO_LDFLAGS: Additional 5l/6l/8l arguments to use when
+# GO_LDFLAGS: Additional go tool link arguments to use when
 # building the commands.
 #
-# GO_CCFLAGS: Additional 5c/6c/8c arguments to use when
-# building.
-#
 # CGO_ENABLED: Controls cgo usage during the build. Set it to 1
 # to include all cgo related files, .c and .go file with "cgo"
 # build directive, in the build. Set it to 0 to ignore them.
@@ -38,30 +35,69 @@ if(! test -f run.rc){
        exit wrongdir
 }
 
-# Generate libc_plan9.h.
-../include/plan9/mklibc.rc > ../include/plan9/libc_plan9.h
-
 # Clean old generated file that will cause problems in the build.
 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.
@@ -72,34 +108,14 @@ if(~ $1 --dist-tool){
        exit
 }
 
-echo '# Building compilers and Go bootstrap tool for host,' $GOHOSTOS/$GOHOSTARCH^.
-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
-$GOTOOLDIR/go_bootstrap clean -i std
-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 -ccflags $"GO_CCFLAGS -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v $pflag std
-       echo
-}
-
-echo '# Building packages and commands for' $GOOS/$GOARCH^.
-$GOTOOLDIR/go_bootstrap install -ccflags $"GO_CCFLAGS -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v $pflag std
-echo
-
-rm -f $GOTOOLDIR/go_bootstrap
-
-if(! ~ $1 --no-banner)
-       $GOTOOLDIR/dist banner
-
-status=''
+# 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
+
+# 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).