mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
Fix zstd-dll build missing dependencies (#3496)
* Fixes zstd-dll build (https://github.com/facebook/zstd/issues/3492): - Adds pool.o and threading.o dependency to the zstd-dll target - Moves custom allocation functions into header to avoid needing to add dependency on common.o - Adds test target for zstd-dll - Adds github workflow that buildis zstd-dll
This commit is contained in:
9
.github/workflows/dev-short-tests.yml
vendored
9
.github/workflows/dev-short-tests.yml
vendored
@ -55,6 +55,14 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
make c89build V=1
|
make c89build V=1
|
||||||
|
|
||||||
|
build-zstd-dll:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # tag=v3
|
||||||
|
- name: build zstd bin against a dynamic lib (debuglevel for more dependencies)
|
||||||
|
run: |
|
||||||
|
make -C lib lib-mt-release
|
||||||
|
DEBUGLEVEL=2 make -C programs zstd-dll
|
||||||
|
|
||||||
gcc-7-libzstd:
|
gcc-7-libzstd:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -339,7 +347,6 @@ jobs:
|
|||||||
make -j -C programs allVariants MOREFLAGS=-O0
|
make -j -C programs allVariants MOREFLAGS=-O0
|
||||||
./tests/test-variants.sh
|
./tests/test-variants.sh
|
||||||
|
|
||||||
|
|
||||||
qemu-consistency:
|
qemu-consistency:
|
||||||
name: QEMU ${{ matrix.name }}
|
name: QEMU ${{ matrix.name }}
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
@ -24,9 +24,6 @@ EXPORT_SYMBOL_GPL(HUF_readStats_wksp);
|
|||||||
EXPORT_SYMBOL_GPL(ZSTD_isError);
|
EXPORT_SYMBOL_GPL(ZSTD_isError);
|
||||||
EXPORT_SYMBOL_GPL(ZSTD_getErrorName);
|
EXPORT_SYMBOL_GPL(ZSTD_getErrorName);
|
||||||
EXPORT_SYMBOL_GPL(ZSTD_getErrorCode);
|
EXPORT_SYMBOL_GPL(ZSTD_getErrorCode);
|
||||||
EXPORT_SYMBOL_GPL(ZSTD_customMalloc);
|
|
||||||
EXPORT_SYMBOL_GPL(ZSTD_customCalloc);
|
|
||||||
EXPORT_SYMBOL_GPL(ZSTD_customFree);
|
|
||||||
|
|
||||||
MODULE_LICENSE("Dual BSD/GPL");
|
MODULE_LICENSE("Dual BSD/GPL");
|
||||||
MODULE_DESCRIPTION("Zstd Common");
|
MODULE_DESCRIPTION("Zstd Common");
|
||||||
|
55
lib/common/allocations.h
Normal file
55
lib/common/allocations.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This source code is licensed under both the BSD-style license (found in the
|
||||||
|
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
|
||||||
|
* in the COPYING file in the root directory of this source tree).
|
||||||
|
* You may select, at your option, one of the above-listed licenses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This file provides custom allocation primitives
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ZSTD_DEPS_NEED_MALLOC
|
||||||
|
#include "zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */
|
||||||
|
|
||||||
|
#include "mem.h" /* MEM_STATIC */
|
||||||
|
#define ZSTD_STATIC_LINKING_ONLY
|
||||||
|
#include "../zstd.h" /* ZSTD_customMem */
|
||||||
|
|
||||||
|
#ifndef ZSTD_ALLOCATIONS_H
|
||||||
|
#define ZSTD_ALLOCATIONS_H
|
||||||
|
|
||||||
|
/* custom memory allocation functions */
|
||||||
|
|
||||||
|
MEM_STATIC void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem)
|
||||||
|
{
|
||||||
|
if (customMem.customAlloc)
|
||||||
|
return customMem.customAlloc(customMem.opaque, size);
|
||||||
|
return ZSTD_malloc(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem)
|
||||||
|
{
|
||||||
|
if (customMem.customAlloc) {
|
||||||
|
/* calloc implemented as malloc+memset;
|
||||||
|
* not as efficient as calloc, but next best guess for custom malloc */
|
||||||
|
void* const ptr = customMem.customAlloc(customMem.opaque, size);
|
||||||
|
ZSTD_memset(ptr, 0, size);
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
return ZSTD_calloc(1, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
MEM_STATIC void ZSTD_customFree(void* ptr, ZSTD_customMem customMem)
|
||||||
|
{
|
||||||
|
if (ptr!=NULL) {
|
||||||
|
if (customMem.customFree)
|
||||||
|
customMem.customFree(customMem.opaque, ptr);
|
||||||
|
else
|
||||||
|
ZSTD_free(ptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* ZSTD_ALLOCATIONS_H */
|
@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
|
|
||||||
/* ====== Dependencies ======= */
|
/* ====== Dependencies ======= */
|
||||||
|
#include "../common/allocations.h" /* ZSTD_customCalloc, ZSTD_customFree */
|
||||||
#include "zstd_deps.h" /* size_t */
|
#include "zstd_deps.h" /* size_t */
|
||||||
#include "debug.h" /* assert */
|
#include "debug.h" /* assert */
|
||||||
#include "zstd_internal.h" /* ZSTD_customCalloc, ZSTD_customFree */
|
|
||||||
#include "pool.h"
|
#include "pool.h"
|
||||||
|
|
||||||
/* ====== Compiler specifics ====== */
|
/* ====== Compiler specifics ====== */
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
* Dependencies
|
* Dependencies
|
||||||
***************************************/
|
***************************************/
|
||||||
#define ZSTD_DEPS_NEED_MALLOC
|
#define ZSTD_DEPS_NEED_MALLOC
|
||||||
#include "zstd_deps.h" /* ZSTD_malloc, ZSTD_calloc, ZSTD_free, ZSTD_memset */
|
|
||||||
#include "error_private.h"
|
#include "error_private.h"
|
||||||
#include "zstd_internal.h"
|
#include "zstd_internal.h"
|
||||||
|
|
||||||
@ -47,37 +46,3 @@ ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
|
|||||||
/*! ZSTD_getErrorString() :
|
/*! ZSTD_getErrorString() :
|
||||||
* provides error code string from enum */
|
* provides error code string from enum */
|
||||||
const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
|
const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*=**************************************************************
|
|
||||||
* Custom allocator
|
|
||||||
****************************************************************/
|
|
||||||
void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem)
|
|
||||||
{
|
|
||||||
if (customMem.customAlloc)
|
|
||||||
return customMem.customAlloc(customMem.opaque, size);
|
|
||||||
return ZSTD_malloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem)
|
|
||||||
{
|
|
||||||
if (customMem.customAlloc) {
|
|
||||||
/* calloc implemented as malloc+memset;
|
|
||||||
* not as efficient as calloc, but next best guess for custom malloc */
|
|
||||||
void* const ptr = customMem.customAlloc(customMem.opaque, size);
|
|
||||||
ZSTD_memset(ptr, 0, size);
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
return ZSTD_calloc(1, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ZSTD_customFree(void* ptr, ZSTD_customMem customMem)
|
|
||||||
{
|
|
||||||
if (ptr!=NULL) {
|
|
||||||
if (customMem.customFree)
|
|
||||||
customMem.customFree(customMem.opaque, ptr);
|
|
||||||
else
|
|
||||||
ZSTD_free(ptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -350,11 +350,6 @@ typedef struct {
|
|||||||
const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */
|
const seqStore_t* ZSTD_getSeqStore(const ZSTD_CCtx* ctx); /* compress & dictBuilder */
|
||||||
int ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
|
int ZSTD_seqToCodes(const seqStore_t* seqStorePtr); /* compress, dictBuilder, decodeCorpus (shouldn't get its definition from here) */
|
||||||
|
|
||||||
/* custom memory allocation functions */
|
|
||||||
void* ZSTD_customMalloc(size_t size, ZSTD_customMem customMem);
|
|
||||||
void* ZSTD_customCalloc(size_t size, ZSTD_customMem customMem);
|
|
||||||
void ZSTD_customFree(void* ptr, ZSTD_customMem customMem);
|
|
||||||
|
|
||||||
|
|
||||||
/* ZSTD_invalidateRepCodes() :
|
/* ZSTD_invalidateRepCodes() :
|
||||||
* ensures next compression will not use repcodes from previous block.
|
* ensures next compression will not use repcodes from previous block.
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
/*-*************************************
|
/*-*************************************
|
||||||
* Dependencies
|
* Dependencies
|
||||||
***************************************/
|
***************************************/
|
||||||
|
#include "../common/allocations.h" /* ZSTD_customMalloc, ZSTD_customCalloc, ZSTD_customFree */
|
||||||
#include "../common/zstd_deps.h" /* INT_MAX, ZSTD_memset, ZSTD_memcpy */
|
#include "../common/zstd_deps.h" /* INT_MAX, ZSTD_memset, ZSTD_memcpy */
|
||||||
#include "../common/mem.h"
|
#include "../common/mem.h"
|
||||||
#include "hist.h" /* HIST_countFast_wksp */
|
#include "hist.h" /* HIST_countFast_wksp */
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
/*-*************************************
|
/*-*************************************
|
||||||
* Dependencies
|
* Dependencies
|
||||||
***************************************/
|
***************************************/
|
||||||
|
#include "../common/allocations.h" /* ZSTD_customMalloc, ZSTD_customFree */
|
||||||
#include "../common/zstd_internal.h"
|
#include "../common/zstd_internal.h"
|
||||||
|
|
||||||
#if defined (__cplusplus)
|
#if defined (__cplusplus)
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/* ====== Dependencies ====== */
|
/* ====== Dependencies ====== */
|
||||||
|
#include "../common/allocations.h" /* ZSTD_customMalloc, ZSTD_customCalloc, ZSTD_customFree */
|
||||||
#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memset, INT_MAX, UINT_MAX */
|
#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memset, INT_MAX, UINT_MAX */
|
||||||
#include "../common/mem.h" /* MEM_STATIC */
|
#include "../common/mem.h" /* MEM_STATIC */
|
||||||
#include "../common/pool.h" /* threadpool */
|
#include "../common/pool.h" /* threadpool */
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
/*-*******************************************************
|
/*-*******************************************************
|
||||||
* Dependencies
|
* Dependencies
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
|
#include "../common/allocations.h" /* ZSTD_customMalloc, ZSTD_customFree */
|
||||||
#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memmove, ZSTD_memset */
|
#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memmove, ZSTD_memset */
|
||||||
#include "../common/cpu.h" /* bmi2 */
|
#include "../common/cpu.h" /* bmi2 */
|
||||||
#include "../common/mem.h" /* low level memory routines */
|
#include "../common/mem.h" /* low level memory routines */
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
/*-*******************************************************
|
/*-*******************************************************
|
||||||
* Dependencies
|
* Dependencies
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
|
#include "../common/allocations.h" /* ZSTD_customMalloc, ZSTD_customCalloc, ZSTD_customFree */
|
||||||
#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memmove, ZSTD_memset */
|
#include "../common/zstd_deps.h" /* ZSTD_memcpy, ZSTD_memmove, ZSTD_memset */
|
||||||
#include "../common/mem.h" /* low level memory routines */
|
#include "../common/mem.h" /* low level memory routines */
|
||||||
#define FSE_STATIC_LINKING_ONLY
|
#define FSE_STATIC_LINKING_ONLY
|
||||||
|
@ -225,7 +225,7 @@ zstd-noxz : zstd
|
|||||||
.PHONY: zstd-dll
|
.PHONY: zstd-dll
|
||||||
zstd-dll : LDFLAGS+= -L$(LIBZSTD)
|
zstd-dll : LDFLAGS+= -L$(LIBZSTD)
|
||||||
zstd-dll : LDLIBS += -lzstd
|
zstd-dll : LDLIBS += -lzstd
|
||||||
zstd-dll : ZSTDLIB_LOCAL_SRC = xxhash.c
|
zstd-dll : ZSTDLIB_LOCAL_SRC = xxhash.c pool.c threading.c
|
||||||
zstd-dll : zstd
|
zstd-dll : zstd
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ allnothread: fullbench fuzzer paramgrill datagen decodecorpus
|
|||||||
dll: fuzzer-dll zstreamtest-dll
|
dll: fuzzer-dll zstreamtest-dll
|
||||||
|
|
||||||
.PHONY: zstd zstd32 zstd-nolegacy # only external makefile knows how to build or update them
|
.PHONY: zstd zstd32 zstd-nolegacy # only external makefile knows how to build or update them
|
||||||
zstd zstd32 zstd-nolegacy:
|
zstd zstd32 zstd-nolegacy zstd-dll:
|
||||||
$(MAKE) -C $(PRGDIR) $@ MOREFLAGS+="$(DEBUGFLAGS)"
|
$(MAKE) -C $(PRGDIR) $@ MOREFLAGS+="$(DEBUGFLAGS)"
|
||||||
|
|
||||||
.PHONY: libzstd
|
.PHONY: libzstd
|
||||||
@ -328,13 +328,17 @@ test-all: test test32 test-decodecorpus-cli
|
|||||||
test-zstd: ZSTD = $(PRGDIR)/zstd
|
test-zstd: ZSTD = $(PRGDIR)/zstd
|
||||||
test-zstd: zstd
|
test-zstd: zstd
|
||||||
|
|
||||||
|
.PHONY: test-zstd-dll
|
||||||
|
test-zstd-dll: ZSTD = $(PRGDIR)/zstd
|
||||||
|
test-zstd-dll: zstd-dll
|
||||||
|
|
||||||
test-zstd32: ZSTD = $(PRGDIR)/zstd32
|
test-zstd32: ZSTD = $(PRGDIR)/zstd32
|
||||||
test-zstd32: zstd32
|
test-zstd32: zstd32
|
||||||
|
|
||||||
test-zstd-nolegacy: ZSTD = $(PRGDIR)/zstd-nolegacy
|
test-zstd-nolegacy: ZSTD = $(PRGDIR)/zstd-nolegacy
|
||||||
test-zstd-nolegacy: zstd-nolegacy
|
test-zstd-nolegacy: zstd-nolegacy
|
||||||
|
|
||||||
test-zstd test-zstd32 test-zstd-nolegacy: datagen
|
test-zstd test-zstd32 test-zstd-nolegacy test-zstd-dll: datagen
|
||||||
file $(ZSTD)
|
file $(ZSTD)
|
||||||
EXE_PREFIX="$(QEMU_SYS)" ZSTD_BIN="$(ZSTD)" DATAGEN_BIN=./datagen ./playTests.sh $(ZSTDRTTEST)
|
EXE_PREFIX="$(QEMU_SYS)" ZSTD_BIN="$(ZSTD)" DATAGEN_BIN=./datagen ./playTests.sh $(ZSTDRTTEST)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user