zlib: don’t define __clang__ for win-arm64 with MSVC

Defining __clang__ when MSVC was used to build zlib was added in
761c6fe8be0e (https://chromium-review.googlesource.com/c/1347773,
2018-12-12) to overcome a problem where the non-clang codepath normally
used by MSVC contained SSE4.2 (x86-specific) intrinsics.

Since zlib in Chromium 9d4ec9349a1b
(https://chromium-review.googlesource.com/c/1960893, 2019-12-12—exactly
one year later!), zlib changed and the __clang__ workaround was no
longer necessary, but evidently not harmful, either.

At some point, the Windows SDK improved its clang compatibility, and its
headers gained some macros to disable clang warnings when being built
with clang. <ucrt/corecrt.h> offers _UCRT_DISABLE_CLANG_WARNINGS, which
expands to _Pragma("clang diagnostic push") and similar when clang is in
use, determined by __clang__ being defined. MSVC doesn’t understand
these pragmas, and raises warning C4068 (unknown pragma), which causes a
build failure when warnings are treated as errors.
_UCRT_DISABLE_CLANG_WARNINGS was used in many headers easily seen by
zlib, such as <stdlib.h>.

Because the __clang__ workaround is no longer necessary, was always
wrong, and since MSVC can now build zlib for win-arm64 without it, just
remove it.

Bug: 42310164, 399670190
Change-Id: I9c0a811db5cf5a623f2988f13c8216e16cc56168
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/6309922
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Mark Mentovai 2025-02-27 14:14:49 -05:00 committed by Crashpad LUCI CQ
parent a47010323c
commit 32a2c250a3

View File

@ -103,12 +103,6 @@ if (zlib_source == "external") {
"/wd4324", # structure was padded due to alignment specifier
"/wd4702", # unreachable code
]
if (current_cpu == "arm64" && !crashpad_is_clang) {
# Select code path for clang in zlib to avoid using MSVC x86/x64
# intrinsics for Windows ARM64.
# TODO: https://crashpad.chromium.org/bug/267
defines += [ "__clang__" ]
}
} else {
defines += [
"HAVE_HIDDEN",