summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Georgi <patrick@georgi-clan.de>2009-03-11 18:13:43 +0000
committerPatrick Georgi <patrick@georgi-clan.de>2009-03-11 18:13:43 +0000
commit032a81eb9ca1316ee31f9ea8e0c058aeee0a509e (patch)
tree6871f620a3b3b8a922de5972e1f5d1b640367411
parent5a90884bd46b8b88bba14476c6ca37e968760848 (diff)
downloadcoreboot-032a81eb9ca1316ee31f9ea8e0c058aeee0a509e.tar.gz
coreboot-032a81eb9ca1316ee31f9ea8e0c058aeee0a509e.tar.bz2
coreboot-032a81eb9ca1316ee31f9ea8e0c058aeee0a509e.zip
Enable the use of scan-build on the coreboot-v3 tree, too
It requires a flag (CONFIG_SCAN_BUILD) to be set, and then $ scan-build make Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: svn://coreboot.org/repository/coreboot-v3@1146 f3766cd6-281f-0410-b1cd-43a5c92072e9
-rw-r--r--Kconfig8
-rw-r--r--Makefile10
-rwxr-xr-xutil/xcompile/xcompile25
3 files changed, 34 insertions, 9 deletions
diff --git a/Kconfig b/Kconfig
index 48cf13da871f..b160bb466acf 100644
--- a/Kconfig
+++ b/Kconfig
@@ -84,6 +84,14 @@ config WHOLE_PROGRAM_COMPILE
Say No.
If you are a Gentoo user, say NO!
+config SCAN_BUILD
+ bool "Use clang's scan-build utility for static analysis"
+ depends EXPERT && EXPERIMENTAL && !WHOLE_PROGRAM_COMPILE
+ default n
+ help
+ Change the compiler configuration so that a 'scan-build make'
+ has a chance to succeed.
+
endmenu
source mainboard/Kconfig
diff --git a/Makefile b/Makefile
index ae1c2f6f0363..aeaaa16bcb62 100644
--- a/Makefile
+++ b/Makefile
@@ -36,14 +36,14 @@ export src obj
# Do not print "Entering directory ...".
MAKEFLAGS += --no-print-directory
-CC := gcc
+CC ?= gcc
CFLAGS := -Os -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-Werror-implicit-function-declaration -Wstrict-aliasing \
-fno-common -ffreestanding -fno-builtin -fomit-frame-pointer \
-mpreferred-stack-boundary=2 -mregparm=3 -pipe
# FIXME: Does stack boundary or regparm break the code on real hardware?
-HOSTCC := gcc
+HOSTCC := $(CC)
HOSTCXX := g++
HOSTCFLAGS := -Wall -Wstrict-prototypes -g -fomit-frame-pointer \
-Wno-unused -Wno-sign-compare
@@ -61,9 +61,6 @@ endif
KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
export KERNELVERSION
-include $(shell $(src)/util/xcompile/xcompile > $(src)/.xcompile || \
- { echo "complete\\ toolchain" && rm -f $(src)/.xcompile && exit 1; }; echo $(src)/.xcompile)
-
ifeq ($(strip $(have_dotconfig)),)
all:
@@ -73,6 +70,9 @@ else
include $(src)/.config
+include $(shell scanbuild=$(CONFIG_SCAN_BUILD) $(src)/util/xcompile/xcompile > $(src)/.xcompile || \
+ { echo "complete\\ toolchain" && rm -f $(src)/.xcompile && exit 1; }; echo $(src)/.xcompile)
+
ifneq ($(CONFIG_LOCALVERSION),"")
COREBOOT_EXTRA_VERSION := -$(shell echo $(CONFIG_LOCALVERSION))
endif
diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile
index 318f7bfdcdc5..7ed14711a910 100755
--- a/util/xcompile/xcompile
+++ b/util/xcompile/xcompile
@@ -55,8 +55,20 @@ searchgnu()
case "$ARCH" in
"x86_64")
- echo "CC_x86 := gcc -m32"
- CC="gcc -m32"
+ if [ "$scanbuild" = "y" ]; then
+ ccwrap=`mktemp`
+ mkdir -p build
+ mv $ccwrap build
+ ccwrap=$PWD/build/`basename $ccwrap`
+ echo '#!/bin/bash' > $ccwrap
+ echo $CC' -m32 "$@"' >> $ccwrap
+ chmod +x $ccwrap
+ echo "CC_x86 := $ccwrap"
+ CC=$ccwrap
+ else
+ echo "CC_x86 := gcc -m32"
+ CC="gcc -m32"
+ fi
searchgnu ar >/dev/null && echo "AR_x86 := $(searchgnu ar)"
searchgnu as >/dev/null && echo "AS_x86 := $(searchgnu as) --32"
@@ -68,8 +80,13 @@ case "$ARCH" in
;;
"x86")
if [ "$OS" != "Darwin" ]; then
- echo "CC_x86 := gcc"
- CC="gcc"
+ if [ "$scanbuild" = "y" ]; then
+ echo 'CC_x86 := $(CC)'
+ if [ "$CC" = "" ]; then CC=gcc; fi
+ else
+ echo "CC_x86 := gcc"
+ CC="gcc"
+ fi
searchgnu ar >/dev/null && echo "AR_x86 := $(searchgnu ar)"
searchgnu as >/dev/null && echo "AS_x86 := $(searchgnu as)"