From cfddf393616007a3c429861f4e47c4317b37259b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Nov 2026 12:10:50 +0100 Subject: [PATCH 1/7] build: apply `SENTRY_ERROR_ON_WARNINGS` to breakpad and crashpad Build breakpad with `/W3` on MSVC and `-Wall` elsewhere, and treat breakpad's and crashpad's warnings as errors with `SENTRY_ERROR_ON_WARNINGS`. Bump breakpad and crashpad to fix their warnings. --- CMakeLists.txt | 8 +++++++- external/CMakeLists.txt | 9 +++++++++ external/breakpad | 2 +- external/crashpad | 2 +- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85392691a8..422d303fd8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,7 +124,7 @@ option(SENTRY_TRANSPORT_COMPRESSION "Enable transport gzip compression" OFF) option(SENTRY_BUILD_TESTS "Build sentry-native tests" "${SENTRY_MAIN_PROJECT}") option(SENTRY_BUILD_EXAMPLES "Build sentry-native example(s)" "${SENTRY_MAIN_PROJECT}") option(SENTRY_BUILD_BENCHMARKS "Build sentry-native benchmarks" OFF) -option(SENTRY_ERROR_ON_WARNINGS "Treat warnings in sentry and sentry-crash as errors on GCC and Clang" OFF) +option(SENTRY_ERROR_ON_WARNINGS "Treat warnings in sentry-native as errors on GCC and Clang" OFF) option(SENTRY_INTEGRATION_PLATFORM "Enable the downstream-provided platform integration" OFF) @@ -796,6 +796,12 @@ if(SENTRY_BACKEND_CRASHPAD) endif() add_subdirectory(external/crashpad crashpad_build) + if(SENTRY_ERROR_ON_WARNINGS AND NOT MSVC) + target_compile_options(crashpad_interface INTERFACE + $<$:-Werror> + ) + endif() + if(WIN32) add_dependencies(sentry crashpad::wer) endif() diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 74e7c83c5b..6b994db4b3 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -188,6 +188,15 @@ if(WIN32) endif() endif() +if(MSVC) + target_compile_options(breakpad_client PRIVATE /W3) +else() + target_compile_options(breakpad_client PRIVATE -Wall) + if(SENTRY_ERROR_ON_WARNINGS) + target_compile_options(breakpad_client PRIVATE -Werror) + endif() +endif() + # breakpad has includes directly to `third_party/lss/...`, # which are being resolved correctly when we add the current directory to # the include directories. A giant hack, yes, but it works diff --git a/external/breakpad b/external/breakpad index 25b6b727af..06c8a83d97 160000 --- a/external/breakpad +++ b/external/breakpad @@ -1 +1 @@ -Subproject commit 25b6b727af49fa383161e7dba4a82ab0661b69b8 +Subproject commit 06c8a83d979583b23ad425a1b58e65b016ee8dda diff --git a/external/crashpad b/external/crashpad index 702c3d5a0d..c0d4832d8d 160000 --- a/external/crashpad +++ b/external/crashpad @@ -1 +1 @@ -Subproject commit 702c3d5a0d02c9b72a8b029d33bdfcd81dc75f65 +Subproject commit c0d4832d8d782a771f535ff666463787344f6b04 From 3831d9d1372015e0c4abaecc03f13cdf9071591e Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Nov 2026 12:14:58 +0100 Subject: [PATCH 2/7] build: respect `SENTRY_ERROR_ON_WARNINGS` on MSVC Add `/WX` to sentry, crashpad and breakpad when the option is enabled, like `-Werror` on other compilers. --- CMakeLists.txt | 19 ++++++++++++++----- external/CMakeLists.txt | 3 +++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 422d303fd8..28ad6ccb2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,7 +124,7 @@ option(SENTRY_TRANSPORT_COMPRESSION "Enable transport gzip compression" OFF) option(SENTRY_BUILD_TESTS "Build sentry-native tests" "${SENTRY_MAIN_PROJECT}") option(SENTRY_BUILD_EXAMPLES "Build sentry-native example(s)" "${SENTRY_MAIN_PROJECT}") option(SENTRY_BUILD_BENCHMARKS "Build sentry-native benchmarks" OFF) -option(SENTRY_ERROR_ON_WARNINGS "Treat warnings in sentry-native as errors on GCC and Clang" OFF) +option(SENTRY_ERROR_ON_WARNINGS "Treat warnings in sentry-native as errors" OFF) option(SENTRY_INTEGRATION_PLATFORM "Enable the downstream-provided platform integration" OFF) @@ -597,6 +597,9 @@ if(MSVC) else() target_compile_options(sentry PRIVATE $) endif() + if(SENTRY_ERROR_ON_WARNINGS) + target_compile_options(sentry PRIVATE $) + endif() # ignore all warnings for mpack set_source_files_properties( "${PROJECT_SOURCE_DIR}/src/sentry_mpack.c" @@ -796,10 +799,16 @@ if(SENTRY_BACKEND_CRASHPAD) endif() add_subdirectory(external/crashpad crashpad_build) - if(SENTRY_ERROR_ON_WARNINGS AND NOT MSVC) - target_compile_options(crashpad_interface INTERFACE - $<$:-Werror> - ) + if(SENTRY_ERROR_ON_WARNINGS) + if(MSVC) + target_compile_options(crashpad_interface INTERFACE + $<$:/WX> + ) + else() + target_compile_options(crashpad_interface INTERFACE + $<$:-Werror> + ) + endif() endif() if(WIN32) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 6b994db4b3..2f26ff5476 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -190,6 +190,9 @@ endif() if(MSVC) target_compile_options(breakpad_client PRIVATE /W3) + if(SENTRY_ERROR_ON_WARNINGS) + target_compile_options(breakpad_client PRIVATE /WX) + endif() else() target_compile_options(breakpad_client PRIVATE -Wall) if(SENTRY_ERROR_ON_WARNINGS) From e9fb7efb7629912ad85c370911b480d6721eb61b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Nov 2026 13:38:49 +0100 Subject: [PATCH 3/7] build: suppress the warnings new in clang-cl 21 clang-cl maps `-Wall` to `-Weverything`, so the warnings that clang 21 added fail the `sentry` build with the clang-cl 22.1.3 that ships with Visual Studio 2026. ```text include\sentry.h(955,11): error: identifier 'wchar_t' conflicts with a C++ keyword [-Werror,-Wc++-keyword] src\sentry_attachment.c(233,12): error: not eliding copy on return [-Werror,-Wnrvo] src\backends\sentry_backend_inproc.c(147,31): error: padding struct 'struct sentry_inproc_backend_config_s' with 3 bytes to align 'handler_strategy' [-Werror,-Wpadded] ``` --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28ad6ccb2c..124251a83f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -632,7 +632,13 @@ if(MSVC) $ $ $ + $ + $ ) + # older versions reject the unknown option under -Werror + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 21) + target_compile_options(sentry PRIVATE $) + endif() endif() else() target_compile_options(sentry PRIVATE $) From b9a335d77b8af05acbc44a0d90161f75a61f2392 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Nov 2026 13:46:59 +0100 Subject: [PATCH 4/7] build: bump breakpad and crashpad to the merged warning fixes Bump to the merge commits of getsentry/breakpad#47 and getsentry/crashpad#181. --- external/breakpad | 2 +- external/crashpad | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/external/breakpad b/external/breakpad index 06c8a83d97..881d74bcc6 160000 --- a/external/breakpad +++ b/external/breakpad @@ -1 +1 @@ -Subproject commit 06c8a83d979583b23ad425a1b58e65b016ee8dda +Subproject commit 881d74bcc64ef36dc879245609139fc0e3cbd97b diff --git a/external/crashpad b/external/crashpad index c0d4832d8d..bc334efe17 160000 --- a/external/crashpad +++ b/external/crashpad @@ -1 +1 @@ -Subproject commit c0d4832d8d782a771f535ff666463787344f6b04 +Subproject commit bc334efe17f07a56e3219a0261d2862d280d4d34 From ba23051ed609608bc091b5a186678bbd5c548ead Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Nov 2026 13:48:54 +0100 Subject: [PATCH 5/7] build: copy the sentry warning options to sentry-crash on MSVC `sentry-crash` copied the warning options from `sentry` only on GCC and Clang, so `SENTRY_ERROR_ON_WARNINGS` did not reach the daemon on MSVC. Ref: https://github.com/getsentry/sentry-native/pull/2315#discussion_r4642291298 --- CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 124251a83f..8eb66a4a9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1012,10 +1012,8 @@ elseif(SENTRY_BACKEND_NATIVE) endif() # Copy warning options from sentry target - if(NOT MSVC) - get_target_property(SENTRY_COMPILE_OPTIONS sentry COMPILE_OPTIONS) - target_compile_options(sentry-crash PRIVATE ${SENTRY_COMPILE_OPTIONS}) - endif() + get_target_property(SENTRY_COMPILE_OPTIONS sentry COMPILE_OPTIONS) + target_compile_options(sentry-crash PRIVATE ${SENTRY_COMPILE_OPTIONS}) # Copy include directories from sentry target target_include_directories(sentry-crash PRIVATE From cd45e308ccc01f81f1ab3d951dfbaf86f76c2292 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Nov 2026 13:53:36 +0100 Subject: [PATCH 6/7] ci: add a ClangCL job for VS 2026 Run the ClangCL build and tests on `windows-2025-vs2026` as well, which ships a newer clang-cl than VS 2022. Let CMake pick the installed Visual Studio instead of forcing the VS 2022 generator. --- .github/workflows/ci.yml | 5 ++++- tests/cmake.py | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c0bd40e45..e55600715d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -204,10 +204,13 @@ jobs: - name: Windows (VS 2026, ninja + sccache) os: windows-2025-vs2026 USE_SCCACHE: 1 - - name: Windows ClangCL (2022 + llvm-cov) + - name: Windows ClangCL (VS 2022 + llvm-cov) os: windows-2022 VS_GENERATOR_TOOLSET: ClangCL RUN_ANALYZER: llvm-cov + - name: Windows ClangCL (VS 2026) + os: windows-2025-vs2026 + VS_GENERATOR_TOOLSET: ClangCL - name: LLVM-Mingw os: windows-latest TEST_MINGW: 1 diff --git a/tests/cmake.py b/tests/cmake.py index bb45b4779a..aa0a0b1d2a 100644 --- a/tests/cmake.py +++ b/tests/cmake.py @@ -362,7 +362,6 @@ def cmake_build(cwd, targets, options): def configure_clang_cl(config_cmd: list[str]): - config_cmd.append("-G Visual Studio 17 2022") config_cmd.append("-A x64") config_cmd.append("-T ClangCL") From da0cbbd3ec6d79731476e6f12c8b6b2fee9edd64 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Fri, 20 Nov 2026 13:56:54 +0100 Subject: [PATCH 7/7] build: respect `SENTRY_ERROR_ON_WARNINGS` on clang-cl clang-cl always built `sentry` with `-Werror`, so each new clang-cl warning broke the build for everyone. Leave it to the `/WX` that `SENTRY_ERROR_ON_WARNINGS` adds. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8eb66a4a9c..e0162b27e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -615,7 +615,7 @@ if(MSVC) if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # clang-cl target_compile_options(sentry PRIVATE - $ + $ $ $ $