diff --git a/.github/problem-matchers/gcc.json b/.github/problem-matchers/gcc.json new file mode 100644 index 00000000000..e43b91c6ff0 --- /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 00000000000..ba0aa32a4ee --- /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.bash b/.github/workflows/linux.bash index d0f0a16b510..dffe4c45664 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:*) @@ -28,7 +33,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 @@ -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 diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index ac09815deb0..8fd8c080f9a 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 be5ffe25e29..3dd237ee67e 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 diff --git a/test/base-stacktrace.cpp b/test/base-stacktrace.cpp index f0b87e2cf1c..ecee54a1ffe 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 */ diff --git a/third-party/mmatch/CMakeLists.txt b/third-party/mmatch/CMakeLists.txt index f48e0739f04..4a8da1ed630 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 diff --git a/third-party/utf8cpp/extern/ftest b/third-party/utf8cpp/extern/ftest deleted file mode 160000 index c4ad4af0946..00000000000 --- a/third-party/utf8cpp/extern/ftest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c4ad4af0946b73ce1a40cbc72205d15d196c7e06 diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp index 7559228169b..9a9f9b63388 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; }