diff --git a/src/all.bash b/src/all.bash index 00110d2da9b..d80a09d1162 100755 --- a/src/all.bash +++ b/src/all.bash @@ -8,7 +8,6 @@ if [ ! -f make.bash ]; then echo 'all.bash must be run from $GOROOT/src' 1>&2 exit 1 fi -. ./make.bash -bash run.bash --no-env --no-rebuild -installed # function defined by make.bash - +. ./make.bash --no-banner +bash run.bash --no-rebuild +../bin/tool/dist banner # print build info diff --git a/src/clean.bash b/src/clean.bash index 96fcaf795b3..958ff73696f 100755 --- a/src/clean.bash +++ b/src/clean.bash @@ -5,34 +5,11 @@ set -e -if [ ! -f env.bash ]; then - echo 'clean.bash must be run from $GOROOT/src' 1>&2 +if [ ! -x ../bin/tool/dist ]; then + echo 'cannot find ../bin/tool/dist; nothing to clean' >&2 exit 1 fi -. ./env.bash -if [ ! -f Make.inc ] ; then - GOROOT_FINAL=${GOROOT_FINAL:-$GOROOT} - sed 's!@@GOROOT@@!'"$GOROOT_FINAL"'!' Make.inc.in >Make.inc -fi -if [ "$1" != "--nopkg" ]; then - rm -rf "$GOROOT"/pkg/${GOOS}_$GOARCH -fi -rm -f "$GOROOT"/lib/*.a -for i in lib9 libbio libmach cmd -do - # Do not use gomake here. It may not be available. - $MAKE -C "$GOROOT/src/$i" clean -done - -if [ -x "$GOBIN/go" ]; then - go clean std || true # go command might not know about clean - - # TODO: Make clean work in directories outside $GOPATH - true || go clean \ - ../misc/cgo/gmp ../misc/cgo/stdio \ - ../misc/cgo/life ../misc/cgo/test \ - ../misc/dashboard/builder ../misc/goplay\ - ../doc/codelab/wiki\ - ../test/bench/shootout ../test/bench/garbage ../test/bench/go1 -fi +eval $(../bin/tool/dist env) +"$GOBIN/go" clean -i std +../bin/tool/dist clean diff --git a/src/env.bash b/src/env.bash deleted file mode 100644 index 3ae4f256de7..00000000000 --- a/src/env.bash +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env bash -# Copyright 2009 The Go Authors. All rights reserved. -# Use of this source code is governed by a BSD-style -# license that can be found in the LICENSE file. - -# If set to a Windows-style path convert to an MSYS-Unix -# one using the built-in shell commands. -if [[ "$GOROOT" == *:* ]]; then - GOROOT=$(cd "$GOROOT"; pwd) -fi - -if [[ "$GOBIN" == *:* ]]; then - GOBIN=$(cd "$GOBIN"; pwd) -fi - -export GOROOT=${GOROOT:-$(cd ..; pwd)} - -if ! test -f "$GOROOT"/include/u.h -then - echo '$GOROOT is not set correctly or not exported: '$GOROOT 1>&2 - exit 1 -fi - -# Double-check that we're in $GOROOT, for people with multiple Go trees. -# Various aspects of the build cd into $GOROOT-rooted paths, -# making it easy to jump to a different tree and get confused. -DIR1=$(cd ..; pwd) -DIR2=$(cd "$GOROOT"; pwd) -if [ "$DIR1" != "$DIR2" ]; then - echo 'Suspicious $GOROOT '"$GOROOT"': does not match current directory.' 1>&2 - exit 1 -fi - -export GOBIN=${GOBIN:-"$GOROOT/bin"} -if [ ! -d "$GOBIN" -a "$GOBIN" != "$GOROOT/bin" ]; then - echo '$GOBIN is not a directory or does not exist' 1>&2 - echo 'create it or set $GOBIN differently' 1>&2 - exit 1 -fi - -export OLDPATH=$PATH -export PATH="$GOBIN":$PATH - -MAKE=make -if ! make --version 2>/dev/null | grep 'GNU Make' >/dev/null; then - MAKE=gmake -fi - -PROGS=" - ar - awk - bash - bison - chmod - cp - cut - echo - egrep - gcc - grep - ls - $MAKE - mkdir - mv - pwd - rm - sed - sort - tee - touch - tr - true - uname - uniq -" - -for i in $PROGS; do - if ! which $i >/dev/null 2>&1; then - echo "Cannot find '$i' on search path." 1>&2 - echo "See http://golang.org/doc/install.html#ctools" 1>&2 - exit 1 - fi -done - -if bison --version 2>&1 | grep 'bison++' >/dev/null 2>&1; then - echo "Your system's 'bison' is bison++." - echo "Go needs the original bison instead." 1>&2 - echo "See http://golang.org/doc/install.html#ctools" 1>&2 - exit 1 -fi - -# Issue 2020: some users configure bash to default to -# set -o noclobber -# which makes >x fail if x already exists. Restore sanity. -set +o noclobber - -# Tried to use . <($MAKE ...) here, but it cannot set environment -# variables in the version of bash that ships with OS X. Amazing. -eval $($MAKE --no-print-directory -f Make.inc go-env | egrep 'GOARCH|GOOS|GOHOSTARCH|GOHOSTOS|GO_ENV|CGO_ENABLED') - -# Shell doesn't tell us whether make succeeded, -# so Make.inc generates a fake variable name. -if [ "$MAKE_GO_ENV_WORKED" != 1 ]; then - echo 'Did not find Go environment variables.' 1>&2 - exit 1 -fi -unset MAKE_GO_ENV_WORKED diff --git a/src/make.bash b/src/make.bash index 9b437707046..1c29568fdc4 100755 --- a/src/make.bash +++ b/src/make.bash @@ -4,12 +4,12 @@ # license that can be found in the LICENSE file. set -e -if [ ! -f env.bash ]; then +if [ ! -f run.bash ]; then echo 'make.bash must be run from $GOROOT/src' 1>&2 exit 1 fi -. ./env.bash +# Test for bad ld. if ld --version 2>&1 | grep 'gold.* 2\.20' >/dev/null; then echo 'ERROR: Your system has gold 2.20 installed.' echo 'This version is shipped by Ubuntu even though' @@ -21,48 +21,9 @@ if ld --version 2>&1 | grep 'gold.* 2\.20' >/dev/null; then exit 1 fi -# Create target directories -mkdir -p "$GOROOT/bin/tool" -mkdir -p "$GOROOT/pkg" - -# Remove old, pre-tool binaries. -rm -rf "$GOROOT"/bin/go-tool -rm -f "$GOROOT"/bin/[568][acgl] -rm -f "$GOROOT"/bin/{6cov,6nm,cgo,ebnflint,goapi,gofix,goinstall,gomake,gopack,gopprof,gotest,gotype,govet,goyacc,quietgcc} - -# If GOBIN is set and it has a Go compiler, it must also be cleaned. -if [ -n "GOBIN" ]; then - if [ -x "$GOBIN"/5g -o -x "$GOBIN"/6g -o -x "$GOBIN"/8g ]; then - rm -f "$GOBIN"/[568][acgl] - rm -f "$GOBIN"/{6cov,6nm,cgo,ebnflint,goapi,gofix,goinstall,gomake,gopack,gopprof,gotest,gotype,govet,goyacc,quietgcc} - fi -fi - -GOROOT_FINAL=${GOROOT_FINAL:-$GOROOT} - -MAKEFLAGS=${MAKEFLAGS:-"-j4"} -export MAKEFLAGS -unset CDPATH # in case user has it set - -rm -f "$GOBIN"/quietgcc -rm -f "$GOROOT/bin/tool/quietgcc" -CC=${CC:-gcc} -export CC -sed -e "s|@CC@|$CC|" < "$GOROOT"/src/quietgcc.bash > "$GOROOT"/bin/tool/quietgcc -chmod +x "$GOROOT"/bin/tool/quietgcc - -export GOMAKE="$GOROOT"/bin/tool/make -rm -f "$GOBIN"/gomake -rm -f "$GOMAKE" -( - echo '#!/bin/sh' - echo 'export GOROOT=${GOROOT:-'$GOROOT_FINAL'}' - echo 'exec '$MAKE' "$@"' -) >"$GOMAKE" -chmod +x "$GOMAKE" - -# on Fedora 16 the selinux filesystem is mounted at /sys/fs/selinux, -# so loop through the possible selinux mount points +# Test for bad SELinux. +# On Fedora 16 the selinux filesystem is mounted at /sys/fs/selinux, +# so loop through the possible selinux mount points. for se_mount in /selinux /sys/fs/selinux do if [ -d $se_mount -a -f $se_mount/booleans/allow_execstack -a -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then @@ -82,67 +43,23 @@ do fi done -bash "$GOROOT"/src/clean.bash - -# pkg builds runtime/cgo and the Go programs in cmd. -for i in lib9 libbio libmach cmd -do - echo; echo; echo %%%% making $i %%%%; echo - "$GOMAKE" -C $i install -done - -echo; echo; echo %%%% making runtime generated files %%%%; echo - -( - cd "$GOROOT"/src/pkg/runtime - ./autogen.sh - "$GOMAKE" install; "$GOMAKE" clean # copy runtime.h to pkg directory -) || exit 1 +# Finally! Run the build. +echo '# Building C bootstrap tool.' +mkdir -p ../bin/tool +gcc -O2 -Wall -Werror -o ../bin/tool/dist -Icmd/dist cmd/dist/*.c echo -echo '# Building go_bootstrap command from bootstrap script.' -if ! ./buildscript/${GOOS}_$GOARCH.sh; then - echo '# Bootstrap script failed.' - if [ ! -x "$GOBIN/go" ]; then - exit 1 - fi - echo '# Regenerating bootstrap script using pre-existing go binary.' - ./buildscript.sh - ./buildscript/${GOOS}_$GOARCH.sh + +echo '# Building compilers and Go bootstrap tool.' +../bin/tool/dist bootstrap -v # builds go_bootstrap +echo + +echo '# Building packages and commands.' +../bin/tool/go_bootstrap clean std +../bin/tool/go_bootstrap install -a -v std +rm -f ../bin/tool/go_bootstrap +echo + +if [ "$1" != "--no-banner" ]; then + ../bin/tool/dist banner fi - -# Clean what clean.bash couldn't. -go_bootstrap clean std - -echo '# Building Go code.' -go_bootstrap install -a -v std -rm -f "$GOBIN/go_bootstrap" - -# Print post-install messages. -# Implemented as a function so that all.bash can repeat the output -# after run.bash finishes running all the tests. -installed() { - eval $("$GOMAKE" --no-print-directory -f Make.inc go-env) - echo - echo --- - echo Installed Go for $GOOS/$GOARCH in "$GOROOT". - echo Installed commands in "$GOBIN". - case "$OLDPATH" in - "$GOBIN:"* | *":$GOBIN" | *":$GOBIN:"*) - ;; - *) - echo '***' "You need to add $GOBIN to your "'$PATH.' '***' - esac - if [ "$(uname)" = "Darwin" ]; then - echo - echo On OS X the debuggers must be installed setgrp procmod. - echo Read and run ./sudo.bash to install the debuggers. - fi - if [ "$GOROOT_FINAL" != "$GOROOT" ]; then - echo - echo The binaries expect "$GOROOT" to be copied or moved to "$GOROOT_FINAL". - fi -} - -(installed) # run in sub-shell to avoid polluting environment - diff --git a/src/run.bash b/src/run.bash index 08c1feb1871..8f282249fb8 100755 --- a/src/run.bash +++ b/src/run.bash @@ -4,54 +4,41 @@ # license that can be found in the LICENSE file. set -e -if [ "$1" = "--no-env" ]; then - # caller has already run env.bash - shift -else - . ./env.bash -fi -unset MAKEFLAGS # single-threaded make +eval $(../bin/tool/dist env -p) + unset CDPATH # in case user has it set # no core files, please ulimit -c 0 -# allow make.bash to avoid double-build of everything +# allow all.bash to avoid double-build of everything rebuild=true if [ "$1" = "--no-rebuild" ]; then - rebuild=false shift +else + echo '# Building packages and commands.' + time go install -a -v std + echo fi - + +echo '# Testing packages.' +time go test std -short -timeout=120s +echo + +echo '# runtime -cpu=1,2,4' +go test runtime -short -timeout=120s -cpu=1,2,4 +echo + +echo '# sync -cpu=10' +go test sync -short -timeout=120s -cpu=10 + xcd() { echo echo --- cd $1 builtin cd "$GOROOT"/src/$1 } -if $rebuild; then - echo - echo '# Package builds' - time go install -a -v std -fi - -echo -echo '# Package tests' -time go test std -short -timeout=120s - -echo -echo '# runtime -cpu=1,2,4' -go test runtime -short -timeout=120s -cpu=1,2,4 - -echo -echo '# sync -cpu=10' -go test sync -short -timeout=120s -cpu=10 - -echo -echo '# Build bootstrap scripts' -./buildscript.sh - BROKEN=true $BROKEN || diff --git a/src/sudo.bash b/src/sudo.bash index 3e4843dc28f..369505d2f64 100755 --- a/src/sudo.bash +++ b/src/sudo.bash @@ -23,7 +23,7 @@ do # Remove old binaries if present sudo rm -f /usr/local/bin/6$i # Install new binaries - sudo cp "$GOROOT"/src/cmd/$i/$i /usr/local/bin/go$i + sudo cp "$GOROOT"/bin/tool/$i /usr/local/bin/go$i sudo chgrp procmod /usr/local/bin/go$i sudo chmod g+s /usr/local/bin/go$i done diff --git a/test/run b/test/run index afc75c19d06..714520aee37 100755 --- a/test/run +++ b/test/run @@ -3,8 +3,8 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -eval $(../bin/tool/make --no-print-directory -f ../src/Make.inc go-env) - +eval $(../bin/tool/dist env) +export GOARCH GOOS GOROOT export E= case X"$GOARCH" in