summaryrefslogtreecommitdiff
path: root/repo/system/snappy/rtti.patch
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-05-04 23:52:30 +0100
committerdavidovski <david@davidovski.xyz>2022-05-04 23:52:30 +0100
commit739c65c54cb0e957df5e9b76f93fb02554e5cac3 (patch)
tree09ddfa0a342f3ea9de136cb50abdd79821bf1b53 /repo/system/snappy/rtti.patch
parent4c585ad54388285500fd18a6aaa516894e0f2c16 (diff)
moved everything to new file formatting
Diffstat (limited to 'repo/system/snappy/rtti.patch')
-rw-r--r--repo/system/snappy/rtti.patch56
1 files changed, 56 insertions, 0 deletions
diff --git a/repo/system/snappy/rtti.patch b/repo/system/snappy/rtti.patch
new file mode 100644
index 0000000..80f89ff
--- /dev/null
+++ b/repo/system/snappy/rtti.patch
@@ -0,0 +1,56 @@
+From f73b11e87dfbe1cb4862b8ee489679d99534f40b Mon Sep 17 00:00:00 2001
+From: Tim Serong <tserong@suse.com>
+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 <snappy-sinksource.h>
+ 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 | 7 -------
+ 1 file changed, 7 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 6eef485..755605d 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -51,10 +51,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
+ string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ 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 +73,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