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