Text file src/cmp.bash

Documentation: Index

     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# It leaves and old.txt and new.txt file in the package
    18# directories for the packages with differences.
    19
    20FLAGS1="-newexport=0"
    21FLAGS2="-newexport=1"
    22
    23echo
    24echo
    25echo "1a) clean build using $FLAGS1"
    26(export GO_GCFLAGS="$FLAGS1"; sh make.bash)
    27
    28echo
    29echo
    30echo "1b) save go build output for all packages"
    31for 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
    35done
    36
    37echo
    38echo
    39echo "2a) clean build using $FLAGS2"
    40(export GO_GCFLAGS="$FLAGS2"; sh make.bash)
    41
    42echo
    43echo
    44echo "2b) save go build output for all packages"
    45for 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
    49done
    50
    51echo
    52echo
    53echo "3) compare assembly files"
    54for 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
    61done

View as plain text