summaryrefslogtreecommitdiff
path: root/repo/system/snappy
diff options
context:
space:
mode:
Diffstat (limited to 'repo/system/snappy')
-rw-r--r--repo/system/snappy/cmakelists.patch76
-rw-r--r--repo/system/snappy/fix-inline.patch13
-rw-r--r--repo/system/snappy/rtti.patch56
-rw-r--r--repo/system/snappy/snappy.xibuild37
4 files changed, 182 insertions, 0 deletions
diff --git a/repo/system/snappy/cmakelists.patch b/repo/system/snappy/cmakelists.patch
new file mode 100644
index 0000000..d6576a8
--- /dev/null
+++ b/repo/system/snappy/cmakelists.patch
@@ -0,0 +1,76 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -213,19 +219,28 @@
+ "snappy-stubs-public.h.in"
+ "${PROJECT_BINARY_DIR}/snappy-stubs-public.h")
+
++# When BUILD_SHARED_LIBS is:
++# ON it will generate a SHARED library
++# OFF it will generate a STATIC library
+ add_library(snappy "")
+-target_sources(snappy
+- PRIVATE
++
++# Used to generate both lib types
++if (BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
++ add_library(snappy_static STATIC "")
++ set_target_properties(snappy_static PROPERTIES OUTPUT_NAME snappy)
++ install(TARGETS snappy_static DESTINATION ${CMAKE_INSTALL_LIBDIR})
++endif ()
++
++set(SNAPPY_SOURCE_PRIVATE
+ "snappy-internal.h"
+ "snappy-stubs-internal.h"
+ "snappy-c.cc"
+ "snappy-sinksource.cc"
+ "snappy-stubs-internal.cc"
+ "snappy.cc"
+- "${PROJECT_BINARY_DIR}/config.h"
++ "${PROJECT_BINARY_DIR}/config.h")
+
+- # Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
+- $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC>
++set(SNAPPY_SOURCE_PUBLIC
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-c.h>
+ $<INSTALL_INTERFACE:include/snappy-c.h>
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-sinksource.h>
+@@ -233,18 +248,32 @@
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy.h>
+ $<INSTALL_INTERFACE:include/snappy.h>
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/snappy-stubs-public.h>
+- $<INSTALL_INTERFACE:include/snappy-stubs-public.h>
+-)
+-target_include_directories(snappy
+- PUBLIC
++ $<INSTALL_INTERFACE:include/snappy-stubs-public.h>)
++
++set(SNAPPY_INCLUDE_DIRS
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
+- $<INSTALL_INTERFACE:include>
+-)
++ $<INSTALL_INTERFACE:include>)
++
++# Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
++target_sources(snappy PRIVATE ${SNAPPY_SOURCE_PRIVATE}
++ $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC> ${SNAPPY_SOURCE_PUBLIC})
++
++target_include_directories(snappy PUBLIC ${SNAPPY_INCLUDE_DIRS})
++
++target_compile_definitions(snappy PRIVATE -DHAVE_CONFIG_H)
++
++# Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
++target_sources(snappy_static PRIVATE ${SNAPPY_SOURCE_PRIVATE}
++ $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC> ${SNAPPY_SOURCE_PUBLIC})
++
++target_include_directories(snappy_static PUBLIC ${SNAPPY_INCLUDE_DIRS})
++
++target_compile_definitions(snappy_static PRIVATE -DHAVE_CONFIG_H)
++
+ set_target_properties(snappy
+ PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
+
+-target_compile_definitions(snappy PRIVATE -DHAVE_CONFIG_H)
+ if(BUILD_SHARED_LIBS)
+ set_target_properties(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
+ endif(BUILD_SHARED_LIBS)
diff --git a/repo/system/snappy/fix-inline.patch b/repo/system/snappy/fix-inline.patch
new file mode 100644
index 0000000..96484e0
--- /dev/null
+++ b/repo/system/snappy/fix-inline.patch
@@ -0,0 +1,13 @@
+Patch-Source: https://github.com/google/snappy/pull/128
+
+--- a/snappy.cc
++++ b/snappy.cc
+@@ -1014,7 +1014,7 @@
+ }
+
+ SNAPPY_ATTRIBUTE_ALWAYS_INLINE
+-size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) {
++inline size_t AdvanceToNextTag(const uint8_t** ip_p, size_t* tag) {
+ const uint8_t*& ip = *ip_p;
+ // This section is crucial for the throughput of the decompression loop.
+ // The latency of an iteration is fundamentally constrained by the
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
diff --git a/repo/system/snappy/snappy.xibuild b/repo/system/snappy/snappy.xibuild
new file mode 100644
index 0000000..e266327
--- /dev/null
+++ b/repo/system/snappy/snappy.xibuild
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+NAME="snappy"
+DESC="Fast compression and decompression library"
+
+MAKEDEPS="cmake"
+DEPS="musl "
+
+PKG_VER=1.1.9
+SOURCE="https://github.com/google/snappy/archive/$PKG_VER.tar.gz"
+
+_googletest_commit=18f8200e3079b0e54fa00cb7ac55d4c39dcf6da6
+ADDITIONAL="
+rtti.patch fix-inline.patch
+https://github.com/google/googletest/archive/$_googletest_commit.tar.gz"
+
+prepare () {
+ apply_patches
+ rmdir third_party/googletest
+ tar xvf $_googletest_commit.tar.gz
+ ln -s ../googletest-$_googletest_commit third_party/googletest
+}
+
+build () {
+ cmake -B build -G Ninja \
+ -DCMAKE_INSTALL_PREFIX=/usr \
+ -DCMAKE_INSTALL_LIBDIR=/usr/lib \
+ -DBUILD_SHARED_LIBS=ON \
+ -DBUILD_STATIC_LIBS=OFF \
+ -DSNAPPY_BUILD_BENCHMARKS=OFF
+
+ cmake --build build
+}
+
+package () {
+ DESTDIR="$PKG_DEST" cmake --install build
+}