summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-03-08 12:42:21 -0500
committerJan Setje-Eilers <73182357+jsetje@users.noreply.github.com>2021-03-09 13:52:53 -0800
commit7d5df1cebdbdc3ed11cde165a752cf358878aa8a (patch)
tree02433cd8c51f40885f059c8137f4154dbd426037
parent1954ef164a55cbc4369f513cca3fb43f3550d81a (diff)
downloadefi-boot-shim-7d5df1cebdbdc3ed11cde165a752cf358878aa8a.tar.gz
efi-boot-shim-7d5df1cebdbdc3ed11cde165a752cf358878aa8a.zip
static analysis: make our build targets work better
This improves our static analysis targets by making them work better with our make variables, and inhibits the use of ccache while building those. Signed-off-by: Peter Jones <pjones@redhat.com>
-rw-r--r--Cryptlib/Makefile3
-rw-r--r--Cryptlib/OpenSSL/Makefile3
-rw-r--r--Make.defaults9
-rw-r--r--include/coverity.mk37
-rw-r--r--include/fanalyzer.mk36
-rw-r--r--include/scan-build.mk35
6 files changed, 97 insertions, 26 deletions
diff --git a/Cryptlib/Makefile b/Cryptlib/Makefile
index 5bae10c9..bc5681c5 100644
--- a/Cryptlib/Makefile
+++ b/Cryptlib/Makefile
@@ -1,3 +1,6 @@
+ifneq ($(CCACHE_DISABLE),)
+export CCACHE_DISABLE
+endif
INCLUDES = -I$(TOPDIR) -iquote $(TOPDIR) -I$(TOPDIR)/Include \
$(EFI_INCLUDES) -I$(shell $(CC) -print-file-name=include)
diff --git a/Cryptlib/OpenSSL/Makefile b/Cryptlib/OpenSSL/Makefile
index 6a58dbaa..6ff58e47 100644
--- a/Cryptlib/OpenSSL/Makefile
+++ b/Cryptlib/OpenSSL/Makefile
@@ -1,3 +1,6 @@
+ifneq ($(CCACHE_DISABLE),)
+export CCACHE_DISABLE
+endif
DEFINES = -DL_ENDIAN \
-D_CRT_SECURE_NO_DEPRECATE \
diff --git a/Make.defaults b/Make.defaults
index 5f30e292..7f1b8015 100644
--- a/Make.defaults
+++ b/Make.defaults
@@ -28,6 +28,15 @@ DASHJ ?= -j$(shell echo $$(($$(grep -c "^model name" /proc/cpuinfo) + 1)))
ARCH ?= $(shell $(CC) -dumpmachine | cut -f1 -d- | sed s,i[3456789]86,ia32,)
OBJCOPY_GTE224 = $(shell expr `$(OBJCOPY) --version |grep ^"GNU objcopy" | sed 's/^.*\((.*)\|version\) //g' | cut -f1-2 -d.` \>= 2.24)
OPTIMIZATIONS ?= -Os
+FA_OPTIMIZATIONS ?= -O2
+ifneq ($(FANALYZER),)
+override OPTIMIZATIONS := $(FA_OPTIMIZATIONS)
+override CCACHE_DISABLE := true
+endif
+export OPTIMIZATIONS
+ifneq ($(CCACHE_DISABLE),)
+export CCACHE_DISABLE
+endif
SUBDIRS = $(TOPDIR)/Cryptlib $(TOPDIR)/lib
diff --git a/include/coverity.mk b/include/coverity.mk
index a897aa0a..e1e5c874 100644
--- a/include/coverity.mk
+++ b/include/coverity.mk
@@ -3,12 +3,18 @@ COV_TOKEN=$(call get-config,coverity.token)
COV_URL=$(call get-config,coverity.url)
COV_FILE=$(NAME)-coverity-$(VERSION)-$(COMMIT_ID).tar.bz2
-cov-int : clean-shim-objs
- make $(DASHJ) Cryptlib/OpenSSL/libopenssl.a Cryptlib/libcryptlib.a
- cov-build --dir cov-int make $(DASHJ) all
+include $(TOPDIR)/Make.rules
-cov-int-all : clean
- cov-build --dir cov-int make $(DASHJ) all
+define prop
+$(if $(findstring undefined,$(origin $(1))),,$(1)="$($1)")
+endef
+
+override CCACHE_DISABLE := 1
+export CCACHE_DISABLE
+
+PROPOGATE_MAKE_FLAGS = ARCH ARCH_SUFFIX COLOR COMPILER CROSS_COMPILE
+
+MAKEARGS = $(foreach x,$(PROPOGATE_MAKE_FLAGS),$(call prop,$(x)))
cov-clean :
@rm -vf $(NAME)-coverity-*.tar.*
@@ -19,7 +25,7 @@ cov-file : | $(COV_FILE)
$(COV_FILE) : | cov-int
tar caf $@ cov-int
-cov-upload :
+cov-upload : | cov-file
@if [ -n "$(COV_URL)" ] && \
[ -n "$(COV_TOKEN)" ] && \
[ -n "$(COV_EMAIL)" ] ; \
@@ -30,11 +36,26 @@ cov-upload :
echo Coverity output is in $(COV_FILE) ; \
fi
+cov-build-unchecked-cryptlib : | clean-cryptlib-objs
+cov-build-unchecked-cryptlib : Cryptlib/libcryptlib.a
+
+cov-build-unchecked-openssl : | clean-openssl-objs
+cov-build-unchecked-openssl : Cryptlib/OpenSSL/libopenssl.a
+
+cov-build-all : | clean clean-shim-objs clean-cryptlib-objs clean-openssl-objs
+ +cov-build --dir cov-int $(MAKE) $(MAKEARGS) CCACHE_DISABLE=1 all
+
+coverity-no-openssl : | cov-test
+coverity-no-openssl : clean-shim-objs clean-cryptlib-objs cov-build-unchecked-openssl cov-build-all cov-file cov-upload
+
+coverity-no-cryptlib : | cov-test
+coverity-no-cryptlib : clean-shim-objs cov-build-unchecked-openssl cov-build-unchecked-cryptlib cov-build-all cov-file cov-upload
+
coverity : | cov-test
-coverity : cov-int cov-file cov-upload
+coverity : coverity-no-openssl cov-file cov-upload
coverity-all : | cov-test
-coverity-all : cov-int-all cov-file cov-upload
+coverity-all : clean cov-build-all cov-file cov-upload
clean : | cov-clean
diff --git a/include/fanalyzer.mk b/include/fanalyzer.mk
index 1018d1da..7e31a082 100644
--- a/include/fanalyzer.mk
+++ b/include/fanalyzer.mk
@@ -3,25 +3,37 @@ GCC_BINARY ?= $(shell x=$$(which --skip-alias --skip-functions gcc 2>/dev/null)
fanalyzer-test : ; $(if $(findstring /,$(GCC_BINARY)),,$(error gcc not found))
define prop
-$(if $(filter-out undefined,$(origin $(1))),$(1)=$($1),)
+$(if $(findstring undefined,$(origin $(1))),,$(eval export $(1)))
endef
-MAKEARGS := \
- $(call prop,ARCH) \
- $(call prop,COLOR) \
- $(call prop,CROSS_COMPILE)
+override CCACHE_DISABLE := 1
+export CCACHE_DISABLE
+override COMPILER := gcc
+export COMPILER
+
+PROPOGATE_MAKE_FLAGS = ARCH ARCH_SUFFIX COLOR COMPILER CROSS_COMPILE DASHJ
+
+MAKEARGS = $(foreach x,$(PROPOGATE_MAKE_FLAGS),$(call prop,$(x)))
fanalyzer : | fanalyzer-test
-fanalyzer : clean-shim-objs fanalyzer-build
+fanalyzer : fanalyzer-no-openssl
+
+fanalyzer-build-unchecked-cryptlib : Cryptlib/libcryptlib.a
+
+fanalyzer-build-unchecked-openssl : Cryptlib/OpenSSL/libopenssl.a
-fanalyzer-build :
- make CC=gcc $(MAKEARGS) $(DASHJ) Cryptlib/OpenSSL/libopenssl.a Cryptlib/libcryptlib.a
- make CC=gcc $(MAKEARGS) FANALYZER=true all
+fanalyzer-build-all : CCACHE_DISABLE=1
+fanalyzer-build-all : FEATUREFLAGS+=-fanalyzer
+fanalyzer-build-all : WERRFLAGS=-Werror=analyzer-null-dereference
+fanalyzer-build-all : all
+
+fanalyzer-no-openssl : | fanalyzer-test
+fanalyzer-no-openssl : clean-shim-objs clean-cryptlib-objs fanalyzer-build-unchecked-openssl fanalyzer-build-all
+
+fanalyzer-no-cryptlib : | fanalyzer-test
+fanalyzer-no-cryptlib : clean-shim-objs fanalyzer-build-unchecked-openssl fanalyzer-build-unchecked-cryptlib fanalyzer-build-all
fanalyzer-all : | fanalyzer-test
fanalyzer-all : clean fanalyzer-build-all
-fanalyzer-build-all :
- make CC=gcc $(MAKEARGS) FANALYZER=true all
-
.PHONY : fanalyzer fanalyzer-build fanalyzer-all fanalyzer-build-all fanalyzer-clean
diff --git a/include/scan-build.mk b/include/scan-build.mk
index 7697cb89..2cb33e79 100644
--- a/include/scan-build.mk
+++ b/include/scan-build.mk
@@ -2,16 +2,39 @@ SCAN_BUILD ?= $(shell x=$$(which --skip-alias --skip-functions scan-build 2>/dev
scan-test : ; $(if $(findstring /,$(SCAN_BUILD)),,$(error scan-build not found))
+define prop
+$(if $(findstring undefined,$(origin $(1))),,$(1)="$($1)")
+endef
+
+override CCACHE_DISABLE := 1
+export CCACHE_DISABLE
+override COMPILER = clang
+
+PROPOGATE_MAKE_FLAGS = ARCH ARCH_SUFFIX COLOR COMPILER CROSS_COMPILE DASHJ
+
+MAKEARGS = $(foreach x,$(PROPOGATE_MAKE_FLAGS),$(call prop,$(x)))
+
scan-clean :
@if [[ -d scan-results ]]; then rm -rf scan-results && echo "removed 'scan-results'"; fi
-scan-build : | scan-test
-scan-build : clean-shim-objs
- make $(DASHJ) Cryptlib/OpenSSL/libopenssl.a Cryptlib/libcryptlib.a
- scan-build -o scan-results make $(DASHJ) CC=clang all
+scan : | scan-test
+scan : clean-shim-objs clean-cryptlib-objs scan-build-no-openssl
+
+scan-build-unchecked-cryptlib : Cryptlib/libcryptlib.a
+
+scan-build-unchecked-openssl : Cryptlib/OpenSSL/libopenssl.a
scan-build-all : | scan-test
-scan-build-all : clean
- scan-build -o scan-results make $(DASHJ) CC=clang all
+scan-build-all :
+ +scan-build -o scan-results make $(MAKEARGS) $(DASHJ) CCACHE_DISABLE=1 all
+
+scan-build-no-openssl : | scan-test
+scan-build-no-openssl : clean-shim-objs clean-cryptlib-objs scan-build-unchecked-openssl scan-build-all
+
+scan-build-no-cryptlib : | scan-test
+scan-build-no-cryptlib : clean-shim-objs scan-build-unchecked-cryptlib scan-build-unchecked-openssl scan-build-all
+
+scan-all : | scan-test
+scan-all : clean scan-build-all
.PHONY : scan-build scan-clean