diff --git a/fix-default-enable-RTTI-in-1.1.9.patch b/fix-default-enable-RTTI-in-1.1.9.patch new file mode 100644 index 0000000000000000000000000000000000000000..9966766e4475d5ced980dc68121875589b84a3d6 --- /dev/null +++ b/fix-default-enable-RTTI-in-1.1.9.patch @@ -0,0 +1,59 @@ +From f73b11e87dfbe1cb4862b8ee489679d99534f40b Mon Sep 17 00:00:00 2001 +From: Tim Serong +Date: Wed, 27 Oct 2021 18:49:04 +1100 +Subject: [PATCH] Re-enable RTTI (needed in order to subclass Source, etc.) + +Commit c98344f in snappy 1.1.9 disabled RTTI, which means the +snappy library no longer exports typeinfo for snappy::Source, +snappy::Sink, ..., so users of the library can't subclass these +classes anymore. + +Here's a trivial reproducer: + + #include + class MySource : snappy::Source { + public: + size_t Available() const override { return 0; } + const char *Peek(size_t *len) override { return NULL; } + void Skip(size_t n) override {} + }; + int main(int argc, char **argv) { + MySource m; + return 0; + } + +Try `g++ -o snappy-test ./snappy-test.cc -lsnappy` with the above +and the linker will fail with "undefined reference to `typeinfo +for snappy::Source'" if RTTI was disabled in the snappy build. + +--- + CMakeLists.txt | 6 ------ + 1 file changed, 6 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 672561e..a4b2cc7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -52,9 +52,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c-") + add_definitions(-D_HAS_EXCEPTIONS=0) + +- # Disable RTTI. +- string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-") + else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # Use -Wall for clang and gcc. + if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall") +@@ -77,9 +74,6 @@ else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions") + +- # Disable RTTI. +- string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") + endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + + # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make +-- +2.24.4 + diff --git a/snappy.spec b/snappy.spec index 79d3e8a7420f3b60f0ac348b2693d7df1b578915..73ad8a4e016e32899fc91d52082eba2f212506ee 100644 --- a/snappy.spec +++ b/snappy.spec @@ -1,6 +1,6 @@ Name: snappy Version: 1.1.9 -Release: 1 +Release: 2 Summary: A fast compressor/decompressor License: BSD URL: https://github.com/google/snappy @@ -9,6 +9,7 @@ Source1: snappy.pc Patch0: remove-dependency-on-google-benchmark-and-gmock.patch Patch1: fix-the-AdvanceToNextTag-fails-to-be-compiled-without-inline.patch +Patch2: fix-default-enable-RTTI-in-1.1.9.patch BuildRequires: gcc-c++ make gtest-devel cmake @@ -69,6 +70,9 @@ make test %doc NEWS README.md %changelog +* Tue Jun 21 2022 wangzengliang - 1.1.9-2 +- default enable RTTI + * Fri Dec 24 2021 yuanxin - 1.1.9-1 - update version to 1.1.9