|
49 | 49 | src/main/c/share/byte_sink.h |
50 | 50 | ) |
51 | 51 |
|
| 52 | +# libzstd is included via a git submodule at src/main/c/share/zstd (pinned to |
| 53 | +# upstream tag v1.5.7). Covers the client side of the QWP egress compression |
| 54 | +# feature; the server-side compressor lives in the Rust qdbr crate and isn't |
| 55 | +# linked into this library. Only the decompress-only subset of upstream is |
| 56 | +# compiled -- the compress/ directory is left out entirely. zstd_jni.c is our |
| 57 | +# JNI glue and lives alongside the submodule (not inside) so upstream resets |
| 58 | +# don't disturb it. |
| 59 | +if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/main/c/share/zstd/lib/zstd.h) |
| 60 | + message(FATAL_ERROR |
| 61 | + "libzstd submodule not initialised. Run:\n" |
| 62 | + " git submodule update --init --recursive\n" |
| 63 | + "from java-questdb-client/.") |
| 64 | +endif () |
| 65 | +set( |
| 66 | + ZSTD_FILES |
| 67 | + src/main/c/share/zstd_jni.c |
| 68 | + src/main/c/share/zstd/lib/common/debug.c |
| 69 | + src/main/c/share/zstd/lib/common/entropy_common.c |
| 70 | + src/main/c/share/zstd/lib/common/error_private.c |
| 71 | + src/main/c/share/zstd/lib/common/fse_decompress.c |
| 72 | + src/main/c/share/zstd/lib/common/pool.c |
| 73 | + src/main/c/share/zstd/lib/common/threading.c |
| 74 | + src/main/c/share/zstd/lib/common/xxhash.c |
| 75 | + src/main/c/share/zstd/lib/common/zstd_common.c |
| 76 | + src/main/c/share/zstd/lib/decompress/huf_decompress.c |
| 77 | + src/main/c/share/zstd/lib/decompress/zstd_ddict.c |
| 78 | + src/main/c/share/zstd/lib/decompress/zstd_decompress_block.c |
| 79 | + src/main/c/share/zstd/lib/decompress/zstd_decompress.c |
| 80 | +) |
| 81 | +# x86_64-only hand-tuned Huffman decoder; C fallback kicks in when |
| 82 | +# ZSTD_DISABLE_ASM is set. |
| 83 | +if (ARCH_AMD64 AND NOT WIN32) |
| 84 | + list(APPEND ZSTD_FILES src/main/c/share/zstd/lib/decompress/huf_decompress_amd64.S) |
| 85 | +endif () |
| 86 | +list(APPEND SOURCE_FILES ${ZSTD_FILES}) |
| 87 | + |
52 | 88 | # JNI includes |
53 | 89 | include_directories($ENV{JAVA_HOME}/include/) |
54 | 90 |
|
@@ -111,6 +147,20 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT}) |
111 | 147 |
|
112 | 148 | add_library(questdb SHARED ${SOURCE_FILES}) |
113 | 149 |
|
| 150 | +# libzstd public header is at zstd/lib/zstd.h; internal headers live under |
| 151 | +# zstd/lib/common/. Both directories go on the include path so zstd_jni.c can |
| 152 | +# use the short include "zstd.h" and the upstream .c files can find their own |
| 153 | +# siblings without patching. |
| 154 | +target_include_directories(questdb PRIVATE |
| 155 | + ${CMAKE_CURRENT_SOURCE_DIR}/src/main/c/share/zstd/lib |
| 156 | + ${CMAKE_CURRENT_SOURCE_DIR}/src/main/c/share/zstd/lib/common) |
| 157 | + |
| 158 | +# Drop the zstd-internal hand-written amd64 assembly on platforms that can't |
| 159 | +# assemble it; libzstd falls back to a C implementation when this is set. |
| 160 | +if (NOT ARCH_AMD64 OR WIN32) |
| 161 | + target_compile_definitions(questdb PRIVATE ZSTD_DISABLE_ASM=1) |
| 162 | +endif () |
| 163 | + |
114 | 164 | set(COMMON_OPTIONS "-Wno-gnu-anonymous-struct;-Wno-nested-anon-types;-Wno-unused-parameter;-fPIC;-fno-rtti;-fno-exceptions") |
115 | 165 |
|
116 | 166 | set(DEBUG_OPTIONS "-Wall;-pedantic;-Wextra;-g;-O0") |
|
0 commit comments