Files
ResInsight/ThirdParty/vcpkg-overlay-ports/snappy/rtti.diff
T
Magne Sjaastad f6787a9ea1 vcpkg: Patch snappy for AVX-by-default toolchains via overlay port
snappy 1.2.2, a transitive dependency of arrow, includes <immintrin.h> only
when SNAPPY_HAVE_BMI2 or SNAPPY_HAVE_X86_CRC32 is set, but MemCopy64() selects
an AVX code path on a separate condition, `defined(__x86_64__) &&
defined(__AVX__)`. The vcpkg port passes -DSNAPPY_HAVE_BMI2=OFF and
-DSNAPPY_HAVE_X86_CRC32=OFF to keep the binaries portable, so on a toolchain
whose default target enables AVX that branch is compiled with no intrinsics
header and snappy.cc fails with "'__m256i' was not declared in this scope".

This broke the clang-tidy and clazy-report workflows the first night after they
moved to ubuntu-26.04. The runner switch also changed the vcpkg compiler hash,
so the binary cache went from "Restored 103 package(s)" to "Restored 0
package(s)" and every port was rebuilt from source, which is what exposed
snappy in the first place. The bug is not GCC 15 specific: microsoft/vcpkg#51047
reports it against GCC 14.3.1. It is still present in snappy 1.3.1 and main, and
vcpkg master still ships 1.2.2 with the SNAPPY_HAVE_* options off, so neither a
baseline bump nor a port update fixes it.

Vendor the port under ThirdParty/vcpkg-overlay-ports and add
avx-immintrin.patch, which includes <immintrin.h> for the __AVX__ branch as
well. The patch cannot change the ISA baseline of the result: it only supplies
a header on a path the compiler was already going to take. Verified by
reproducing the failure locally with an overlay triplet setting
-march=x86-64-v3, confirming the patched port builds both with and without that
flag, and checking that objdump finds no AVX instructions in the library built
with the stock toolchain.

Reference the two overlay ports by their individual directories rather than by
the parent directory. The two configurations resolve different versions of both
ports (default: snappy 1.2.2#1, thrift 0.22.0; rhel8: snappy 1.2.1,
thrift 0.20.0#1), so an overlay of the whole directory would downgrade thrift
for the default builds and bump snappy for RHEL8. Dry runs of both manifests
confirm each profile now picks up only its own overlay.

The bumped port-version misses the existing vcpkg binary caches, but those
caches are already cold for the ubuntu-26.04 workflows.
2026-09-29 14:14:51 +02:00

28 lines
912 B
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cd71a47..d92aed0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,8 +53,10 @@ if(MSVC)
add_definitions(-D_HAS_EXCEPTIONS=0)
# Disable RTTI.
+ if(NOT SNAPPY_WITH_RTTI)
string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
+ endif()
else(MSVC)
# Use -Wall for clang and gcc.
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
@@ -82,9 +84,11 @@ else(MSVC)
string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
+ if(NOT SNAPPY_WITH_RTTI)
# Disable RTTI.
string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
+ endif()
endif(MSVC)
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make