diff options
author | Caroline Tice <cmtice@google.com> | 2015-11-11 14:28:53 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-11-12 01:25:00 +0000 |
commit | b02b811163e5ca1be4506d53448ee71ba450508c (patch) | |
tree | 179068d578ec56c4d62666da3d8e99dbd7ed25e8 /compiler-test.sh | |
parent | 7f20acb9c9036015a665a14f27633c639e9b9d91 (diff) | |
download | toolchain-utils-b02b811163e5ca1be4506d53448ee71ba450508c.tar.gz |
Add a new shell script to figure out which compiler built image.
This adds a new script that checks to see which compiler (GCC or
clang) was used to build all the images in a ChromeOS image. It
outputs a count of how many packages it found that were built with
each compiler.
BUG=None
TEST=Tested in my chroot with both a locally-built GCC image and a
trybot-built clang image.
Change-Id: I26b5faea8616b5427c5bbe27a58ea3c9d4e36043
Reviewed-on: https://chrome-internal-review.googlesource.com/238685
Commit-Ready: Caroline Tice <cmtice@google.com>
Tested-by: Caroline Tice <cmtice@google.com>
Reviewed-by: Han Shen <shenhan@google.com>
Diffstat (limited to 'compiler-test.sh')
-rwxr-xr-x | compiler-test.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/compiler-test.sh b/compiler-test.sh new file mode 100755 index 00000000..8083e2d2 --- /dev/null +++ b/compiler-test.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# This script is supposed to verify which compiler (GCC or clang) was +# used to build the packages in a ChromeOS image. To use the script, +# just pass the path to the tree containing the *.debug files for a +# ChromeOS image. It then reads the debug info in each .debug file +# it can find, checking the AT_producer field to determine whether +# the package was built with clang or GCC. It counts the total +# number of .debug files found as well as how many are built with +# each compiler. It writes out these statistics when it is done. +# +# For a locally-built ChromeOS image, the debug directory is usually: +# ${chromeos_root}/chroot/build/${board}/usr/lib/debug (from outside +# chroot) +# or +# /build/${board}/usr/lib/debug (from inside chroot) +# +# For a buildbot-built image you can usually download the debug tree +# (using 'gsutil cp') from +# gs://chromeos-archive-image/<path-to-your-artifact-tree>/debug.tgz +# After downloading it somewhere, you will need to uncompress and +# untar it before running this script. +# + +DEBUG_TREE=$1 + +clang_count=0 +gcc_count=0 +file_count=0 + +# Verify the argument. + +if [[ $# != 1 ]]; then + echo "Usage error:" + echo "compiler-test.sh <debug_directory>" + exit 1 +fi + + +if [[ ! -d ${DEBUG_TREE} ]] ; then + echo "Cannot find ${DEBUG_TREE}." + exit 1 +fi + +cd ${DEBUG_TREE} +for f in `find . -name "*.debug" -type f` ; do + at_producer=`readelf --debug-dump=info $f | head -25 | grep AT_producer `; + if echo ${at_producer} | grep -q 'GNU C' ; then + ((gcc_count++)) + elif echo ${at_producer} | grep -q 'clang'; then + ((clang_count++)); + fi; + ((file_count++)) +done + +echo "GCC count: ${gcc_count}" +echo "Clang count: ${clang_count}" +echo "Total file count: ${file_count}" + + +exit 0 |