From 07d1ae496bea8280f4cec08df5745845f7956365 Mon Sep 17 00:00:00 2001
From: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
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

