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# /build/${board}/usr/lib/debug (from inside chroot) 14# 15# For a buildbot-built image you can usually download the debug tree 16# (using 'gsutil cp') from 17# gs://chromeos-archive-image/<path-to-your-artifact-tree>/debug.tgz 18# After downloading it somewhere, you will need to uncompress and 19# untar it before running this script. 20# 21 22DEBUG_TREE=$1 23 24clang_count=0 25gcc_count=0 26file_count=0 27 28# Verify the argument. 29 30if [[ $# != 1 ]]; then 31 echo "Usage error:" 32 echo "compiler-test.sh <debug_directory>" 33 exit 1 34fi 35 36 37if [[ ! -d ${DEBUG_TREE} ]] ; then 38 echo "Cannot find ${DEBUG_TREE}." 39 exit 1 40fi 41 42cd ${DEBUG_TREE} 43for f in `find . -name "*.debug" -type f` ; do 44 at_producer=`llvm-dwarfdump $f | head -25 | grep AT_producer `; 45 if echo ${at_producer} | grep -q 'GNU C' ; then 46 ((gcc_count++)) 47 elif echo ${at_producer} | grep -q 'clang'; then 48 ((clang_count++)); 49 fi; 50 ((file_count++)) 51done 52 53echo "GCC count: ${gcc_count}" 54echo "Clang count: ${clang_count}" 55echo "Total file count: ${file_count}" 56 57 58exit 0 59