20090310-3-scanbuild:

Add support for clang's scan-build utility to abuild. scan-build wraps
the compiler and runs its own compiler on the same sources to do some
static analysis on them. It adds an option "-sb" or "--scan-build" that
creates a coreboot-builds/$target-scanbuild directory for every $target,
containing the output of scan-build, which is a HTML documentation on
its results.
Be aware, that scanbuild significantly increases build time: A board
that takes 6-7 seconds normally requires 60 seconds with that option
enabled on my test system.
The patch also moves the stack-protector option down a bit, so it
applies to crosscompiled targets, too (which overwrote the compiler
settings before)

Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>



git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3996 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Patrick Georgi 2009-03-11 15:43:02 +00:00 committed by Stefan Reinauer
parent 118c1005ed
commit d229677b61
1 changed files with 29 additions and 3 deletions

View File

@ -46,6 +46,9 @@ mode=text
# this is disabled per default but can be enabled with -s # this is disabled per default but can be enabled with -s
silent= silent=
# clang mode enabled by -sb option.
scanbuild=false
# stackprotect mode enabled by -ns option. # stackprotect mode enabled by -ns option.
stackprotect=false stackprotect=false
@ -334,9 +337,7 @@ function build_target
CROSS_COMPILE="$TARCH-elf-" CROSS_COMPILE="$TARCH-elf-"
found_crosscompiler=true found_crosscompiler=true
fi fi
if [ "$stackprotect" = "true" ]; then
CC="$CC -fno-stack-protector"
fi
HOSTCC='gcc' HOSTCC='gcc'
printf "Processing mainboard/$VENDOR/$MAINBOARD" printf "Processing mainboard/$VENDOR/$MAINBOARD"
@ -396,6 +397,25 @@ function build_target
fi fi
fi fi
if [ "$stackprotect" = "true" ]; then
CC="$CC -fno-stack-protector"
fi
if [ "$scanbuild" = "true" ]; then
ccwrap=`mktemp`
mkdir -p $TARGET/${VENDOR}_${MAINBOARD}
mkdir -p $TARGET/scan-build-results-tmp
mv $ccwrap $TARGET/${VENDOR}_${MAINBOARD}
ccwrap=$TARGET/${VENDOR}_${MAINBOARD}/`basename $ccwrap`
echo '#!/bin/sh' > $ccwrap
echo $CC' "$@"' >> $ccwrap
chmod +x $ccwrap
origMAKE=$MAKE
MAKE="scan-build --use-cc=$ccwrap -o $TARGET/scan-build-results-tmp -analyze-headers $MAKE GCC=$ccwrap"
CC="\$(CC)"
HOSTCC="CCC_CC=$HOSTCC \$(CC)"
fi
built_successfully $VENDOR $MAINBOARD && \ built_successfully $VENDOR $MAINBOARD && \
{ {
printf " ( mainboard/$VENDOR/$MAINBOARD previously ok )\n\n" printf " ( mainboard/$VENDOR/$MAINBOARD previously ok )\n\n"
@ -419,6 +439,10 @@ function build_target
compile_target $VENDOR $MAINBOARD && compile_target $VENDOR $MAINBOARD &&
xml " <status>ok</status>" || xml " <status>ok</status>" ||
xml "<status>broken</status>" xml "<status>broken</status>"
if [ "$scanbuild" = "true" ]; then
mv `dirname $TARGET/scan-build-results-tmp/*/index.html` $TARGET/${VENDOR}_${MAINBOARD}-scanbuild
MAKE=$origMAKE
fi
fi fi
xml "" xml ""
@ -484,6 +508,7 @@ function myhelp
printf " [-c|--cpus <numcpus>] build on <numcpus> at the same time\n" printf " [-c|--cpus <numcpus>] build on <numcpus> at the same time\n"
printf " [-s|--silent] omit compiler calls in logs\n" printf " [-s|--silent] omit compiler calls in logs\n"
printf " [-ns|--nostackprotect] use gcc -fno-stack-protector option\n" printf " [-ns|--nostackprotect] use gcc -fno-stack-protector option\n"
printf " [-sb|--scan-build] use clang's static analyzer\n"
printf " [-C|--config] configure-only mode\n" printf " [-C|--config] configure-only mode\n"
printf " [lbroot] absolute path to coreboot sources\n" printf " [lbroot] absolute path to coreboot sources\n"
printf " (defaults to $LBROOT)\n\n" printf " (defaults to $LBROOT)\n\n"
@ -542,6 +567,7 @@ while true ; do
-c|--cpus) shift; cpus="$1"; test "$cpus" == "max" && cpus=""; shift;; -c|--cpus) shift; cpus="$1"; test "$cpus" == "max" && cpus=""; shift;;
-s|--silent) shift; silent="-s";; -s|--silent) shift; silent="-s";;
-ns|--nostackprotect) shift; stackprotect=true;; -ns|--nostackprotect) shift; stackprotect=true;;
-sb|--scan-build) shift; scanbuild=true;;
-C|--config) shift; configureonly=1;; -C|--config) shift; configureonly=1;;
--) shift; break;; --) shift; break;;
-*) printf "Invalid option\n\n"; myhelp; exit 1;; -*) printf "Invalid option\n\n"; myhelp; exit 1;;