scan-build will set a number of environment variables, including CC and CCC_ANALYZER_HTML and the build command passed as its argument. When that build system uses CC as a compiler, scan-build will capture the arguments used and run clang-analyzer on all these files in addition to the normal compiler. This doesn't current work with barebox as barebox' Kbuild ignores the CC variable in the environment. Fix this by collecting into ENVCC the CC environment variable and using it to override CC whenever it is set in addition to CCC_ANALYZER_HTML. Example usage: export LLVM=-19 scan-build${LLVM} --use-cc=clang${LLVM} make Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index f3e5b44d5566..9ef07ba34457 100644 --- a/Makefile +++ b/Makefile @@ -410,6 +410,8 @@ KBUILD_HOSTCXXFLAGS := -Wall -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) +ENVCC := $(CC) + # Make variables (CC, etc...) CPP = $(CC) -E ifneq ($(LLVM),) @@ -574,6 +576,13 @@ ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) include $(srctree)/scripts/Makefile.clang endif +# allow scan-build to override the used compiler +ifneq ($(CCC_ANALYZER_HTML),) +ifneq ($(ENVCC),) +CC = $(ENVCC) +endif +endif + ifdef config-build # =========================================================================== # *config targets only - make sure prerequisites are updated, and descend -- 2.39.5