Text file
src/cmp.bash
1 #!/usr/bin/env bash
2
3 # Copyright 2016 The Go Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style
5 # license that can be found in the LICENSE file.
6
7 # A simple script to compare differences between
8 # assembly listings for packages built with different
9 # compiler flags. It is useful to inspect the impact
10 # of a compiler change across all std lib packages.
11 #
12 # The script builds the std library (make.bash) once
13 # with FLAGS1 and once with FLAGS2 and compares the
14 # "go build <pkg>" assembly output for each package
15 # and lists the packages with differences.
16 #
17 # For packages with differences it leaves files named
18 # old.txt and new.txt.
19
20 FLAGS1="-newexport=0"
21 FLAGS2="-newexport=1"
22
23 echo
24 echo
25 echo "1a) clean build using $FLAGS1"
26 (export GO_GCFLAGS="$FLAGS1"; sh make.bash)
27
28 echo
29 echo
30 echo "1b) save go build output for all packages"
31 for pkg in `go list std`; do
32 echo $pkg
33 DIR=$GOROOT/src/$pkg
34 go build -gcflags "$FLAGS1 -S" -o /dev/null $pkg &> $DIR/old.txt
35 done
36
37 echo
38 echo
39 echo "2a) clean build using $FLAGS2"
40 (export GO_GCFLAGS="$FLAGS2"; sh make.bash)
41
42 echo
43 echo
44 echo "2b) save go build output for all packages"
45 for pkg in `go list std`; do
46 echo $pkg
47 DIR=$GOROOT/src/$pkg
48 go build -gcflags "$FLAGS2 -S" -o /dev/null $pkg &> $DIR/new.txt
49 done
50
51 echo
52 echo
53 echo "3) compare assembly files"
54 for pkg in `go list std`; do
55 DIR=$GOROOT/src/$pkg
56
57 if cmp $DIR/old.txt $DIR/new.txt &> /dev/null
58 then rm $DIR/old.txt $DIR/new.txt
59 else echo "==> $DIR"
60 fi
61 done
62
View as plain text