summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig38
1 files changed, 38 insertions, 0 deletions
diff --git a/build.zig b/build.zig
index c0235e41..5e88ef68 100644
--- a/build.zig
+++ b/build.zig
@@ -964,6 +964,44 @@ pub fn build(b: *std.Build) void {
if (sources != 1) @panic("zstbi's build no longer compiles one C file: redo its patch in build.zig");
};
+ // One zstd (docs/shared-libs.md): a far replica's stream, compressed by
+ // its session and read by its client (src/replica.zig). The library's
+ // compressor and decompressor alone, single-threaded and without its
+ // x86 assembly, each context made with ZSTD_customMem over c_heap; of
+ // its block compressors only those of levels 3 (dfast) and 6 (lazy),
+ // the two replica.zig asks for, and its unused functions dropped at
+ // link. Zig's std has a decompressor, but no compressor.
+ if (!freestanding_core) {
+ const dep = b.dependency("zstd", .{});
+ const zstd = b.addLibrary(.{
+ .name = "zstd",
+ .root_module = b.createModule(.{ .target = target, .optimize = c_optimize, .link_libc = true }),
+ .linkage = .static,
+ });
+ zstd.root_module.addCSourceFiles(.{
+ .root = dep.path("lib"),
+ .files = &.{
+ "common/debug.c", "common/entropy_common.c", "common/error_private.c",
+ "common/fse_decompress.c", "common/pool.c", "common/threading.c",
+ "common/xxhash.c", "common/zstd_common.c", "compress/fse_compress.c",
+ "compress/hist.c", "compress/huf_compress.c", "compress/zstd_compress.c",
+ "compress/zstd_compress_literals.c", "compress/zstd_compress_sequences.c", "compress/zstd_compress_superblock.c",
+ "compress/zstd_double_fast.c", "compress/zstd_fast.c", "compress/zstd_lazy.c",
+ "compress/zstd_ldm.c", "compress/zstd_opt.c", "compress/zstd_preSplit.c",
+ "decompress/huf_decompress.c", "decompress/zstd_ddict.c", "decompress/zstd_decompress.c",
+ "decompress/zstd_decompress_block.c",
+ },
+ .flags = &.{
+ "-DXXH_NAMESPACE=ZSTD_", "-DZSTD_DISABLE_ASM", "-DZSTD_LEGACY_SUPPORT=0",
+ "-DDEBUGLEVEL=0", "-DZSTD_EXCLUDE_GREEDY_BLOCK_COMPRESSOR", "-DZSTD_EXCLUDE_LAZY2_BLOCK_COMPRESSOR",
+ "-DZSTD_EXCLUDE_BTLAZY2_BLOCK_COMPRESSOR", "-DZSTD_EXCLUDE_BTOPT_BLOCK_COMPRESSOR", "-DZSTD_EXCLUDE_BTULTRA_BLOCK_COMPRESSOR",
+ },
+ });
+ zstd.link_function_sections = true;
+ zstd.link_data_sections = true;
+ for (core_mods) |m| m.linkLibrary(zstd);
+ }
+
// One call per module instead of one line per module per dependency, and
// BEFORE the fold below, which reads what these imports put in the table.
for (core_mods) |m| wireCore(m, .{