Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/meson/lib/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ libzstd_sources = [join_paths(zstd_rootdir, 'lib/common/entropy_common.c'),
join_paths(zstd_rootdir, 'lib/dictBuilder/divsufsort.c'),
join_paths(zstd_rootdir, 'lib/dictBuilder/zdict.c')]

# The assembly source only has an x86_64 implementation, so only build it there.
# really we need anything that defines __GNUC__ as that is what ZSTD_ASM_SUPPORTED is gated on
# but these are the two compilers that are supported in tree and actually handle this correctly
# Otherwise, explicitly disable assembly.
if [compiler_gcc, compiler_clang].contains(cc_id)
if host_machine.cpu_family() == 'x86_64' and [compiler_gcc, compiler_clang].contains(cc_id)
libzstd_sources += join_paths(zstd_rootdir, 'lib/decompress/huf_decompress_amd64.S')
else
add_project_arguments('-DZSTD_DISABLE_ASM', language: 'c')
Expand Down
12 changes: 6 additions & 6 deletions lib/libzstd.mk
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ else
ZSTD_STRIP_ERROR_STRINGS ?= 0
endif

# Assembly support
ZSTD_NO_ASM ?= 0

ZSTD_LIB_EXCLUDE_COMPRESSORS_DFAST_AND_UP ?= 0
ZSTD_LIB_EXCLUDE_COMPRESSORS_GREEDY_AND_UP ?= 0

Expand Down Expand Up @@ -151,11 +148,14 @@ ZSTD_LEGACY_FILES :=

ZSTD_DECOMPRESS_AMD64_ASM_FILES := $(sort $(wildcard $(LIB_SRCDIR)/decompress/*_amd64.S))

ifneq ($(ZSTD_NO_ASM), 0)
# The assembly sources only have an x86_64 implementation, so only build
# them when the compiler targets x86_64. Ask the compiler instead of using
# uname so that cross-compiling and -m32 builds do the right thing.
ZSTD_ASM_X86_64 := $(shell echo | $(CC) $(CPPFLAGS) $(CFLAGS) -dM -E - 2>$(VOID) | $(GREP) -c '__x86_64__')

ifeq ($(ZSTD_ASM_X86_64), 0)
CPPFLAGS += -DZSTD_DISABLE_ASM
else
# Unconditionally add the ASM files they are disabled by
# macros in the .S file.
ZSTD_DECOMPRESS_FILES += $(ZSTD_DECOMPRESS_AMD64_ASM_FILES)
endif

Expand Down
Loading