1#!/bin/bash 2 3# This script is supposed to verify which compiler (GCC or clang) was 4# used to build the packages in a ChromeOS image. To use the script, 5# just pass the path to the tree containing the *.debug files for a 6# ChromeOS image. It then reads the debug info in each .debug file 7# it can find, checking the AT_producer field to determine whether 8# the package was built with clang or GCC. It counts the total 9# number of .debug files found as well as how many are built with 10# each compiler. It writes out these statistics when it is done. 11# 12# For a locally-built ChromeOS image, the debug directory is usually: 13# ${chromeos_root}/chroot/build/${board}/usr/lib/debug (from outside 14# chroot) 15# or 16# /build/${board}/usr/lib/debug (from inside chroot) 17# 18# For a buildbot-built image you can usually download the debug tree 19# (using 'gsutil cp') from 20# gs://chromeos-archive-image/<path-to-your-artifact-tree>/debug.tgz 21# After downloading it somewhere, you will need to uncompress and 22# untar it before running this script. 23# 24 25DEBUG_TREE=$1 26 27clang_count=0 28gcc_count=0 29file_count=0 30 31# Verify the argument. 32 33if [[ $# != 1 ]]; then 34 echo "Usage error:" 35 echo "compiler-test.sh <debug_directory>" 36 exit 1 37fi 38 39 40if [[ ! -d ${DEBUG_TREE} ]] ; then 41 echo "Cannot find ${DEBUG_TREE}." 42 exit 1 43fi 44 45cd ${DEBUG_TREE} 46for f in `find . -name "*.debug" -type f` ; do 47 at_producer=`readelf --debug-dump=info $f | head -25 | grep AT_producer `; 48 if echo ${at_producer} | grep -q 'GNU C' ; then 49 ((gcc_count++)) 50 elif echo ${at_producer} | grep -q 'clang'; then 51 ((clang_count++)); 52 fi; 53 ((file_count++)) 54done 55 56echo "GCC count: ${gcc_count}" 57echo "Clang count: ${clang_count}" 58echo "Total file count: ${file_count}" 59 60 61exit 0 62