From b813f01f2465819662243ced602d02223098427f Mon Sep 17 00:00:00 2001 From: Mark Abraham Date: Sun, 12 Apr 2020 08:55:43 +0000 Subject: [PATCH] Update to clang-tidy-9 Code fixes have already taken place, it remains to update the CI configuration to use the existing llvm-9 Docker image and adjust the documentation to match. --- admin/clang-tidy.sh | 6 +++--- admin/git-pre-commit | 2 +- admin/gitlab-ci/global.gitlab-ci.yml | 7 +++++++ admin/gitlab-ci/lint.gitlab-ci.yml | 11 +++++++---- docs/dev-manual/build-system.rst | 10 +++++----- docs/dev-manual/code-formatting.rst | 19 ++++++++++--------- 6 files changed, 33 insertions(+), 22 deletions(-) diff --git a/admin/clang-tidy.sh b/admin/clang-tidy.sh index 677d79490c..d606fa5b59 100755 --- a/admin/clang-tidy.sh +++ b/admin/clang-tidy.sh @@ -105,14 +105,14 @@ then if [ -z "$RUN_CLANG_TIDY" ] then echo "Please set the path to run-clang-tidy using the git hook" - echo "git config hooks.runclangtidypath /path/to/run-clang-tidy-7.py" + echo "git config hooks.runclangtidypath /path/to/run-clang-tidy-9.py" echo "or by setting an environment variable, e.g." - echo "RUN_CLANG_TIDY=/path/to/run-clang-tidy-7.py" + echo "RUN_CLANG_TIDY=/path/to/run-clang-tidy-9.py" exit 2 fi if ! which "$RUN_CLANG_TIDY" 1>/dev/null then - echo "run-clang-tidy-7.py not found: $RUN_CLANG_TIDY" + echo "run-clang-tidy-9.py not found: $RUN_CLANG_TIDY" exit 2 fi fi diff --git a/admin/git-pre-commit b/admin/git-pre-commit index d5d5bf858e..be833e3312 100755 --- a/admin/git-pre-commit +++ b/admin/git-pre-commit @@ -88,7 +88,7 @@ then if [ -z "$runclangtidy_path" ] then echo "Please set the path to run-clang-tidy using 'git config hooks.runclangtidypath'." - echo "Note that you need at least clang-tidy-8." + echo "Note that you need at least clang-tidy-9." exit 1 fi export RUN_CLANG_TIDY="$runclangtidy_path" diff --git a/admin/gitlab-ci/global.gitlab-ci.yml b/admin/gitlab-ci/global.gitlab-ci.yml index bbb0716c7d..2ac489e83a 100644 --- a/admin/gitlab-ci/global.gitlab-ci.yml +++ b/admin/gitlab-ci/global.gitlab-ci.yml @@ -176,3 +176,10 @@ COMPILER_MAJOR_VERSION: 8 extends: - .use-clang:base + +.use-clang9: + image: gromacs/cmake-3.13.0-llvm-9-intelopencl-openmpi:master + variables: + COMPILER_MAJOR_VERSION: 9 + extends: + - .use-clang:base diff --git a/admin/gitlab-ci/lint.gitlab-ci.yml b/admin/gitlab-ci/lint.gitlab-ci.yml index 3836cbe5b6..6c3a96af0d 100644 --- a/admin/gitlab-ci/lint.gitlab-ci.yml +++ b/admin/gitlab-ci/lint.gitlab-ci.yml @@ -3,7 +3,7 @@ clang-tidy:configure: extends: - .gromacs:base:configure - - .use-clang7 + - .use-clang9 - .rules:not-for-release dependencies: [] variables: @@ -18,7 +18,7 @@ clang-tidy:build: - .gromacs:base:build - .use-ccache - .variables:default - - .use-clang7 + - .use-clang9 - .rules:nightly-not-for-release stage: source-check needs: @@ -32,7 +32,7 @@ clang-tidy:test: - .gromacs:base:build - .use-ccache - .variables:default - - .use-clang7 + - .use-clang9 - .rules:not-for-release stage: source-check needs: @@ -44,7 +44,10 @@ clang-tidy:test: KUBERNETES_CPU_REQUEST: 2 KUBERNETES_MEMORY_LIMIT: 4Gi script: - - RUN_CLANG_TIDY=run-clang-tidy-$COMPILER_MAJOR_VERSION bash admin/clang-tidy.sh check --parallel=$KUBERNETES_CPU_LIMIT --warnings=clang-tidy.log --rev=origin/master -B=$BUILD_DIR + # TODO (issue #3272) `master` is not appropriate for use on release-xxxx branches, how should we handle that? + # See discussion at https://gitlab.com/gromacs/gromacs/-/merge_requests/67 + - REV=$(git fetch -q https://gitlab.com/gromacs/gromacs.git master && git show -s --pretty=format:"%h" `git merge-base FETCH_HEAD HEAD`) + - RUN_CLANG_TIDY=run-clang-tidy-$COMPILER_MAJOR_VERSION bash admin/clang-tidy.sh check --parallel=$KUBERNETES_CPU_LIMIT --warnings=clang-tidy.log --rev=$REV -B=$BUILD_DIR - grep -iq "found code issues" clang-tidy.log | tee code-lint.txt || true - if [ -s code-lint.txt ] ; then echo "clang-tidy.sh found issues"; exit 1; fi artifacts: diff --git a/docs/dev-manual/build-system.rst b/docs/dev-manual/build-system.rst index a98c9e9f84..a35b57f784 100644 --- a/docs/dev-manual/build-system.rst +++ b/docs/dev-manual/build-system.rst @@ -352,13 +352,13 @@ Variables affecting the ``all`` target .. cmake:: GMX_CLANG_TIDY - `clang-tidy `_ + `clang-tidy `_ is used for static code analysis and (some) automated fixing of issues detected. clang-tidy is easy to install. It is contained in - the llvm binary `package `_. Only - version 8.0.* with libstdc++<7 or libc++ is supported. Others might miss tests or give false positives. - It is run automatically on Jenkins for each commit. Many checks have fixes which can automatically be + the llvm binary `package `_. Only + version 9.0.* with libstdc++<7 or libc++ is supported. Others might miss tests or give false positives. + It is run automatically in gitlab CI for each commit. Many checks have fixes which can automatically be applied. To run it, the build has to be configured with - ``cmake -DGMX_CLANG_TIDY=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=on``. + ``cmake -DGMX_CLANG_TIDY=ON -DCMAKE_BUILD_TYPE=Debug``. Any ``CMAKE_BUILD_TYPE`` which enables asserts (e.g. ASAN) works. Such a configured build will run both the compiler as well as clang-tidy when building. The name of the clang-tidy executable is set with ``-DCLANG_TIDY=...``, and the full path to it can be set with ``-DCLANG_TIDY_EXE=...``. diff --git a/docs/dev-manual/code-formatting.rst b/docs/dev-manual/code-formatting.rst index 9beeb4529c..963389b3ce 100644 --- a/docs/dev-manual/code-formatting.rst +++ b/docs/dev-manual/code-formatting.rst @@ -93,15 +93,17 @@ Other files are ignored by ``clang-tidy.sh``, ``clang-format.sh``, Setting up clang-tidy --------------------- -|Gromacs| source code tidiness checking is enforced with clang-tidy 8.0.1. +|Gromacs| source code tidiness checking is enforced with clang-tidy provided +alongside *clang* compiler version 9. :command:`clang-tidy` is one of the core *clang* tools. It may be included in a *clang* or *llvm* package from your favorite packaging -system or you may find a standalone *clang-tidy* package, -but you should confirm that the provided command is version 8.0.1 or -7.1.0. Example:: +system or you may find a standalone *clang-tidy* or *clang-tools* package, +but you should confirm that the provided command is version 9. +Example:: $ clang-tidy --version - clang-tidy version 7.1.0 (tags/RELEASE_710/final) + LLVM (http://llvm.org/): + LLVM version 9.0.0 If you use a different version of clang-tidy, you will likely get different checking results than @@ -110,12 +112,12 @@ and the commits that you push will fail the automated tests. .. note:: - Refer to `LLVM `__ for + Refer to `LLVM `__ for source and binary downloads. If downloading sources, note that you will need to download both the *LLVM source code* and the *Clang source code*. As per the clang - `INSTALL.txt `__, + `INSTALL.txt `__, place the expanded clang source into a :file:`tools/clang` subdirectory within the expanded llvm archive, then run CMake against the llvm source directory. @@ -134,8 +136,7 @@ clang-tidy discovers which formatting rules to apply from the which will be automatically updated (if necessary) when you :command:`git pull` from the |Gromacs| repository. For more about the tool and the :file:`.clang-tidy` configuration file, -visit https://releases.llvm.org/7.0.1/tools/clang/docs/ClangTidy.html - +visit http://releases.llvm.org/9.0.0/tools/clang/tools/extra/docs/clang-tidy/index.html Scripts ------- -- 2.22.0