From 2ce7ba7661f28d8dd1fada3015514bd2edb71f27 Mon Sep 17 00:00:00 2001 From: wangzengliang Date: Wed, 22 Jun 2022 10:29:52 +0800 Subject: [PATCH] add option to enable rtti set default to current (cherry picked from commit cdd4662566eff3e5e8528097c85d5eb2ad3a50d9) --- ...able-rtti-set-default-to-current-ben.patch | 72 +++++++++++++++++++ snappy.spec | 8 ++- 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 add-option-to-enable-rtti-set-default-to-current-ben.patch diff --git a/add-option-to-enable-rtti-set-default-to-current-ben.patch b/add-option-to-enable-rtti-set-default-to-current-ben.patch new file mode 100644 index 0000000..6e259fd --- /dev/null +++ b/add-option-to-enable-rtti-set-default-to-current-ben.patch @@ -0,0 +1,72 @@ +From 07d1ae496bea8280f4cec08df5745845f7956365 Mon Sep 17 00:00:00 2001 +From: Ganesh Maharaj Mahalingam +Date: Wed, 6 Apr 2022 10:04:21 -0700 +Subject: [PATCH] snappy: Autospec creation for version 1.1.9 + +This patch addresses an issue with Ceph +https://tracker.ceph.com/issues/53060. There have been multiple patches +to upstream snappy, but they have all been rejected and the reasoning +has always been that snappy would like to be consistent in their build +flags with chrome as mentioned at +https://github.com/google/snappy/pull/144#issuecomment-968371042 +add-option-to-enable-rtti-set-default-to-current-ben.patch +--- + CMakeLists.txt | 14 ++++++++++---- + snappy-stubs-internal.h | 2 +- + 2 files changed, 11 insertions(+), 5 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 672561e..cafdc59 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -53,8 +53,10 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + 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-") ++ if(NOT SNAPPY_ENABLE_RTTI) ++ string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-") ++ endif(SNAPPY_ENABLE_RTTI) + else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + # Use -Wall for clang and gcc. + if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall") +@@ -78,8 +80,10 @@ else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + 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") ++ if(NOT SNAPPY_ENABLE_RTTI) ++ string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") ++ endif(SNAPPY_ENABLE_RTTI) + endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + + # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make +@@ -98,6 +102,8 @@ option(SNAPPY_REQUIRE_AVX2 "Target processors with AVX2 support." OFF) + + option(SNAPPY_INSTALL "Install Snappy's header and library" ON) + ++option(SNAPPY_ENABLE_RTTI "Enable RTTI for Snappy's library" OFF) ++ + include(TestBigEndian) + test_big_endian(SNAPPY_IS_BIG_ENDIAN) + +diff --git a/snappy-stubs-internal.h b/snappy-stubs-internal.h +index c2a838f..5bf7870 100644 +--- a/snappy-stubs-internal.h ++++ b/snappy-stubs-internal.h +@@ -100,7 +100,7 @@ + + // Inlining hints. + #ifdef HAVE_ATTRIBUTE_ALWAYS_INLINE +-#define SNAPPY_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) ++#define SNAPPY_ATTRIBUTE_ALWAYS_INLINE + #else + #define SNAPPY_ATTRIBUTE_ALWAYS_INLINE + #endif +-- +2.24.4 + diff --git a/snappy.spec b/snappy.spec index 9a66adc..a3c2de5 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: add-option-to-enable-rtti-set-default-to-current-ben.patch BuildRequires: gcc-c++ make gtest-devel cmake @@ -32,7 +33,7 @@ This package is the development files for snappy. %autosetup -n %{name}-%{version} -p1 %build -%cmake +%cmake -DSNAPPY_ENABLE_RTTI=ON %make_build %install @@ -69,6 +70,9 @@ make test %doc NEWS README.md %changelog +* Wed Jun 22 2022 wangzengliang - 1.1.9-2 +- DESC: add-option to enable rtti set default to current + * Tue Dec 7 2021 hanxinke - 1.1.9-1 - DESC: upgrade snappy to 1.1.9 -- Gitee