From 43cc09274987b23240b3c5dec0c9498c7b2b3f80 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Thu, 4 Sep 2025 13:32:14 +0200 Subject: [PATCH 1/7] Add Github Problem Matchers actions for GCC/MSVC MSVC needs two matchers: One general matcher for regular single-line warnings, and one multi-line matcher for template warnings that originate from a template in MSVC's library. In the latter case, MSVC prints the path to the actual file that should be annotated several lines down and all lines in between the first line and that line need to be matched by one of the regexps. --- .github/problem-matchers/gcc.json | 17 +++++++++++ .github/problem-matchers/msvc.json | 49 ++++++++++++++++++++++++++++++ .github/workflows/linux.yml | 3 ++ .github/workflows/windows.yml | 4 +++ 4 files changed, 73 insertions(+) create mode 100644 .github/problem-matchers/gcc.json create mode 100644 .github/problem-matchers/msvc.json diff --git a/.github/problem-matchers/gcc.json b/.github/problem-matchers/gcc.json new file mode 100644 index 0000000000..e43b91c6ff --- /dev/null +++ b/.github/problem-matchers/gcc.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "gcc-problem-matcher", + "pattern": [ + { + "regexp": "^(?:(?:\\.\\.?)?\\/)?(?:icinga2\\/)?(.*?):(\\d+):(\\d*):?\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + ] + } + ] +} diff --git a/.github/problem-matchers/msvc.json b/.github/problem-matchers/msvc.json new file mode 100644 index 0000000000..ba0aa32a4e --- /dev/null +++ b/.github/problem-matchers/msvc.json @@ -0,0 +1,49 @@ +{ + "problemMatcher": [ + { + "owner": "msvc-problem-matcher", + "pattern": [ + { + "regexp": "^([^\\s].*icinga2.*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\):\\s(error|warning|info)\\s(\\w{1,2}\\d+):\\s([^\\s].*?)\\s\\[(.*)\\]$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "code": 5, + "message": 6, + "fromPath": 7 + } + ] + }, + { + "owner": "msvc-template-problem-matcher", + "pattern": [ + { + "regexp": "^(?:[^\\s].*Microsoft.*)\\(\\d+,?\\d+?(?:,\\d+,\\d+)?\\):\\s(error|warning|info)\\s(\\w{1,2}\\d+):\\s([^\\s].*?)\\s\\[(.*)\\]$", + "severity": 1, + "code": 2, + "message": 3, + "fromPath": 4 + }, + { + "regexp": "^\\s*(?:[^\\s].*Microsoft.*)\\(\\d+,?\\d+?(?:,\\d+,\\d+)?\\):.*$" + }, + { + "regexp": "^\\s*\\(compiling source file '.*?'\\)$" + }, + { + "regexp": "^\\s*(?:[^\\s].*Microsoft.*)\\(\\d+,?\\d+?(?:,\\d+,\\d+)?\\):.*$" + }, + { + "regexp": "^\\s+the template instantiation context \\(the oldest one first\\) is$" + }, + { + "regexp": "^\\s*([^\\s].*icinga2.*)\\((\\d+),?(\\d+)?(?:,\\d+,\\d+)?\\):$", + "file": 1, + "line": 2, + "column": 3 + } + ] + } + ] +} diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index ac09815deb..8fd8c080f9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -69,6 +69,9 @@ jobs: - name: Checkout HEAD uses: actions/checkout@v5 + - name: Turn on Problem Matcher + run: echo "::add-matcher::.github/problem-matchers/gcc.json" + - name: Restore/backup ccache uses: actions/cache@v4 with: diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index be5ffe25e2..3dd237ee67 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -38,6 +38,10 @@ jobs: Set-PSDebug -Trace 1 & .\doc\win-dev.ps1 + - name: Turn on Problem Matcher + run: | + Write-Host "::add-matcher::.github/problem-matchers/msvc.json" + - name: Binary run: | Set-PSDebug -Trace 1 From ec1f44879a4dab80bde508d4d33692021d3d0cb2 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Tue, 9 Sep 2025 16:57:49 +0200 Subject: [PATCH 2/7] Remove MSVC warnings about unknown pragmas GCC/clang --- test/base-stacktrace.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/base-stacktrace.cpp b/test/base-stacktrace.cpp index f0b87e2cf1..ecee54a1ff 100644 --- a/test/base-stacktrace.cpp +++ b/test/base-stacktrace.cpp @@ -20,12 +20,13 @@ using namespace icinga; * should be printed. If it looks somewhat meaningful, you can probably ignore a failure of this test case. */ +#ifndef _MSC_VER #pragma GCC push_options #pragma GCC optimize ("O0") #pragma clang optimize off -#ifdef _MSVC_VER +#else /* _MSC_VER */ #pragma optimize("", off) -#endif /* _MSVC_VER */ +#endif /* _MSC_VER */ BOOST_AUTO_TEST_SUITE(base_stacktrace) @@ -65,8 +66,9 @@ BOOST_AUTO_TEST_CASE(stacktrace) BOOST_AUTO_TEST_SUITE_END() +#ifndef _MSC_VER #pragma GCC pop_options #pragma clang optimize on -#ifdef _MSVC_VER +#else /* _MSC_VER */ #pragma optimize("", on) -#endif /* _MSVC_VER */ +#endif /* _MSC_VER */ From 9b0fa9ff971df77f0404637acf1614633cef1202 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Tue, 9 Sep 2025 17:01:32 +0200 Subject: [PATCH 3/7] Remove reference to missing ftest submodule --- third-party/utf8cpp/extern/ftest | 1 - 1 file changed, 1 deletion(-) delete mode 160000 third-party/utf8cpp/extern/ftest diff --git a/third-party/utf8cpp/extern/ftest b/third-party/utf8cpp/extern/ftest deleted file mode 160000 index c4ad4af094..0000000000 --- a/third-party/utf8cpp/extern/ftest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c4ad4af0946b73ce1a40cbc72205d15d196c7e06 From 6fc966c502f6e2b0dbef7f49820a1e71ed20c056 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Tue, 9 Sep 2025 17:07:48 +0200 Subject: [PATCH 4/7] Silence Amazonlinux:2 warnings about deprecated coroutines --- .github/workflows/linux.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.bash b/.github/workflows/linux.bash index d0f0a16b51..6b4e9d16f9 100755 --- a/.github/workflows/linux.bash +++ b/.github/workflows/linux.bash @@ -28,7 +28,7 @@ case "$DISTRO" in ( cd boost_1_69_0 ./bootstrap.sh --with-libraries=context,coroutine,date_time,filesystem,iostreams,program_options,regex,system,test,thread - ./b2 + ./b2 define=BOOST_COROUTINES_NO_DEPRECATION_WARNING ) ln -vs /usr/bin/cmake3 /usr/local/bin/cmake From 0b57e9a30c571dba9a21c3d2c7cba74f05f4745f Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Wed, 10 Sep 2025 12:30:38 +0200 Subject: [PATCH 5/7] Disable -Wunused-(parameter|variable) on generated files --- tools/mkclass/classcompiler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp index 7559228169..9a9f9b6338 100644 --- a/tools/mkclass/classcompiler.cpp +++ b/tools/mkclass/classcompiler.cpp @@ -1482,6 +1482,10 @@ void ClassCompiler::CompileStream(const std::string& path, std::istream& input, << "#pragma warning( push )" << std::endl << "#pragma warning( disable : 4244 )" << std::endl << "#pragma warning( disable : 4800 )" << std::endl + << "#else /* _MSC_VER */" << std::endl + << "#pragma GCC diagnostic push" << std::endl + << "#pragma GCC diagnostic ignored \"-Wunused-parameter\"" << std::endl + << "#pragma GCC diagnostic ignored \"-Wunused-variable\"" << std::endl << "#endif /* _MSC_VER */" << std::endl << std::endl; @@ -1492,5 +1496,7 @@ void ClassCompiler::CompileStream(const std::string& path, std::istream& input, oimpl << "#ifdef _MSC_VER" << std::endl << "#pragma warning ( pop )" << std::endl + << "#else /* _MSC_VER */" << std::endl + << "#pragma GCC diagnostic pop" << std::endl << "#endif /* _MSC_VER */" << std::endl; } From 05d933c18d179203ffd27a211247250cd3f50e40 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Wed, 10 Sep 2025 12:39:49 +0200 Subject: [PATCH 6/7] Enable -Wall -Wextra for all Linux runners With some exceptions. --- .github/workflows/linux.bash | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.bash b/.github/workflows/linux.bash index 6b4e9d16f9..dffe4c4566 100755 --- a/.github/workflows/linux.bash +++ b/.github/workflows/linux.bash @@ -5,6 +5,11 @@ export PATH="/usr/lib/ccache/bin:/usr/lib/ccache:/usr/lib64/ccache:$PATH" export CCACHE_DIR=/icinga2/ccache export CTEST_OUTPUT_ON_FAILURE=1 CMAKE_OPTS=() +# -Wstringop-overflow is notorious for false positives and has been a problem for years. +# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443 +# -Wtemplate-id-cdtor leaks from using the generated headers. We should reenable this once +# we're considering moving to C++20 and/or the -ti.hpp files are generated differently. +WARN_FLAGS="-Wall -Wextra -Wno-template-id-cdtor -Wno-stringop-overflow" case "$DISTRO" in alpine:*) @@ -79,14 +84,21 @@ esac case "$DISTRO" in alpine:*) - CMAKE_OPTS+=(-DUSE_SYSTEMD=OFF -DICINGA2_WITH_MYSQL=OFF -DICINGA2_WITH_PGSQL=OFF) + CMAKE_OPTS+=( + -DUSE_SYSTEMD=OFF + -DICINGA2_WITH_MYSQL=OFF + -DICINGA2_WITH_PGSQL=OFF + -DCMAKE_{C,CXX}_FLAGS="${WARN_FLAGS}" + ) ;; debian:*|ubuntu:*) CMAKE_OPTS+=(-DICINGA2_LTO_BUILD=ON) source <(dpkg-buildflags --export=sh) + export CFLAGS="${CFLAGS} ${WARN_FLAGS}" + export CXXFLAGS="${CXXFLAGS} ${WARN_FLAGS}" ;; *) - CMAKE_OPTS+=(-DCMAKE_{C,CXX}_FLAGS="$(rpm -E '%{optflags} %{?march_flag}')") + CMAKE_OPTS+=(-DCMAKE_{C,CXX}_FLAGS="$(rpm -E '%{optflags} %{?march_flag}') ${WARN_FLAGS}") export LDFLAGS="$(rpm -E '%{?build_ldflags}')" ;; esac From 47a9dab8476f779de6d6f06036152fee54e9a6f5 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Wed, 24 Sep 2025 10:03:55 +0200 Subject: [PATCH 7/7] Disable -Wimplicit-fallthrough for mmatch --- third-party/mmatch/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/third-party/mmatch/CMakeLists.txt b/third-party/mmatch/CMakeLists.txt index f48e0739f0..4a8da1ed63 100644 --- a/third-party/mmatch/CMakeLists.txt +++ b/third-party/mmatch/CMakeLists.txt @@ -6,6 +6,13 @@ set(mmatch_SOURCES add_library(mmatch OBJECT ${mmatch_SOURCES}) +if(NOT MSVC) + target_compile_options(mmatch + PRIVATE + -Wno-implicit-fallthrough + ) +endif() + set_target_properties( mmatch PROPERTIES FOLDER Lib