build: make scan-build work again
This drops the scan-build related Kconfig options since it's now possible to simply run scan-build [-o outdir] make and get coreboot built with its report. There's also no inner make process anymore, and the way things work should be clearer now. Also adapt abuild to this new reality. Change-Id: I03e03334761ec83f718b3235ebf811834cd2e3e3 Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/5774 Tested-by: build bot (Jenkins) Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
This commit is contained in:
parent
e24a119cce
commit
fadbe5f657
30
Makefile
30
Makefile
|
@ -30,19 +30,9 @@
|
||||||
## SUCH DAMAGE.
|
## SUCH DAMAGE.
|
||||||
##
|
##
|
||||||
|
|
||||||
ifeq ($(INNER_SCANBUILD),y)
|
|
||||||
CC_real:=$(CC)
|
|
||||||
endif
|
|
||||||
|
|
||||||
$(if $(wildcard .xcompile),,$(eval $(shell bash util/xcompile/xcompile $(XGCCPATH) > .xcompile)))
|
$(if $(wildcard .xcompile),,$(eval $(shell bash util/xcompile/xcompile $(XGCCPATH) > .xcompile)))
|
||||||
include .xcompile
|
include .xcompile
|
||||||
|
|
||||||
ifeq ($(INNER_SCANBUILD),y)
|
|
||||||
CC:=$(CC_real)
|
|
||||||
HOSTCC:=$(CC_real) --hostcc
|
|
||||||
HOSTCXX:=$(CC_real) --hostcxx
|
|
||||||
endif
|
|
||||||
|
|
||||||
export top := $(CURDIR)
|
export top := $(CURDIR)
|
||||||
export src := src
|
export src := src
|
||||||
export srck := $(top)/util/kconfig
|
export srck := $(top)/util/kconfig
|
||||||
|
@ -119,12 +109,10 @@ include $(HAVE_DOTCONFIG)
|
||||||
|
|
||||||
include toolchain.inc
|
include toolchain.inc
|
||||||
|
|
||||||
ifneq ($(INNER_SCANBUILD),y)
|
|
||||||
ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
|
ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
|
||||||
CC:=clang -m32 -mno-mmx -mno-sse -no-integrated-as
|
CC:=clang -m32 -mno-mmx -mno-sse -no-integrated-as
|
||||||
HOSTCC:=clang
|
HOSTCC:=clang
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_CCACHE),y)
|
ifeq ($(CONFIG_CCACHE),y)
|
||||||
CCACHE:=$(word 1,$(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH)))))
|
CCACHE:=$(word 1,$(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH)))))
|
||||||
|
@ -143,25 +131,7 @@ strip_quotes = $(subst ",,$(subst \",,$(1)))
|
||||||
# The primary target needs to be here before we include the
|
# The primary target needs to be here before we include the
|
||||||
# other files
|
# other files
|
||||||
|
|
||||||
ifeq ($(INNER_SCANBUILD),y)
|
|
||||||
CONFIG_SCANBUILD_ENABLE:=
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_SCANBUILD_ENABLE),y)
|
|
||||||
ifneq ($(CONFIG_SCANBUILD_REPORT_LOCATION),)
|
|
||||||
CONFIG_SCANBUILD_REPORT_LOCATION:=-o $(CONFIG_SCANBUILD_REPORT_LOCATION)
|
|
||||||
endif
|
|
||||||
real-all:
|
|
||||||
echo '#!/bin/sh' > .ccwrap
|
|
||||||
echo 'CC="$(CC)"' >> .ccwrap
|
|
||||||
echo 'if [ "$$1" = "--hostcc" ]; then shift; CC="$(HOSTCC)"; fi' >> .ccwrap
|
|
||||||
echo 'if [ "$$1" = "--hostcxx" ]; then shift; CC="$(HOSTCXX)"; fi' >> .ccwrap
|
|
||||||
echo 'eval $$CC $$*' >> .ccwrap
|
|
||||||
chmod +x .ccwrap
|
|
||||||
scan-build $(CONFIG_SCANBUILD_REPORT_LOCATION) -analyze-headers --use-cc=$(top)/.ccwrap --use-c++=$(top)/.ccwrap $(MAKE) INNER_SCANBUILD=y
|
|
||||||
else
|
|
||||||
real-all: real-target
|
real-all: real-target
|
||||||
endif
|
|
||||||
|
|
||||||
# must come rather early
|
# must come rather early
|
||||||
.SECONDEXPANSION:
|
.SECONDEXPANSION:
|
||||||
|
|
23
src/Kconfig
23
src/Kconfig
|
@ -80,29 +80,6 @@ config ANY_TOOLCHAIN
|
||||||
we'll have to assume that they use their distro compiler by mistake.
|
we'll have to assume that they use their distro compiler by mistake.
|
||||||
Make sure that using patched compilers is a conscious decision.
|
Make sure that using patched compilers is a conscious decision.
|
||||||
|
|
||||||
config SCANBUILD_ENABLE
|
|
||||||
bool "Build with scan-build for static code analysis"
|
|
||||||
default n
|
|
||||||
help
|
|
||||||
Changes the build process to use scan-build (a utility for
|
|
||||||
running the clang static code analyzer from the command line).
|
|
||||||
|
|
||||||
Requires the scan-build utility in your system $PATH.
|
|
||||||
|
|
||||||
For details see http://clang-analyzer.llvm.org/scan-build.html.
|
|
||||||
|
|
||||||
config SCANBUILD_REPORT_LOCATION
|
|
||||||
string "Directory for the scan-build report(s)"
|
|
||||||
default ""
|
|
||||||
depends on SCANBUILD_ENABLE
|
|
||||||
help
|
|
||||||
Directory where the scan-build reports should be stored in. The
|
|
||||||
reports are stored in subdirectories of the form 'yyyy-mm-dd-*'
|
|
||||||
in the specified directory.
|
|
||||||
|
|
||||||
If this setting is left empty, the coreboot top-level directory
|
|
||||||
will be used to store the report subdirectories.
|
|
||||||
|
|
||||||
config CCACHE
|
config CCACHE
|
||||||
bool "Use ccache to speed up (re)compilation"
|
bool "Use ccache to speed up (re)compilation"
|
||||||
default n
|
default n
|
||||||
|
|
|
@ -19,6 +19,22 @@
|
||||||
|
|
||||||
ARCH_SUPPORTED := armv7 x86_32
|
ARCH_SUPPORTED := armv7 x86_32
|
||||||
|
|
||||||
|
|
||||||
|
# scan-build integration
|
||||||
|
ifneq ($(CCC_ANALYZER_OUTPUT_FORMAT),)
|
||||||
|
|
||||||
|
ifeq ($(CCC_ANALYZER_ANALYSIS),)
|
||||||
|
export CCC_ANALYZER_ANALYSIS := -analyzer-opt-analyze-headers
|
||||||
|
endif
|
||||||
|
|
||||||
|
$(foreach arch,$(ARCH_SUPPORTED), \
|
||||||
|
$(eval CC_$(arch):=CCC_CC=$(CC_$(arch)) $(CC) ))
|
||||||
|
|
||||||
|
HOSTCC:=CCC_CC="$(HOSTCC)" $(CC)
|
||||||
|
HOSTCXX:=CCC_CXX="$(HOSTCXX)" $(CXX)
|
||||||
|
ROMCC=CCC_CC="$(ROMCC_BIN)" $(CC)
|
||||||
|
endif
|
||||||
|
|
||||||
COREBOOT_STANDARD_STAGES := bootblock romstage ramstage
|
COREBOOT_STANDARD_STAGES := bootblock romstage ramstage
|
||||||
|
|
||||||
ARCHDIR-i386 := x86
|
ARCHDIR-i386 := x86
|
||||||
|
|
|
@ -238,7 +238,7 @@ function compile_target
|
||||||
CURR=$( pwd )
|
CURR=$( pwd )
|
||||||
#stime=`perl -e 'print time();' 2>/dev/null || date +%s`
|
#stime=`perl -e 'print time();' 2>/dev/null || date +%s`
|
||||||
build_dir=$TARGET/${VENDOR}_${MAINBOARD}
|
build_dir=$TARGET/${VENDOR}_${MAINBOARD}
|
||||||
eval $MAKE $silent DOTCONFIG=${build_dir}/config.build obj=${build_dir} objutil=$TARGET/sharedutils \
|
eval $BUILDPREFIX $MAKE $silent DOTCONFIG=${build_dir}/config.build obj=${build_dir} objutil=$TARGET/sharedutils \
|
||||||
&> ${build_dir}/make.log
|
&> ${build_dir}/make.log
|
||||||
ret=$?
|
ret=$?
|
||||||
cp .xcompile ${build_dir}/xcompile.build
|
cp .xcompile ${build_dir}/xcompile.build
|
||||||
|
@ -291,13 +291,16 @@ function build_target
|
||||||
stime=`perl -e 'print time();' 2>/dev/null || date +%s`
|
stime=`perl -e 'print time();' 2>/dev/null || date +%s`
|
||||||
create_buildenv $VENDOR $MAINBOARD $CONFIG
|
create_buildenv $VENDOR $MAINBOARD $CONFIG
|
||||||
if [ $? -eq 0 -a $configureonly -eq 0 ]; then
|
if [ $? -eq 0 -a $configureonly -eq 0 ]; then
|
||||||
|
BUILDPREFIX=
|
||||||
if [ "$scanbuild" = "true" ]; then
|
if [ "$scanbuild" = "true" ]; then
|
||||||
rm -rf $TARGET/scan-build-results-tmp
|
scanbuild_out=$TARGET/${VENDOR}_${MAINBOARD}-scanbuild
|
||||||
|
rm -rf ${scanbuild_out}
|
||||||
|
BUILDPREFIX="scan-build -o ${scanbuild_out}tmp"
|
||||||
fi
|
fi
|
||||||
compile_target $VENDOR $MAINBOARD
|
compile_target $VENDOR $MAINBOARD
|
||||||
if [ "$scanbuild" = "true" ]; then
|
if [ "$scanbuild" = "true" ]; then
|
||||||
rm -rf $TARGET/${VENDOR}_${MAINBOARD}-scanbuild
|
mv ${scanbuild_out}tmp/* ${scanbuild_out}
|
||||||
mv `dirname $TARGET/scan-build-results-tmp/*/index.html` $TARGET/${VENDOR}_${MAINBOARD}-scanbuild
|
rmdir ${scanbuild_out}tmp
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Not calculated here because we still print it in compile_target
|
# Not calculated here because we still print it in compile_target
|
||||||
|
@ -386,7 +389,6 @@ function myhelp
|
||||||
printf " [-T|--test] submit image(s) to automated test system\n"
|
printf " [-T|--test] submit image(s) to automated test system\n"
|
||||||
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 " [-sb|--scan-build] use clang's static analyzer\n"
|
|
||||||
printf " [-y|--ccache] use ccache\n"
|
printf " [-y|--ccache] use ccache\n"
|
||||||
printf " [-C|--config] configure-only mode\n"
|
printf " [-C|--config] configure-only mode\n"
|
||||||
printf " [-l|--loglevel <num>] set loglevel\n"
|
printf " [-l|--loglevel <num>] set loglevel\n"
|
||||||
|
@ -394,6 +396,7 @@ function myhelp
|
||||||
printf " [-P|--prefix <name>] file name prefix in CBFS\n"
|
printf " [-P|--prefix <name>] file name prefix in CBFS\n"
|
||||||
printf " [-B|--blobs] Allow using binary files\n"
|
printf " [-B|--blobs] Allow using binary files\n"
|
||||||
printf " [-L|--clang] Use clang\n"
|
printf " [-L|--clang] Use clang\n"
|
||||||
|
printf " [--scan-build] use clang's static analyzer\n"
|
||||||
printf " [cbroot] absolute path to coreboot sources\n"
|
printf " [cbroot] absolute path to coreboot sources\n"
|
||||||
printf " (defaults to $ROOT)\n\n"
|
printf " (defaults to $ROOT)\n\n"
|
||||||
}
|
}
|
||||||
|
@ -468,10 +471,9 @@ while true ; do
|
||||||
expr "$1" : '-\?[0-9]\+$' > /dev/null && test 0$1 -gt 1 && cpuconfig="on $1 cpus in parallel"
|
expr "$1" : '-\?[0-9]\+$' > /dev/null && test 0$1 -gt 1 && cpuconfig="on $1 cpus in parallel"
|
||||||
shift;;
|
shift;;
|
||||||
-s|--silent) shift; silent="-s";;
|
-s|--silent) shift; silent="-s";;
|
||||||
-sb|--scan-build) shift
|
--scan-build) shift
|
||||||
scanbuild=true
|
scanbuild=true
|
||||||
customizing="${customizing}, scan-build"
|
customizing="${customizing}, scan-build"
|
||||||
configoptions="${configoptions}CONFIG_SCANBUILD_ENABLE=y\nCONFIG_SCANBUILD_REPORT_LOCATION=\"$TARGET/scan-build-results-tmp\""
|
|
||||||
;;
|
;;
|
||||||
-y|--ccache) shift
|
-y|--ccache) shift
|
||||||
customizing="${customizing}, ccache"
|
customizing="${customizing}, ccache"
|
||||||
|
@ -546,7 +548,17 @@ build_all_targets()
|
||||||
echo "CONFIG_USE_BLOBS=y" > $TMPCFG
|
echo "CONFIG_USE_BLOBS=y" > $TMPCFG
|
||||||
fi
|
fi
|
||||||
$MAKE -j $cpus DOTCONFIG=$TMPCFG obj=$TARGET/temp objutil=$TARGET/sharedutils allnoconfig
|
$MAKE -j $cpus DOTCONFIG=$TMPCFG obj=$TARGET/temp objutil=$TARGET/sharedutils allnoconfig
|
||||||
$MAKE -j $cpus DOTCONFIG=$TMPCFG obj=$TARGET/temp objutil=$TARGET/sharedutils tools || exit 1
|
BUILDPREFIX=
|
||||||
|
if [ "$scanbuild" = "true" ]; then
|
||||||
|
scanbuild_out=$TARGET/sharedutils-scanbuild
|
||||||
|
rm -rf ${scanbuild_out}
|
||||||
|
BUILDPREFIX="scan-build -o ${scanbuild_out}tmp"
|
||||||
|
fi
|
||||||
|
$BUILDPREFIX $MAKE -j $cpus DOTCONFIG=$TMPCFG obj=$TARGET/temp objutil=$TARGET/sharedutils tools || exit 1
|
||||||
|
if [ "$scanbuild" = "true" ]; then
|
||||||
|
mv ${scanbuild_out}tmp/* ${scanbuild_out}
|
||||||
|
rmdir ${scanbuild_out}tmp
|
||||||
|
fi
|
||||||
rm -rf $TARGET/temp $TMPCFG
|
rm -rf $TARGET/temp $TMPCFG
|
||||||
for VENDOR in $( vendors ); do
|
for VENDOR in $( vendors ); do
|
||||||
for MAINBOARD in $( mainboards $VENDOR ); do
|
for MAINBOARD in $( mainboards $VENDOR ); do
|
||||||
|
|
|
@ -33,7 +33,7 @@ fi
|
||||||
|
|
||||||
# $1: object directory
|
# $1: object directory
|
||||||
run_printall() {
|
run_printall() {
|
||||||
$MAKE CONFIG_USE_BLOBS=n CONFIG_CCACHE=n CONFIG_SCANBUILD_ENABLE=n NOMKDIR=1 \
|
$MAKE CONFIG_USE_BLOBS=n CONFIG_CCACHE=n NOMKDIR=1 \
|
||||||
DOTCONFIG=$TMPCONFIG obj=$1 printall | \
|
DOTCONFIG=$TMPCONFIG obj=$1 printall | \
|
||||||
sed -e "s,^ *,," -e "s,^r.mstage-objs:=,," \
|
sed -e "s,^ *,," -e "s,^r.mstage-objs:=,," \
|
||||||
-e "s,mainboard/[^/]*/[^/]*/,.../,g" | \
|
-e "s,mainboard/[^/]*/[^/]*/,.../,g" | \
|
||||||
|
|
Loading…
Reference in New Issue