From: Andrew Cooper Date: Thu, 31 Oct 2024 16:14:40 +0000 (+0000) Subject: CI: Fix cppcheck parallel build more X-Git-Tag: 4.20.0-rc1~245 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e27436fba7f52ddc00c33e569ef91a07da433067;p=xen.git CI: Fix cppcheck parallel build more A recent cppcheck run was found to fail: https://gitlab.com/xen-project/people/andyhhp/xen/-/jobs/8237167472 with: "type mismatch! call is() before get()" && is() make[3]: *** [arch/x86/boot/Makefile:28: arch/x86/boot/reloc-trampoline.32.o] Error 1 This turns out to be a parallel build issue, combined with a recent change to x86. Notably, we now have a case where we build both: CC arch/x86/boot/reloc-trampoline.32.o CC arch/x86/boot/reloc-trampoline.o from the same original C file, and cppcheck uses the source C file as the key for generating it's intermediate files. Switch cppcheck to use the object file as the unique key instead. Fixes: 45bfff651173 ("xen/misra: xen-analysis.py: fix parallel analysis Cppcheck errors") Fixes: db8acf31f96b ("x86/boot: Reuse code to relocate trampoline") Suggested-by: Luca Fancellu Signed-off-by: Andrew Cooper Reviewed-by: Luca Fancellu Tested-by: Luca Fancellu --- diff --git a/xen/tools/cppcheck-cc.sh b/xen/tools/cppcheck-cc.sh index 16a965edb7..8a58c3aa86 100755 --- a/xen/tools/cppcheck-cc.sh +++ b/xen/tools/cppcheck-cc.sh @@ -26,6 +26,7 @@ EOF BUILD_DIR="" CC_FILE="" +OBJ_FILE="" COMPILER="" CPPCHECK_HTML="n" CPPCHECK_PLAT_PATH="" @@ -56,6 +57,7 @@ do then # This must be the path to the obj file, turn off flag and save path OBJTREE_PATH="$(dirname "${OPTION}")" + OBJ_FILE="$(basename "${OPTION}")" obj_arg_content="n" fi # Forward any argument to the compiler @@ -177,12 +179,12 @@ then done if [ "${IGNORE_PATH}" = "n" ] then - JDB_FILE="${OBJTREE_PATH}/$(basename "${CC_FILE}".json)" + JDB_FILE="${OBJTREE_PATH}/${OBJ_FILE}.json" # Prepare the Json Compilation Database for the file create_jcd "${COMPILER} ${FORWARD_FLAGS}" - out_file="${OBJTREE_PATH}/$(basename "${CC_FILE%.c}".cppcheck.txt)" + out_file="${OBJTREE_PATH}/${OBJ_FILE}.cppcheck.txt" # Select the right target platform, ARCH is generated from Xen Makefile case ${ARCH} in @@ -211,7 +213,7 @@ then fi # Generate build directory for the analysed file - cppcheck_build_dir="${BUILD_DIR}/${OBJTREE_PATH}" + cppcheck_build_dir="${BUILD_DIR}/${OBJTREE_PATH}/${OBJ_FILE}" mkdir -p "${cppcheck_build_dir}" # Shellcheck complains about missing quotes on CPPCHECK_TOOL_ARGS, but