From fd2ef1027f4bbee4d1941a947e9a402ec7272d76 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 27 Sep 2022 11:26:45 +0200 Subject: [PATCH 1/3] selfcheck.yml: added `callgrind` step --- .github/workflows/selfcheck.yml | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/selfcheck.yml b/.github/workflows/selfcheck.yml index c1b4a154807..3fc2abea2cd 100644 --- a/.github/workflows/selfcheck.yml +++ b/.github/workflows/selfcheck.yml @@ -28,6 +28,11 @@ jobs: with: key: ${{ github.workflow }}-${{ runner.os }} + - name: Install missing software + run: | + sudo apt-get update + sudo apt-get install valgrind + - name: Cache Qt ${{ env.QT_VERSION }} id: cache-qt uses: actions/cache@v1 # not v2! @@ -88,3 +93,36 @@ jobs: ./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.notest/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr env: DISABLE_VALUEFLOW: 1 + + - name: Fetch corpus + run: | + wget https://github.com/danmar/cppcheck/archive/refs/tags/2.8.tar.gz + tar xvf 2.8.tar.gz + + - name: CMake (corpus / no test) + run: | + cmake -S cppcheck-2.8 -B cmake.output.corpus -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=Off -DBUILD_GUI=ON -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On + + - name: Generate dependencies (corpus) + run: | + # make sure the precompiled headers exist + make -C cmake.output.notest lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.cxx + # make sure auto-generated GUI files exist + make -C cmake.output.corpus autogen + make -C cmake.output.corpus gui-build-deps + + # TODO: find a way to report unmatched suppressions without need to add information checks + - name: Self check (unusedFunction / corpus / no test / callgrind) + run: | + # TODO: fix -rp so the suppressions actually work + valgrind --tool=callgrind ./cppcheck -q --template=selfcheck --error-exitcode=0 --library=cppcheck-lib --library=qt -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.corpus/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr 2>callgrind.log || (cat callgrind.log && false) + cat callgrind.log + callgrind_annotate --auto=no > callgrind.annotated.log + head -50 callgrind.annotated.log + env: + DISABLE_VALUEFLOW: 1 + + - uses: actions/upload-artifact@v2 + with: + name: Callgrind Output + path: ./callgrind.* From ed760033b463897542e09b6273c4532898624df4 Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 27 Sep 2022 11:43:08 +0200 Subject: [PATCH 2/3] selfcheck.yml: use clang to build since it generates a faster binary for callgrind --- .github/workflows/selfcheck.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/selfcheck.yml b/.github/workflows/selfcheck.yml index 3fc2abea2cd..1116f9b624e 100644 --- a/.github/workflows/selfcheck.yml +++ b/.github/workflows/selfcheck.yml @@ -31,7 +31,7 @@ jobs: - name: Install missing software run: | sudo apt-get update - sudo apt-get install valgrind + sudo apt-get install clang-14 valgrind - name: Cache Qt ${{ env.QT_VERSION }} id: cache-qt @@ -51,7 +51,12 @@ jobs: - name: Self check (build) run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" - make -j$(nproc) -s CXXFLAGS="-O2 -w -DHAVE_BOOST" MATCHCOMPILER=yes + # valgrind cannot handle DWARF 5 yet so force version 4 + # work around performance regression with -inline-deferral + make -j$(nproc) -s CXXFLAGS="-O2 -w -DHAVE_BOOST -gdwarf-4 -mllvm -inline-deferral" MATCHCOMPILER=yes + env: + CC: clang-14 + CXX: clang++-14 - name: CMake run: | From 101e150f84fe23b054bea1725120fc4ca3cc9fbc Mon Sep 17 00:00:00 2001 From: firewave Date: Tue, 27 Sep 2022 12:07:33 +0200 Subject: [PATCH 3/3] selfcheck.yml: use non-quiet analysis with callgrind --- .github/workflows/selfcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/selfcheck.yml b/.github/workflows/selfcheck.yml index 1116f9b624e..e820a32d6a6 100644 --- a/.github/workflows/selfcheck.yml +++ b/.github/workflows/selfcheck.yml @@ -120,7 +120,7 @@ jobs: - name: Self check (unusedFunction / corpus / no test / callgrind) run: | # TODO: fix -rp so the suppressions actually work - valgrind --tool=callgrind ./cppcheck -q --template=selfcheck --error-exitcode=0 --library=cppcheck-lib --library=qt -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.corpus/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr 2>callgrind.log || (cat callgrind.log && false) + valgrind --tool=callgrind ./cppcheck --template=selfcheck --error-exitcode=0 --library=cppcheck-lib --library=qt -D__GNUC__ -DQT_VERSION=0x050000 -DQ_MOC_OUTPUT_REVISION=67 --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.corpus/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr 2>callgrind.log || (cat callgrind.log && false) cat callgrind.log callgrind_annotate --auto=no > callgrind.annotated.log head -50 callgrind.annotated.log